SA-MP Forums Archive
/radio command help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /radio command help (/showthread.php?tid=431574)



/radio command help - MichaelWharton101 - 19.04.2013

How would I make this command ONLY play for people in the car? I do not want anyone to hear this unless they are in the car....

Код:
CMD:radio(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /radio [url]");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You need be on car when you want listen radio");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be driving a car to use the radio.");
    format(string, sizeof(string), "%s switches the song on their radio to song '%s'.", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    format(string,sizeof(string),"http://americanrp.x10.mx/music/%s",params);
    foreach(Player, i)
    {
        PlayAudioStreamForPlayer(i, string);
    }
    return 1;
}



Re: /radio command help - Scrillex - 19.04.2013

Here the first one

Second Here


Re: /radio command help - Giroud12 - 19.04.2013

pawn Код:
CMD:r(playerid,params[])
{
    #pragma unused params
    if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [text] to talk in team radio");
    new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
    new string[128];
    format(string, sizeof(string), "[R][Team Radio] %s: %s", Name, params[0]);
    printf("%s", string);

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
    }
    return 1;
}



Re: /radio command help - MichaelWharton101 - 19.04.2013

Hmm... I still need help... I did not understand you two


Re: /radio command help - Jefff - 19.04.2013

pawn Код:
new DriverVehID = GetPlayerVehicleID(playerid);
    foreach(Player, i)
    {
        if(DriverVehID == GetPlayerVehicleID(i))
            PlayAudioStreamForPlayer(i, string);
    }

    or

    new DriverVehID = GetPlayerVehicleID(playerid);
    foreach(Player, i)
    {
        if(IsPlayerInVehicle(i, DriverVehID))
            PlayAudioStreamForPlayer(i, string);
    }



Re: /radio command help - Giroud12 - 19.04.2013

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
 PlayAudioStreamForPlayer(playerid, "linkofyoursong");



Re: /radio command help - MichaelWharton101 - 19.04.2013

Still confused haha


Re: /radio command help - Scrillex - 19.04.2013

Okay that first one was a fail link...

if(GetPlayerState(playerid)== PLAYER_STATE_DRIVER)
By cheking it..


Re: /radio command help - Giroud12 - 19.04.2013

Add in ur script:
pawn Код:
if(IsPlayerInAnyVehicle(playerid))
 PlayAudioStreamForPlayer(playerid, "linkofyoursong");
Correct me if its a mistake