SA-MP Forums Archive
Timer / SetPlayertime - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer / SetPlayertime (/showthread.php?tid=136324)



Timer / SetPlayertime - XxerykxX - 24.03.2010

Hello i have a timer that sets players time to 11 and reset it after 0.1 secs :

Under gamemodeinit
Код:
SetTimer("czas",100,1);
end of gamemode
Код:
forward czas();
public czas(){
for(new i; i<200; i++){
if(IsPlayerConnected(i))
{
SetPlayerTime(i,11,0);
}
}
}
But when i type /night
My command:
Код:
if(strcmp(cmdtext, "/noc", true) == 0)
{
SetPlayerTime(playerid, 20 , 0);
return 1;
}
The players time change to 20 and change back to 11. How to fix?


Re: Timer / SetPlayertime - Drake1994 - 24.03.2010

try this:

Код:
SetPlayerTime(i,11,0);
put this to OnPlayerConnect and delete the forward czas and public czas


Re: Timer / SetPlayertime - Correlli - 24.03.2010

Quote:
Originally Posted by XxerykxX
The players time change to 20 and change back to 11. How to fix?
Of course it's changing back to 11 because you're setting it in your timer every 100 miliseconds.


Re: Timer / SetPlayertime - XxerykxX - 24.03.2010

yeah i know but there is one server and it works perfectly


Re: Timer / SetPlayertime - Drake1994 - 24.03.2010

try this:
Код:
if(strcmp(cmdtext, "/noc", true) == 0)
{
SetPlayerTime(playerid, 20 , 0);
KillTimer(czas);
return 1;
}

if(strcmp(cmdtext, "/czas", true) == 0)
{
SetTimer("czas",100,1);
return 1;
}
The /czas command start the Timer again. ( I think )


Re: Timer / SetPlayertime - XxerykxX - 24.03.2010

when i put KillTimer i got :
Код:
error 076: syntax error in the expression, or invalid function call



Re: Timer / SetPlayertime - Drake1994 - 24.03.2010

try this:
Код:
//PUT THIS ON YOUR SCRIPT TOP
new Timer;

//CHANGE THE /noc COMMAND KillTimer(czas); to
KillTimer(Timer);

//CHANGE THE SetTimer("czas",100,1); OnGameModeInit To
Timer = SetTimer("czas", 100,1);



Re: Timer / SetPlayertime - XxerykxX - 24.03.2010

not works