get playername - 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: get playername (
/showthread.php?tid=323899)
get playername -
[LHT]Bally - 07.03.2012
how to use get player name in here so all players know that someone listened to radio once they clicked the radio station
pawn Код:
#include <a_samp>
#include <zcmd>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Radio ");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" gtfo");
print("----------------------------------\n");
}
#endif
/////////////////commands////////////////////////
COMMAND:radio(playerid, params[])
{
ShowPlayerDialog(playerid,9780,DIALOG_STYLE_LIST,"Truckers Life Radio","1. Capital Fm Manchester\r\n2. Key 103\r\n3. Radio 1","Play", "Cancel");
return 1;
}
COMMAND:stopradio(playerid, params[])
{
StopAudioStreamForPlayer(playerid);//This is the function we need to stop the audio from streaming the music.
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 9780: //Remember the ID we changed in ShowPlayerDialog? (90) That's how the DialogResponse will get to know which Dialog it's going to use.
{
if(!response)// This one is used for option 2 which we changed to (Cancel).
{
SendClientMessage(playerid, 0xff000098, "You canceled the dialog.");//This one sends a message when you close the dialog using (Cancel).
return 1;
}
switch(listitem)//This one will list the items.
{
case 0://Case 0 is basically the first line we made in ShowPlayerDialog (1.)
{
PlayAudioStreamForPlayer(playerid, "http://media-ice.musicradio.com/CapitalManchesterMP3Low");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0xFF0000FF, "Type /stopradio to stop audio streaming."); //This line sends a message to the listener that he can stop it using /stopradio.
}
case 1://Case 1 is the second line we put in ShowPlayerDialog (\r\n2.)
{
PlayAudioStreamForPlayer(playerid, "http://stream.radioactivity.fm:8002/");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0xFF0000FF, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
}
case 2://Case 2 is the third line we put in ShowPlayerDialog(\r\n3.)
{
PlayAudioStreamForPlayer(playerid, "http://bbc.co.uk/radio/listen/live/r1.asx");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0xFF0000FF, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
}
//You can continue cases here but make sure you make a new line in the ShowPlayerDialog on /myradio command \r\n4. 4th \r\n5. 5th channel etc..
}
}
}
return 1;
}
Re: get playername -
Basicz - 07.03.2012
At OnPlayerDialogResponse :
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 9780: //Remember the ID we changed in ShowPlayerDialog? (90) That's how the DialogResponse will get to know which Dialog it's going to use.
{
if(!response)// This one is used for option 2 which we changed to (Cancel).
{
SendClientMessage(playerid, 0xff000098, "You canceled the dialog.");//This one sends a message when you close the dialog using (Cancel).
return 1;
}
new
pName[ 24 ]; GetPlayerName( playerid, pName, 24 ); new string[ 128 ];
format( string, 128, "%s[%d] has listened to the radio! [ /radio ]", pName, playerid );
SendClientMessageToAll( -1, string );
switch(listitem)//This one will list the items.
{
case 0://Case 0 is basically the first line we made in ShowPlayerDialog (1.)
{
PlayAudioStreamForPlayer(playerid, "http://media-ice.musicradio.com/CapitalManchesterMP3Low");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0xFF0000FF, "Type /stopradio to stop audio streaming."); //This line sends a message to the listener that he can stop it using /stopradio.
}
case 1://Case 1 is the second line we put in ShowPlayerDialog (\r\n2.)
{
PlayAudioStreamForPlayer(playerid, "http://stream.radioactivity.fm:8002/");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0xFF0000FF, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
}
case 2://Case 2 is the third line we put in ShowPlayerDialog(\r\n3.)
{
PlayAudioStreamForPlayer(playerid, "http://bbc.co.uk/radio/listen/live/r1.asx");//This function will play our desired radio. So we have to put the url between its brackets.
SendClientMessage(playerid, 0xFF0000FF, "Type /stopradio to stop audio streaming.");//This line sends a message to the listener that he can stop it using /stopradio.
}
//You can continue cases here but make sure you make a new line in the ShowPlayerDialog on /myradio command \r\n4. 4th \r\n5. 5th channel etc..
}
}
}
return 1;
}
Re: get playername -
[LHT]Bally - 07.03.2012
thanks alot man
+rep