Quote:
Originally Posted by Sjn
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(playerid, params[])
{
if(Player[playerid][pVip] < 2)
return SCM(playerid, ADMIN_COLOR, ADMIN_MESSAGE);
if(!IsPlayerInAnyVehicle(playerid))
return SCM(playerid, ADMIN_COLOR, " You are not in any vehicle.");
if (g_RepairTime[playerid] > gettime())
return SCM(playerid, ADMIN_COLOR, "You need to wait 3 minutes before using this command.");
new vehicleid, Float: health;
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicleid, health);
if(health == 1000.0)
return SCM(playerid, ADMIN_COLOR, " Your vehicle is already at full hp!");
new vip[MAX_PLAYER_NAME], string[128],
GetPlayerName(playerid, vip, sizeof(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(string, sizeof(string), "{EB4255}[VIP CMD] VIP Player %s has repaired his vehicle.", vip);
SendManagerMessage(-1, string);
g_RepairTime[playerid] = (gettime() + 180);
return 1;
}
And btw, why are you using that "pid" inside this command? There's no pid here.
|
Thank you. It works perfectly.
Been inactive for a couple of days, and yes "pid" is defined as playerid in my script.