10.04.2019, 03:24
Como eu faзo para pegar o ID do veiculo que estб perto com um comando?
Prox_Vehicle(playerid){
new Float:v_pos[3];
for(new v = 0; v < GetVehiclePoolSize(); v++){
GetVehiclePos(v, v_pos[0], v_pos[1], v_pos[2]);
if(IsPlayerInRangeOfPoint(playerid, 10.5, v_pos[0], v_pos[1], v_pos[2]))
return i;
}
return -1;
}
GetNearestVehicleFromPlayer(playerid, Float:distance = 30.0) {
new
Float:min_dist,
vehicleid = INVALID_VEHICLE_ID,
Float:x,
Float:y,
Float:z;
GetPlayerPos(playerid, x, y, z);
for (new i = (GetVehiclePoolSize() + 1); --i != 0;) {
if ((min_dist = GetVehicleDistanceFromPoint(i, x, y, z)) <= distance) {
vehicleid = i;
distance = min_dist;
}
}
return vehicleid;
}
format(string, sizeof string, "O ID do veiculo й %d", );
SendClientMessage(playerid, -1, string);
Como que eu faзo para usar? Tipo...
PHP Code:
|
new
str[23];
format(str, sizeof(str), "O ID do veiculo й %d", GetNearestVehicleFromPlayer(playerid));
SendClientMessage(playerid, -1, str);
PHP Code:
|
GetNearestVehicleFromPlayer(playerid, Float:distance = 30.0)
{
new
Float: hPos[3];
for(new v = 1; v != MAX_VEHICLES; ++ v)
{
GetVehiclePos(v, hPos[0], hPos[1], hPos[2]);
if(IsPlayerInRangeOfPoint(playerid, distance, hPos[0], hPos[1], hPos[2]))
{
return v;
}
}
return INVALID_VEHICLE_ID;
}
CMD:veiculoproximo(playerid)
{
new string[50];
new carro;
carro = GetNearestVehicleFromPlayer(playerid);
if(carro != INVALID_VEHICLE_ID)
{
format(string, sizeof(string), "O Veнculo Mais prуximo й o Veнculo ID: %d.", carro);
SCM(playerid, -1, string);
}
else
{
SCM(playerid, COLOR_ERRO, "Nгo existe nenhum veнculo perto de vocк.");
}
return 1;
}