CMD:vfixveh(playerid, params[]) { new vip[MAX_PLAYER_NAME], string[128], Float:health; new FVTime = tickcount() - 180000; FixvehTimer[playerid] = GetTickCount(); TimerInfo[playerid][CMD_vfixveh] = tickcount(); if(Player[playerid][pVip] < 2) { SCM(pid, ADMIN_COLOR, ADMIN_MESSAGE); return 1; } new vehicleid = GetPlayerVehicleID(playerid); new vehicleHp = GetVehicleHealth(playerid, health); GetPlayerName(playerid, vip, sizeof(vip)); if(vehicleHp == 1000) { SCM(pid, ADMIN_COLOR, " Your vehicle is already at full hp!"); return 1; } if(!IsPlayerInAnyVehicle(playerid)) { SCM(pid, ADMIN_COLOR, " You are not in any vehicle."); FVTime = tickcount() - 180000; return 1; } if( GetTickCount() - FixvehTimer[playerid] < 180000 ) { RepairVehicle(vehicleid); SCM(pid, -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); SetTimerEx("EndFixvehTimer", 180000, false, "i", playerid); return 1; } else { if(FVTime < TimerInfo[playerid][CMD_vfixveh]) { SCM(pid, -1, "{F71B9C} You can only use this command every 3 minutes."); return 1; } } return 1; }
CMD:test(playerid) { if(TimerInfo[playerid][CMD_vfixveh] < gettime()) { SCM(pid, -1, "{F71B9C} Command executed!"); TimerInfo[playerid][CMD_vfixveh] = gettime() + 180; } else { SCM(pid, -1, "{F71B9C} You can only use this command every 3 minutes."); } return 1; }
if(( GetTickCount() - FixvehTimer[playerid] ) < 180000 )
{
RepairVehicle(vehicleid);
SCM(pid, -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);
SetTimerEx("EndFixvehTimer", 180000, false, "i", playerid);
return 1;
}
else
{
if(FVTime < TimerInfo[playerid][CMD_vfixveh])
{
SCM(pid, -1, "{F71B9C} You can only use this command every 3 minutes.");
return 1;
}
}
return 1;
}
if( GetTickCount() - FixvehTimer[playerid] < 180000 )
if( FixvehTimer[playerid] < 180000 )
CMD:vfixveh(playerid, params[])
{
new vip[MAX_PLAYER_NAME], string[128], Float:health;
new FVTime = tickcount() - 180000;
FixvehTimer[playerid] = GetTickCount();
TimerInfo[playerid][CMD_vfixveh] = tickcount();
if(Player[playerid][pVip] < 2) return SCM(pid, ADMIN_COLOR, ADMIN_MESSAGE);
new vehicleid = GetPlayerVehicleID(playerid);
new vehicleHp = GetVehicleHealth(playerid, health);
GetPlayerName(playerid, vip, sizeof(vip));
if(vehicleHp == 1000) return SCM(pid, ADMIN_COLOR, " Your vehicle is already at full hp!");
if(!IsPlayerInAnyVehicle(playerid))
{
SCM(pid, ADMIN_COLOR, " You are not in any vehicle.");
FVTime = tickcount() - 180000;
return 1;
}
else if( GetTickCount() - FixvehTimer[playerid] < 180000 )
{
RepairVehicle(vehicleid);
SCM(pid, -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);
SetTimerEx("EndFixvehTimer", 180000, false, "i", playerid);
return 1;
}
else
{
if(FVTime < TimerInfo[playerid][CMD_vfixveh])
{
SCM(pid, -1, "{F71B9C} You can only use this command every 3 minutes.");
return 1;
}
}
return 1;
}
// 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.
|
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 код:
|