Posts: 240
Threads: 5
Joined: Nov 2017
Quote:
Originally Posted by RogueDrifter
I'd say try this:
PHP код:
new Rainbow_Timer[MAX_PLAYERS];
CMD:rainbow(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be a driver in a vehicle to use that command.");
ChangeVehicleColor(GetPlayerVehicleID(playerid),-1,-1);
Rainbow_Timer[playerid] = SetTimerEx("RainBow", 2000, true, "i", playerid);
return 1;
}
forward RainBow(playerid);
public RainBow(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) ChangeVehicleColor(GetPlayerVehicleID(playerid),-1,-1);
return 1;
}
And use:
Код:
KillTimer(Rainbow_Timer[playerid]);
At OnPlayerDisconnect strictly:
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(Rainbow_Timer[playerid]);
return 1;
}
and
OnPlayerStateChange with a state check
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 1 && oldstate == 2) KillTimer(Rainbow_Timer[playerid]);
return 1;
}
|
KillTimer(Rainbow_Timer[playerid]);
should be
KillTimer(Rainbow_Timer(playerid)); since the compiler complains when i use [playerid] for timers