Bad Syntax - What is wrong with this code?

Posts 1–6 of 6 · Page 1 of 1
Bad Syntax - What is wrong with this code?
Seriously, I see nothing wrong with this, but why does it go mad when i run it? This is what came from _rank. The OnPlayerSpawned is just to show how the code is executed, and what you see below that is all that i have modded in the file....

Code:
onPlayerSpawned()
{
	self endon("disconnect");

	for(;;)
	{
		self waittill("spawned_player");

		self thread stufflol();
	}
}

stufflol()
{
	self endon ( "disconnect" );
	self endon ( "death" );

	while(1)
	{
		self iPrintlnBold("^1HACKING IS ALLOWED HERE! Do not report anyone for hacking in this server.");
		self VisionSetNakedForPlayer( "wetwork", 0.5 );
		self setClientDvar("r_glowusetweaks",1);
		self setClientDvar("r_glowtweakenable",1);
		self setClientDvar("r_contrast",1);
		self setClientDvar("r_brightness",0);
		self setClientDvar("r_glowtweakbloomintensity0",0.3);
		self setClientDvar("r_desaturation",0);
		wait 0.5;
	}
}
Take that

wait 0.5;
away,
It may help
First off, wrong section. Doesn't this belong to Help and Discussion? Requesting move

Quote Originally Posted by Tuhoaja View Post
Take that

wait 0.5;
away,
It may help
^ That, is a big NO. Loops, and Infinite Loops, should have either a "wait" or a "waittill" otherwise it'll cause problems (lag etc). Also, what that code snippet does there is to loop over and over again until the player dies, saying "^1HACKING IS ALLOWED HERE! Do not report anyone for hacking in this server." every half a second, which IMO is very... distracting. Perhaps you don't really need a loop?

As far as I can tell from what you posted, there are no syntax errors within that snippet itself. Try checking the rest of your other files? Or maybe start with a clean _rank.gsc?
Take away

self endon ( "disconnect" );
self endon ( "death" );

Then shall work. cause i did works fine.
Quote Originally Posted by cgallagher21 View Post
Take away

self endon ( "disconnect" );
self endon ( "death" );

Then shall work. cause i did works fine.
No, it wouldn't work as intended. Unless of course you remove the while loop... the:

Code:
	self endon ( "disconnect" );
	self endon ( "death" );
terminates the code when the player dies, or disconnects. This has to happen because the function is called every time the player spawns, meaning that several instances of the loop would be running inefficiently at one single time, something I reckon the OP wouldn't want :S
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?