Why does this do this ?
#3

You should consider using a function like gettime instead, not to mention your code could do with some cleaning up, here's an example:

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);
}
Code is a lot cleaner, easier to read and more efficient. No more useless timers, no more redundant code and/or repeating code!
Reply


Messages In This Thread
Why does this do this ? - by Geniuss - 11.06.2012, 20:24
Re: Why does this do this ? - by Makaveli93 - 11.06.2012, 20:27
Re: Why does this do this ? - by JaTochNietDan - 11.06.2012, 20:38

Forum Jump:


Users browsing this thread: 2 Guest(s)