Small script problem
#7

The way you have made this command is really bad. That's not how you check if a vehicle's health is equal to 1000 either. Plus, gettime() is a better replacement for GetTickCount().

Anyway, I have optimized your code a little. Try it out and let me know how it turns out.

PHP код:
// You can replace this array with your current tick holder or use this one directly
new g_RepairTime[MAX_PLAYERS]; // Global array, put this on top of your script
// Inside OnPlayerConnect
    
g_RepairTime[playerid] = 0;
    
CMD:vfixveh(playeridparams[])
{
    if(
Player[playerid][pVip] < 2)
        return 
SCM(playeridADMIN_COLORADMIN_MESSAGE);
    if(!
IsPlayerInAnyVehicle(playerid))
        return 
SCM(playeridADMIN_COLOR" You are not in any vehicle.");
        
    if (
g_RepairTime[playerid] > gettime())
        return 
SCM(playeridADMIN_COLOR"You need to wait 3 minutes before using this command.");
    new 
vehicleidFloathealth;
    
    
vehicleid GetPlayerVehicleID(playerid);
    
GetVehicleHealth(vehicleidhealth);
    if(
health == 1000.0)
        return 
SCM(playeridADMIN_COLOR" Your vehicle is already at full hp!");
    new 
vip[MAX_PLAYER_NAME], string[128],
    
GetPlayerName(playeridvipsizeof(vip));
    
    
RepairVehicle(vehicleid);
    
SCM(playerid, -1" {74FF5C}You have fixed your vehicle! You'll be able to use this command again after 3 minutes.");
    
format(stringsizeof(string), "{EB4255}[VIP CMD] VIP Player %s has repaired his vehicle."vip);
    
SendManagerMessage(-1string);
    
g_RepairTime[playerid] = (gettime() + 180);
    return 
1;

And btw, why are you using that "pid" inside this command? There's no pid here.
Reply


Messages In This Thread
Small script problem - by JXF - 24.06.2016, 20:11
Re: Small script problem - by F1N4L - 24.06.2016, 20:22
Re: Small script problem - by jlalt - 24.06.2016, 20:31
Re: Small script problem - by JXF - 24.06.2016, 20:48
Re: Small script problem - by IceBilizard - 25.06.2016, 04:15
Re: Small script problem - by JXF - 25.06.2016, 10:57
Re: Small script problem - by Sjn - 25.06.2016, 11:36
Re: Small script problem - by Sew_Sumi - 25.06.2016, 12:15
Re: Small script problem - by JXF - 28.06.2016, 16:34

Forum Jump:


Users browsing this thread: 1 Guest(s)