30.08.2013, 02:50
(
Последний раз редактировалось PROJECTO; 22.04.2014 в 17:11.
Причина: Reparado
)
Reparado
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[]) {
if(strcmp("/radiopos", cmdtext, true) == 0) {
if(IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid,-1 ,"[!] No puedes usar el comando en el vehiculo, bajate!.");
new count=0, veh=0, Float:pos[2][3];
GetPlayerPos(playerid, pos[0][0], pos[0][1], pos[0][2]);
for(new vehicleid=0; vehicleid<MAX_VEHICLES; vehicleid++) {
if(!IsVehicleInRangeOfPoint(vehicleid, 3.5, pos[0][0], pos[0][1], pos[0][2])) continue;
if(IsVehicleInRangeOfPoint(vehicleid, 3.5, pos[0][0], pos[0][1], pos[0][2])) {
veh = vehicleid;
count++;
break;
}
}
switch(count) {
case 1: {
//Se han encontrados 1 vehiculo cerca
GetVehiclePos(veh, pos[1][0], pos[1][1], pos[1][2]);
PlayAudioStreamForPlayer(playerid, "http://tumusica", pos[1][0], pos[1][1], pos[1][2], 20.0, 1);
}
default: {
//Se han encontrados varis vehiculos cerca tuyo
}
}
return true;
}
return false ;
}
stock IsVehicleInRangeOfPoint(vehicleid, Float:radi, Float:x, Float:y, Float:z) {
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetVehiclePos(vehicleid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
return true;
} return false;
}