public OnPlayerSpawn(playerid) { SetPlayerPos(playerid,0.0,0.0,3.0); //The position where the player will stand when u give him the dialog, (not important) ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Spawns:","1. spawn 1\r\n2. spawn 2\r\n3. spawn 3","select", "cancel"); //Show the player the dialog return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //What must happen when the player choose a item from the dialog { switch(dialogid) // Lookup the dialogid { case 1: { if(!response) { SendClientMessage(playerid, 0xFF0000FF, "You cancelled."); //when he types cancel (copied this part from wiki IMO I would do it on a different way...) return 1; // We processed it } switch(listitem) // This is far more efficient than using an if-elseif-else structure { case 0: // Listitems start with 0, not 1 { SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 1 return 1; } case 1: { SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 2 return 1; } case 2: { SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 3 return 1; } // Add the rest of your listitems for dialog 1 here } } // Add the rest of your dialogs here } return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.). }
Код:
public OnPlayerSpawn(playerid) { SetPlayerPos(playerid,0.0,0.0,3.0); //The position where the player will stand when u give him the dialog, (not important) ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Spawns:","1. spawn 1\r\n2. spawn 2\r\n3. spawn 3","select", "cancel"); //Show the player the dialog return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //What must happen when the player choose a item from the dialog { switch(dialogid) // Lookup the dialogid { case 1: { if(!response) { SendClientMessage(playerid, 0xFF0000FF, "You cancelled."); //when he types cancel (copied this part from wiki IMO I would do it on a different way...) return 1; // We processed it } switch(listitem) // This is far more efficient than using an if-elseif-else structure { case 0: // Listitems start with 0, not 1 { SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 1 return 1; } case 1: { SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 2 return 1; } case 2: { SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 3 return 1; } // Add the rest of your listitems for dialog 1 here } } // Add the rest of your dialogs here } return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.). } MOre information about the callbacks and functions: https://sampwiki.blast.hk/wiki/OnDialogResponse https://sampwiki.blast.hk/wiki/OnPlayerSpawn https://sampwiki.blast.hk/wiki/SetPlayerPos |