Jump to content
Sign in to follow this  
SRBuckey5266

Function isn't sleeping?

Recommended Posts

Any idea why my script doesn't sleep for the 7 seconds it's suppose to?

da_name_of_me = name player;
serialkiller = true;

player addEventHandler ["Fired", {
if(serialkiller) then {
	[] call change_name;
};
}];

change_back = {
hint "John Doe";
player setIdentity "John";
sleep 7;
player setIdentity da_name_of_me;
hint format["%1", da_name_of_me];
};

if(!serialkiller) then {
player removeEventHandler ["Fired", 0];
};

Share this post


Link to post
Share on other sites

IMO

You are calling a function from within event handler, therefore out of scheduler, where sleepeing, as always except SQS' ~ command, is not allowed, same as waitUntil-ing. Use spawn command instead of call to begin new, scheduled scope, where sleep is allowed, or spawn as separate scope only part of the called function, where action after the sleep is desired.

Not sure however, as name of the called function is other than name of defined fuction (change_name and change_back).

Edited by Rydygier

Share this post


Link to post
Share on other sites

you can't have sleep inside a call, use spawn instead. unlike the call command spawn isn't returning immediately but it's separate process.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×