11.06.2012, 20:38
You should consider using a function like gettime instead, not to mention your code could do with some cleaning up, here's an example:
Code is a lot cleaner, easier to read and more efficient. No more useless timers, no more redundant code and/or repeating code!
pawn Код:
new lastHotwire[MAX_PLAYERS];
command(hotwire, playerid, params[])
{
if((gettime() - 60) < lastHotwire[playerid]) return SendClientMessage(playerid, WHITE, "You can not hotwire a car yet");
if(!IsPlayerInAnyVehicle(playerid)) return; // Player is not in any vehicle.
if(engine == 1) return SendClientMessage(playerid, WHITE, "The vehicles engine is on no need to hotwire"); // One variable for all vehicles?
if(random(100) > 50)
{
// No need to initialize variables unless they are needed
new engine, lights, alarm, doors, bonnet, boot, objective, string[128];
new veh = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "%s has successfuly hotwired the vehicle", GetNameNoUnderScore(playerid));
IsPlayerInHotWiredCar = 1; // Single variable for 500 players? Odd!
}
else format(string, sizeof(string), "%s has failed at hotwiring the vehicle", GetNameNoUnderScore(playerid));
lastHotwire[playerid] = gettime();
NearByMessage(playerid, PURPLE, string);
}