public OnDialogResponse
#1

Hello forums

i got this code

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(1337)
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "You cancelled.");
                return 1; // We processed it
            }

            switch(3) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
          			GetPlayerPos(playerid, x, y, z);
                    CreateVehicle(603, x, y, z, 0, -1, -1, 60);
                    SendClientMessage(playerid, red, "You have spawned a Phoenix ID: 603");
                }
                case 1:
                {
          			GetPlayerPos(playerid, x, y, z);
                    CreateVehicle(506, x, y, z, 0, -1, -1, 60);
                }
                case 2:
                {
          			GetPlayerPos(playerid, x, y, z);
                    CreateVehicle(532, x, y, z, 0, -1, -1, 60);
                }
                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    return 1; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
and this is my Dialog

Код:
CMD:vehlist(playerid, params[])
{
	    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_LIST, "Vehicle List:", "603\tPhoenix\n503\tHotring B\n532\tCombine Harvestor\n588\tHotdog\n403\tLinerunner\n462\tFaggio\n468\tSanchez\n432\tRhino\n520\tHydra\n425\tHunter", "OK", "Exit");
	 //   SendClientMessage(playerid, red, "Veh list: Phoenix 603 Hotring B 503 Combine Harvestor 532 Hotdog 588 Linerunner 403 Faggio 462 Sanchez 468 Rhino 432 Hydra 520");
	//    SendClientMessage(playerid, red, "Hunter 425");
		return 1;
}
but it wont spawn a vehicle when i press it in the dialog

whats wrong
Reply
#2

That code is completely wrong, You should read some documentation about OnDialogResponse

Try this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1337)
    {
        if(!response)
        {
            SendClientMessage(playerid, 0xFF0000FF, "You cancelled.");
            return 1; // We processed it
        }
        if(response)
        {
            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
                    GetPlayerPos(playerid, x, y, z);
                    CreateVehicle(603, x, y, z, 0, -1, -1, 60);
                    SendClientMessage(playerid, red, "You have spawned a Phoenix ID: 603");
                }
                case 1:
                {
                    GetPlayerPos(playerid, x, y, z);
                    CreateVehicle(506, x, y, z, 0, -1, -1, 60);
                }
                case 2:
                {
                    GetPlayerPos(playerid, x, y, z);
                    CreateVehicle(532, x, y, z, 0, -1, -1, 60);
                }
            }
        }
    }
    return 1; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
Reply
#3

Do you even know what Switch() does? like Switch(1337) what is that supposed to do? that means that the case will always be 1337.
Reply
#4

You need to use 'else' after the if(!response) and not 'if(response)'
Reply
#5

meh a frind helped me making it a easier way
Reply
#6

Share the way with us.
Reply
#7

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
You need to use 'else' after the if(!response) and not 'if(response)'
if(response) works fine, it's the same as if(response == 1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)