pawn Код:
if (strcmp("/fix", cmdtext, true, 10) == 0)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,RED,"You are not driving in any vehicle!");
new Float:vHealth,cost;
for(new i = 0; i < (1000 - (GetVehicleHealth(GetPlayerVehicleID(playerid),vHealth))); i += 3)
{
if(i - 1000 == 0) break; //If vehicle health is 1000
cost = i;
}
if(GetPlayerMoney(playerid) < cost) return SendClientMessage(playerid,RED,"You don't have enough money to fix your vehicle.");
SetVehicleHealth(GetPlayerVehicleID(playerid),1000);
GivePlayerMoney(playerid,GetPlayerMoney(playerid) - cost);
SendClientMessage(playerid,RED,"You have fixed your vehicle!");
}
Try this.
It adds 3 dollars for each 1% of car health. Examples:
If a car's health is 900, 1000-900 = 100, therefore the price would be $300.
If a car's health is 400, 1000-400 = 600, therefore the price would be $1,800.
If a car's health is 3, 1000-3 = 997, therefore the price would be $2,991.
If a car's health is -1,1000- -1 = 1001, therefore the price would be $3003. (No,that one won't happen).