CMD:rainbow(playerid, params[]) { if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be a driver in a vehicle to use that command."); } else { new vehicleid; GetPlayerVehicleID(playerid); ChangeVehicleColor(vehicleid,-1,-1); SetTimerEx("RainBow", 2000, true, "i", playerid); } return 1; } forward RainBow(playerid); public RainBow(playerid) { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vehicleid; GetPlayerVehicleID(playerid); ChangeVehicleColor(vehicleid,-1,-1); SetTimerEx("RainBow", 2000, true, "i", playerid); } return 1; }
new vehicleid; GetPlayerVehicleID(playerid); |
new vehicleid = GetPlayerVehicleID(playerid);
new hasplayerrainbow[MAX_PLAYERS] = false;
CMD:rainbow(playerid, params[])
{
if(hasplayerrainbow[playerid]) return SendClientMessage(playerid, -1, "You already have rainbow");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, -1, "[ERROR]: You need to be a driver in a vehicle to use that command.");
}
else
{
new vehicleid = GetPlayerVehicleID(playerid);
ChangeVehicleColor(vehicleid,-1,-1);
SetTimerEx("RainBow", 2000, true, "i", playerid);
}
return 1;
}
forward RainBow(playerid);
public RainBow(playerid)
{
if(!hasplayerrainbow[playerid])
{
KillTimer(RainBow(playerid));
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
hasplayerrainbow[playerid] = true;
new vehicleid = GetPlayerVehicleID(playerid);
ChangeVehicleColor(vehicleid,-1,-1);
SetTimerEx("RainBow", 2000, true, "i", playerid);
}
return 1;
}
CMD:killrainbow(playerid, params[])
{
if (hasplayerrainbow[playerid])
{
hasplayerrainbow[playerid] = false;
KillTimer(RainBow(playerid));
SendClientMessage(playerid, -1, "rainbow deactivated");
}
else
{
SendClientMessage(playerid, -1, "you don't have rainbow activated");
}
}
Код:
CMD:rainbow(playerid, params[]) { if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessage(playerid, -1, "[ERROR]: You need to be a driver in a vehicle to use that command."); } else { new vehicleid = GetPlayerVehicleID(playerid); ChangeVehicleColor(vehicleid,-1,-1); SetTimerEx("RainBow", 2000, true, "i", playerid); } return 1; } forward RainBow(playerid); public RainBow(playerid) { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vehicleid = GetPlayerVehicleID(playerid); ChangeVehicleColor(vehicleid,-1,-1); SetTimerEx("RainBow", 2000, true, "i", playerid); } return 1; } |
Yea, I've tried making it like that too. It still just changes the car color once and that's all.
It's like the timer doesn't effect or exist. |
Why do you set the same timer twice if one is already is repeating?remove the one in the function
|
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;
}
KillTimer(Rainbow_Timer[playerid]);
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(Rainbow_Timer[playerid]);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 1 && oldstate == 2) KillTimer(Rainbow_Timer[playerid]);
return 1;
}
I'd say try this:
PHP код:
Код:
KillTimer(Rainbow_Timer[playerid]); PHP код:
OnPlayerStateChange with a state check PHP код:
|
KillTimer(Rainbow_Timer[playerid]);
should be KillTimer(Rainbow_Timer(playerid)); since the compiler complains when i use [playerid] for timers |