Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 41 Guests
Online:

LATEST FORUM THREADS

»
Gaming
Q4 General
eXtreme+ v2.9
CoDBO Map + Mod Releases
map loading error
CoD2 MP Mapping
Good Servers on PC
CoDBO General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: define cvar-changer person
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Mar. 9, 2012 01:40 pm
hello,

if i got this:
Code:

test()
{ 
while (1) 
 {
 if ( getcvar("state") != "0" ) {
  changer = ???
  changer iprintln("you changed state"); }
 wait 1;
 }
}


is there any way to define "changer" as me, if i wrote to console /state 1 ?
if my friend write it (rcon state 1) then changer= my friend

it is possible with only one command to change a cvar and define another cvar as a player?

edited on Mar. 9, 2012 01:41 pm by kimistatheone
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Mar. 9, 2012 01:58 pm
I have no idea what you want.
Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Mar. 9, 2012 02:50 pm
[lol]
for example, i want to kill someone on my MP server. there are a simple killplayer() function, which kills the player which number i typed in.
f.e. i type rcon killplayer 5, then the player#5 will die. its okay, but i want to show him a message, but not like this "admin killed you".

if there are 3 admins on the server, write to player the name of the admin who killed him (who typed the killplayer)

after all, i want to define the admin who typed an rcon command, as a cvar.
is there a function like this?

i hope u understand me.
Share |
BraX
General Member
Since: Apr 29, 2008
Posts: 413
Last: May 26, 2012
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Mar. 9, 2012 03:26 pm
This is for you:
http://zeroy.com/script/debug/iprintlnbold.htm
http://zeroy.com/script/debug/iprintln.htm


@edit:
You're lucky that i'm bored, here it is:
Code:

main()
{
	level.RConCommands = [];

	// in this way you could add your own commands
	// when you type \rcon killplayer 1 function cmd_killplayer will be called etc.
	RegisterCmd( "killplayer", ::cmd_killplayer );
	RegisterCmd( "msg", ::cmd_message );

	//this loop checks if cvar/dvar was changed and if it was then call correct function
	while( 1 )
	{
		wait 0.1;
		for( i = 0; i < level.RConCommands.size; i++ )
		{
			value = getCvar( level.RConCommands[i].name );
			if( value != "" )
			{
				[[level.RConCommands[i].function]]( value );
				setCvar( level.RConCommands[i].name, "" );
			}
		}
	}
}


RegisterCmd( name, function )
{
	cmd = spawnStruct();
	cmd.name = name;
	cmd.function = function;

	level.RConCommands[level.RConCommands.size] = cmd;
}


cmd_killplayer( id )
{
	random = [];
	random[0] = "Slappin'";
	random[1] = "Hearth attack!";
	random[2] = "Scared to death";
	random[3] = "God will be with You... allways" );


	players = getEntArray( "player", "classname" )
	for( i = 0; i < players.size; i++ )
	{
		if( players[i] getEntityNumber() == id )
		{
			players[i] suicide();
			players[i] iPrintlnBold( random[randomInt(random.size)] );
			break;
		}
	}
}


cmd_message( message )
{
	iPrintlnBold( message );
}




Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Mar. 9, 2012 05:09 pm
thx, i hope it will help.

@edit
i know how to print a text or run a function. i think u didnt understand me. i wrote another example, i hope now u will understand what i want.

Code:

warp()
{
	setcvar("warp", "");
	while(1)
	{	if(getcvar("warp") != "")
		{
			Num = getcvarint("warp");
			players = getentarray("player", "classname");
			for(i = 0; i < players.size; i++)
			{
			if( num == -5 )  						  status = true;
			else if( num == -3 && players[i].pers["team"] == "axis" )       status = true;
			else if( num == -2 && players[i].pers["team"] == "allies" )     status = true;
			else if( num == players[i] getEntityNumber() )		  status = true;
			else								  status = false;

			if( status )
				{

				coord = level.neworigin + (20,0,0);
//				coord =self.Origin + (20,0,0);
				players[i] setOrigin( coord );
				}
			}
			setcvar("warp", "");
		}
		wait 0.05;
	}
}


i got another script where i define the level.neworigin = self.origin.
but this way i have to use 2 command to teleport a player to my postion. i want to use one command, so you can see i want to use a "coord = self.origin" thats is not defined i think. is there a way to use the teleport with only one command?

if u dont understand, i think i should stop making crazy ideas :D

edited on Mar. 10, 2012 04:33 am by kimistatheone
Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, May. 20, 2012 02:39 am
i can use a command on a zombie server:
/openscriptmenu sendmoney ClientID#value

how can i make a script, that watches 2 number in one command? (id and value)
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Sunday, May. 20, 2012 09:52 am
use a strtok(getcvar(cvar),separator) to identify multiple parts of a command.
Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, May. 20, 2012 12:06 pm
thx, i'll check it.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»