CMD:repair(playerid, params[]) return RepairVehicle(strval(params));
CMD:repair(playerid, params[]) { new Float:x, Float:y, Float:z; for (new i = 1, j = GetVehiclePoolSize(); i <= j) if (IsValidVehicle(i) && GetVehicleVirtualWorld(i) == GetPlayerVirtualWorld(playerid)) { GetVehiclePos(i, x, y, z); if (IsPlayerInRangeOfPoint(5.0, x, y, z)) { RepairVehicle(i); return 1; } } SendClientMessage(playerid, -1, "You are not in range of any vehicle."); return 1; }
#define VEHICLE_DISTANCE 3
stock GetVehicleNearPlayer(playerid)
{
new Float:x, Float:y, Float:z;
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(IsValidVehicle(i))
{
GetVehiclePos(i, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, VEHICLE_DISTANCE, x, y, z);
{
return i;
}
}
}
return INVALID_VEHICLE_ID;
}
CMD:repair(playerid, params[])
return RepairVehicle(GetVehicleNearPlayer(playerid));
I think you dont understand...
i already have the command, and is returning the correct VEHICLE ID, is just not repairing if the vehicle is not occupped |
new Float:vida, Float: distance, Float: x, Float: y, Float: z, Float: a;
new carro;
if(!IsPlayerInAnyVehicle(playerid))
{
carro = GetClosestVehicleFromPlayer(playerid);
GetPlayerPos(playerid, x, y, z);
distance = GetVehicleDistanceFromPoint(carro, x, y, z);
if(distance > 4) return SendClientMessage(playerid, -1, "Deves estar perto de um veнculo!");
GetVehicleHealth(carro, vida);
if(vida >= 1000) return SendClientMessage(playerid, -1, "O veнculo nгo precisa de ser reparado.");
SetTimerEx("RepararCarro", 10000, 0, "ii", playerid, carro);
TimerSomRepararCarro[playerid] = SetTimerEx("SomRepararCarro", 2500, 1, "i", playerid);
GameTextForPlayer(playerid,"~w~Reparando...",10000,3);
TogglePlayerControllable(playerid,0);
SetPlayerFacingAngle(playerid, a+90);
ApplyAnimation(playerid,"CAR","Fixn_Car_Loop",5.0,0,1,1,0,10000,1);
for(new i = 1; i < MAX_PLAYERS ; i++)
{
distance = GetPlayerDistanceFromPoint(i, x, y, z);
if(distance < 15)
{
PlayerPlaySound(i, 32000, 0, 0, 0);
}
}
return 1;
}
return 1;
}
public SomRepararCarro(playerid)
{
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
for(new i = 1; i < MAX_PLAYERS ; i++)
{
new Float:distance = GetPlayerDistanceFromPoint(i, x, y, z);
if(distance < 15)
{
PlayerPlaySound(i, 32000, 0, 0, 0);
}
}
return 1;
}
public RepararCarro(playerid, carro)
{
KillTimer(TimerSomRepararCarro[playerid]);
SetVehicleHealth(carro,1000);
RepairVehicle(carro);
TogglePlayerControllable(playerid,1);
SendClientMessage(playerid, -1,"Carro reparado com sucesso!");
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
for(new i = 1; i < MAX_PLAYERS ; i++)
{
new Float:distance = GetPlayerDistanceFromPoint(i, x, y, z);
if(distance < 15)
{
PlayerPlaySound(i, 1133, 0, 0, 0);
}
}
return 1;
}
new string[128];
format(string, sizeof(string), "%d", carro);
SendClientMessage(playerid, -1, string);
for(new i = 1; i < MAX_PLAYERS ; i++)
for(new i = 0; i < MAX_PLAYERS ; i++)