SA-MP Forums Archive
public OnDialogResponse - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: public OnDialogResponse (/showthread.php?tid=204527)



public OnDialogResponse - [SU]Fnugski - 29.12.2010

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


Re: public OnDialogResponse - Sinner - 29.12.2010

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.).
}



Re: public OnDialogResponse - DVDK - 29.12.2010

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.


Re: public OnDialogResponse - Jochemd - 29.12.2010

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


Re: public OnDialogResponse - [SU]Fnugski - 29.12.2010

meh a frind helped me making it a easier way


Re: public OnDialogResponse - Jochemd - 29.12.2010

Share the way with us.


Re: public OnDialogResponse - Sinner - 30.12.2010

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)