VehicleRadio(vehicleid,link[],bool:turn);
#include <a_samp>#include <zcmd>CMD:playtimber(playerid) //mondjuk elindítjuk pitbulltól és keshatól a timbert..{if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,-1,\"Nem vagy a vezetõ ülésen.\");VehicleRadio(GetPlayerVehicleID(playerid),\"http://dl.ttbax.org/Hamid/Music/1392/07/Pitbull%20feat.%20Ke$ha%20-%20Timber%5B128%5D.mp3\",true); //true, azaz bekapcsoljuk. ha már be van kapcsolva, akkor csak sávot vált.return 1;}CMD:stopradio(playerid){if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,-1,\"Nem vagy a vezetõ ülésen.\");VehicleRadio(GetPlayerVehicleID(playerid),\"\",false); //false, azaz kikapcsoljukreturn 1;}
#if !defined include_vehicle_radio#define include_vehicle_radio#endif#define RADIO_DISTANCE 40.0new 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;}
#include audioincneve