for(new i = 1; i < MAX_VEHICLES; i ++)
{
new Float:x, Float:y, Float:z;
GetVehiclePos(i, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
{
if(GetVehicleModel(i) == 443)
{
// codigo...
}
}
}
native IsValidVehicle(vehicleid);
// Ej. ModelVehicleIsNear(playerid, 522).
stock ModelVehicleIsNear(playerid, model, Float:radius = 5.0)
{
new
Float:vPos[3]
;
if(!IsPlayerConnected(playerid))
return 0;
for(new v = 1; v != MAX_VEHICLES; v++)
{
if(!IsValidVehicle(v))
continue;
GetVehiclePos(v, vPos[0], vPos[1], vPos[2]);
if(!IsPlayerInRangeOfPoint(playerid, radius, vPos[0], vPos[1], vPos[2]))
continue;
if(GetVehicleModel(v) != model)
continue;
return 1;
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/nrg_cerca", cmdtext, true, 10) == 0)
{
if(!ModelVehicleIsNear(playerid, 522, 6.0))
return SendClientMessage(playerid, -1, "No hay una NRG-500 cerca en 6 metros!");
SendClientMessage(playerid, -1, "Sн hay una NRG-500 cerca 6 metros!");
return 1;
}
return 0;
}
new Taxi;
public OnGameModeInit( )
{
// Agregar un taxi al juego con un tiempo de 60 segundos de reaparecer
Taxi = CreateVehicle(420, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
return 1;
}
new Float:pos[3], rango = 15;
GetVehiclePos(Taxi,pos[0],pos[1],pos[2]);
if(IsPlayerInRangeOfPoint(playerid,rango,pos[0],pos[1],pos[2])) printf("Esta cerca del vehiculo modelo # %i",GetVehicleModel(Taxi));
else print("No esta cerca de un taxi modelo 420");
Perdуn, escribн el mensaje justo cuando Sick lo estaba enviando. Aprovechando, estб en una funciуn.
PHP код:
PHP код:
|