08.12.2012, 04:55
Try this:
Where did you go wrong?
You use else instead of an else if statement, otherwise you would be setting the variable to 0, therefore the code just resets.
Код:
CMD:neon(playerid, params[]) { if(IsPlayerInAnyVehicle(playerid)) { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vehid = GetPlayerVehicleID(playerid); if(PlayerVehicleInfo[playerid][vehid][pvNeon] >= 1) { if(Neon[vehid] == 1) { UnloadNeon(playerid, vehid); SendClientMessageEx(playerid, COLOR_GREY, "Neon turned off."); Neon[vehid] = 0; } else if(Neon[vehid] == 0) { LoadNeon(playerid, vehid); SendClientMessageEx(playerid, COLOR_GREY, "Neon turned on."); Neon[vehid] = 1; } } else return SendClientMessageEx(playerid, COLOR_GREY, "This vehicle doesn't have neon!"); } else return SendClientMessageEx(playerid, COLOR_GREY, "You are not the driver!"); } else return SendClientMessageEx(playerid, COLOR_GREY, "You are not inside a Vehicle!"); return 1; }
Код:
if(Neon[vehid] == 1) { UnloadNeon(playerid, vehid); SendClientMessageEx(playerid, COLOR_GREY, "Neon turned off."); Neon[vehid] = 0; } else if(Neon[vehid] == 0) { LoadNeon(playerid, vehid); SendClientMessageEx(playerid, COLOR_GREY, "Neon turned on."); Neon[vehid] = 1; }