Jochemd

Example for GetRadioStationsString()

Feb 11th, 2013
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.32 KB | None | 0 0
  1. public OnPlayerCommandText(playerid, cmdtext[])
  2. {
  3.     if(!strcmp(playerid,"/changestation",true))
  4.     {
  5.         if(IsPlayerInAnyVehicle(playerid)) // Check if the player is in a vehicle, so he cannot change it onfoot.
  6.         {
  7.             ShowPlayerDialog(playerid,12349,DIALOG_STYLE_LIST,"Radio Stations",GetRadioStationsString(),"Choose","Close"); // Shows a dialog with all radio stations (including radio off).
  8.             return 1;
  9.         }
  10.         else return SendClientMessage(playerid,COLOR_RED,"Error: You are not in a vehicle.");
  11.     }
  12.     return 0;
  13. }
  14.  
  15. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  16. {
  17.     if(dialogid == 12349) // Our radio stations dialog
  18.     {
  19.         if(response)
  20.         {
  21.             SetRadioStation(GetPlayerVehicleID(playerid), listitem); // listitem is equal to the radio IDs, so we should use listitem here and set the radio station of the player's vehicle to that ID.
  22.             if(listitem) // We'll send a seperate message for ID 0 (radio off)
  23.             {
  24.                 new string[45 + NAME_SIZE]; // 45 for the default text + NAME_SIZE for the radio station name.
  25.                 format(string,sizeof(string),"You have changed your radio station: {FFFF00}%s",GetStationName(listitem));
  26.                 SendClientMessage(playerid,COLOR_WHITE,string);
  27.                 return 1;
  28.             }
  29.             else return SendClientMessage(playerid, COLOR_WHITE, "You have turned your radio off.");
  30.         }
  31.     }
  32.     return 1;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment