Sign in to follow this  
ultranewbie

want a variable to store data in

Recommended Posts

Posted (edited)

i am trying to create a custom round script ... so far i am able to give weapons to all player present on the server... but when players join after the round initiated the the round is not effecting the player who joined later ... 

 

init()
{
	level.pers[ "customround" ] = 1;
	level.pers[ "customroundname"] = 0;
	/* 
	customround -> 0 = off , 1 = ON 
	customroundname -> 0 - off , 1 - sniper , 2 - knife, 3 - shotgun 
	*/
	
	
}

customroundname(roundname)
{
	players = getEntArray("player", "classname");

	for(i = 0; i < players.size ; i++)
	{
		

		switch(roundname)
		{
			case "sniper":
				level.pers["customround"] = 1;
				level.pers["customroundname"] = 1;
				players[i] takeAllWeapons();
				players[i] giveWeapon("m40a3_mp");
				players[i] givemaxammo("m40a3_mp");
				players[i] giveWeapon("remington700_mp");
				players[i] givemaxammo("remington700_mp");
				players[i] switchtoweapon( "m40a3_mp" );
				players[i] iPrintlnBold("^1Sniper round ^2Activated");
				break;
			case "knife":
				level.pers["customround"] = 1;
				level.pers["customroundname"] = 2;
				players[i] takeAllWeapons();
				players[i] giveWeapon("knife_mp");
				players[i] givemaxammo("knife_mp");
				players[i] giveWeapon("deserteagle_mp");
				players[i] SetWeaponAmmoClip( "deserteagle_mp", 0 );
				players[i] switchtoweapon( "deserteagle_mp" );
				players[i] iPrintln("^1Knife round ^2Activiated");
				break;
			case "shotgun":
				level.pers["customround"] = 1;
				level.pers["customroundname"] = 3;
				players[i] takeAllWeapons();
				players[i] giveWeapon("winchester1200_mp");
				players[i] givemaxammo("winchester1200_mp");
				players[i] giveWeapon("m1014_mp");
				players[i] givemaxammo("m1014_mp");
				players[i] switchtoweapon( "winchester1200_mp" );
				players[i] iPrintln("^1Shotgun round ^2Activitated");
				break;
			case "off":
				level.pers["customround"] = 0;
				level.pers["customroundname"] = 0;
				break;
			default:
				break;
		}
		code\player::init();
			
	}
}

is the variable that i taken is right ?  for storing round info

level.pers[ "customround" ] = 1;

level.pers[ "customroundname"] = 0;

on what variable i need to use for storing the value about that round  .... so that the players joined in the middle of the round, will also have the same (weapons and conditions ) as other players   

thank for any help

Edited by ultranewbie
added full code

Share this post


Link to post
Share on other sites

There is no level.pers array first of all. Just do level.yourcustomvariablename = something.

I suspect your customroundname function is designed to be called only once at the start of the round. However you also need to call the weapon functions... for the specific joining player... when joining a team. You should probably do it that way all the time for every player during the round. That way it will also take care of people going to spectate and rejoining.

Share this post


Link to post
Share on other sites

Thanks you for providing valuable information.... @INeedGames @Sheryl 

by checking loop btw spawned_player and death of player ... i managed to do stuff for rounds .. it also works (even if player joined to spectators or change team and back to team)

i came to understand that... I need to assign a variable  before player connected  server to check for that variable  because when player connected the init.gsx will check for variable to do stuff ....  thats way i cant able to assign variable in scripts (i am not sure how to do it)

if assigned in init.gsx then when ever a player connected to server the value will be changed. i tried to use isdefined() for checking to see if variable is defined or not . i thought it will work.

	if(!isDefined((level.customround) && (level.customroundname)))
	{
		level.customround = 0;
		level.customroundname = 0;
	}

servers started , but when player connected it giving error 

******* script runtime error *******
cannot cast undefined to bool: (file 'code/init.gsx', line 31)
 if(!isDefined((level.customround) && (level.customroundname)))
               *
called from:
(file 'code/init.gsx', line 14)
  player thread initialSetup();
                *
started from:
(file 'code/init.gsx', line 12)
  level waittill( "connected", player );
        *
************************************
----- Server Shutdown -----

and with other variables also same results  like (  game["customround"] and level.pers["customround"] )

Share this post


Link to post
Share on other sites

i figured it out .. i created another set of variables self.customround = 0; self.customroundname = 0; and assigned to all players in the server .... when a new player joins .... i created a function to check for this player.customround and player.customroundname working great. than  expected 😁😎 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this