24.03.2015, 16:30
So I've been trying to make a repair script, but they have to be in range.
All of that works but whenever I put an error usage if the player is not in range, it always returns that.
I'm talking about
Full command:
All of that works but whenever I put an error usage if the player is not in range, it always returns that.
I'm talking about
pawn Код:
} else {
SendClientMessage(playerid, -1, "{E74C3C}Error: You are not close to a repairing station! They are marked on the map with a red flag.");
break;
}
pawn Код:
CMD:repair(playerid, params[])
{
new vehid = GetPlayerVehicleID(playerid), Float:health, string[128];
GetVehicleHealth(vehid, Float:health);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{E74C3C}Error: You must be in a vehicle in order to repair a vehicle!");
if(Float:health == 1000) return SendClientMessage(playerid, -1, "{E74C3C}Error: Your vehicle is already fully repaired!");
for (new i = 0; i < sizeof (GasStations); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 75.0, GasStations[i][gX], GasStations[i][gY], GasStations[i][gZ]))
{
new Float:price = 1000-Float:health;
format(string, sizeof(string), "{2ECC71}You have successfully repaired your vehicle for {FFFFFF}$%1.0f", floatmul(Float:price, 5));
SendClientMessage(playerid, -1, string);
PlayerData[playerid][Money] += floatround(floatmul(Float:price, 5), floatround_ceil);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerData[playerid][Money]);
RepairVehicle(GetPlayerVehicleID(playerid));
} else {
SendClientMessage(playerid, -1, "{E74C3C}Error: You are not close to a repairing station! They are marked on the map with a red flag.");
break;
}
}
return 1;
}