Timer / SetPlayertime
#1

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?
Reply
#2

try this:

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

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.
Reply
#4

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

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 )
Reply
#6

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

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);
Reply
#8

not works
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)