How to make a menu and how to make it have teleport options
#10

Try this:
pawn Code:
#define TeleMenu 12345
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/telemenu", cmdtext, true) == 0)
    {
        ShowPlayerDialog(playerid,TeleMenu,DIALOG_STYLE_LIST,"Server Teleports","PlaceName1\r\nPlaceName2\r\nPlaceName3","Teleport", "Close")
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid) // Lookup the dialogid
    {
        case 12345:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "You have closed the telemenu.");
                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, x, y, z ); // Change X, Y and Z to the Co-Ords of where you want to teleport.
                      SendClientMessage(playerid,0xFFFFFFAA,"Welcome to your place! Enjoy your stay.");
                }
                case 1:
                {
                      SetPlayerPos(playerid, x, y, z ); // Change X, Y and Z to the Co-Ords of where you want to teleport.
                      SendClientMessage(playerid,0xFFFFFFAA,"Welcome to your place! Enjoy your stay.");
                }
                case 2:
                {
                      SetPlayerPos(playerid, x, y, z ); // Change X, Y and Z to the Co-Ords of where you want to teleport.
                      SendClientMessage(playerid,0xFFFFFFAA,"Welcome to your place! Enjoy your stay.");
                }
                // 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.).
}
NOTE: Be sure to replace 'x, y, z' with the X, Y and Z coordinates of your places.
NOTE: If you want to add more teleports, look where it says '// Add the rest of your listitems for dialog 1 here' and highlight, copy and paste 'case 2' and everything within the brackets. After you have pasted it under where it says '// Add the rest of your listitems for dialog 1 here' simply rename 'case 2' to 'case 3'.
NOTE: If you need any other help concerning this, just PM me in the forums.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 6 Guest(s)