Masold be a VehicleRadio funkciodat.
#telo
#include <a_samp>
#if !defined include_vehicle_radio
#define include_vehicle_radio
#endif
#define RADIO_DISTANCE 40.0
new RadioTimer = -1;
new RadioActive[MAX_PLAYERS][2];
enum RadioEN
{
Float:VRposX,
Float:VRposY,
Float:VRposZ,
mode
};
new VRadio[MAX_VEHICLES][RadioEN];
stock VehicleRadio(vehicleid,link[],bool:turn)
{
if(turn)
{
if(RadioTimer == -1) RadioTimer = SetTimerEx(\"VehicleRadioTimer\",1000,1,\"s[256]\",link);
VRadio[vehicleid][mode] = 1;
GetVehiclePos(vehicleid,VRadio[vehicleid][VRposX],VRadio[vehicleid][VRposY],VRadio[vehicleid][VRposZ]);
}
else
{
VRadio[vehicleid][mode] = 0;
}
return 1;
}
stock GetClosestVehicleEx(playerid,Float:dis = RADIO_DISTANCE)
{
new Float:distance[2] = 0.0,bool:count;
distance[1] = dis;
new vehicleid;
for(new i; i<MAX_VEHICLES; i++)
{
if(VRadio[mode] == 1)
{
new Float:pos[3];
GetVehiclePos(i,pos[0],pos[1],pos[2]);
distance[0] = GetPlayerDistanceFromPoint(playerid, pos[0],pos[1],pos[2]);
if(distance[0] < distance[1])
{
count = true;
distance[1] = distance[0];
vehicleid = i;
}
}
}
if(distance[1] == dis && count == false) return INVALID_VEHICLE_ID;
return vehicleid;
}
forward VehicleRadioTimer(link[]);
public VehicleRadioTimer(link[])
{
new Float:pos[3];
for(new i; i<MAX_PLAYERS; i++)
{
if(RadioActive[0] == 0)
{
new v = GetClosestVehicleEx(i);
if(v != -1)
{
GetVehiclePos(v,VRadio[v][VRposX],VRadio[v][VRposY],VRadio[v][VRposZ]);
PlayAudioStreamForPlayer(i, link, VRadio[v][VRposX],VRadio[v][VRposY],VRadio[v][VRposZ], RADIO_DISTANCE);
RadioActive[0] = 1;
RadioActive[1] = v;
}
}
else
{
new v = RadioActive[1];
GetVehiclePos(v,pos[0],pos[1],pos[2]);
new Float:dis = GetPlayerDistanceFromPoint(i, pos[0],pos[1],pos[2]);
if(dis > RADIO_DISTANCE)
{
StopAudioStreamForPlayer(i);
RadioActive[0] = 0;
RadioActive[1] = -1;
}
}
}
return 1;
}
Ez külön inc-be van