Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #define MAX_RADIOS 50
- #define COLOR_GREY 0x33aa33FF
- enum RADIOX
- {
- rObject,
- rURL[128]
- }
- new Radio[MAX_RADIOS][RADIOX];
- new Radio_Index;
- stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
- {
- new Float:a;
- GetPlayerPos(playerid, x, y, a);
- GetPlayerFacingAngle(playerid, a);
- if (GetPlayerVehicleID(playerid))
- {
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- }
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- }
- public OnPlayerUpdate(playerid)
- {
- new Float:X,Float:Y,Float:Z,Float:dist;
- for(new i = 0;i<MAX_RADIOS;i++)
- {
- if(Radio[i][rObject] == INVALID_OBJECT_ID) {}
- else
- {
- GetObjectPos(Radio[i][rObject],X,Y,Z);
- dist = GetPlayerDistanceFromPoint(playerid,X,Y,Z);
- if(dist <= 30)
- {
- PlayAudioStreamForPlayer(playerid,Radio[i][rURL]);
- }
- else
- {
- StopAudioStreamForPlayer(playerid);
- }
- }
- }
- }
- CMD:radio(playerid,params[])
- {
- if(!strlen(params))
- {
- return SendClientMessage(playerid,COLOR_GREY,"USAGE: /radio [url]");
- }
- new Float:X,Float:Y,Float:Z,Float:Xi,Float:Yi;
- for(new i = 0;i<MAX_RADIOS;i++)
- {
- if(Radio[i][rObject] == INVALID_OBJECT_ID) {}
- else
- {
- GetObjectPos(Radio[i][rObject],X,Y,Z);
- if(IsPlayerInRangeOfPoint(playerid,X,Y,Z,30.0))
- {
- return SendClientMessage(playerid,COLOR_GREY,"Too close to another radio.");
- }
- }
- }
- GetPlayerPos(playerid,Xi,Yi,Z);
- GetXYInFrontOfPlayer(playerid,X,Y,3);
- Radio[Radio_Index][rObject] = CreateObject(3031,X,Y,Z,0,0,0);
- strmid(Radio[Radio_Index][rURL],params,0,strlen(params));
- Radio_Index++;
- return 1;
- }
- CMD:remove(playerid)
- {
- new Float:X,Float:Y,Float:Z;
- for(new i = 0;i<MAX_RADIOS;i++)
- {
- if(Radio[i][rObject] == INVALID_OBJECT_ID) {}
- else
- {
- GetObjectPos(Radio[i][rObject],X,Y,Z);
- if(IsPlayerInRangeOfPoint(playerid,X,Y,Z,30.0))
- {
- DestroyObject(Radio[i][rObject]);
- strdel(Radio[i][rURL],0,strlen(Radio[i][rURL]));
- Radio_Index--;
- return SendClientMessage(playerid,COLOR_GREY,"Radio removed");
- }
- }
- }
- return SendClientMessage(playerid,COLOR_GREY,"No radios in range.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement