SA-MP Forums Archive
Please help with dialog - 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: Please help with dialog (/showthread.php?tid=229206)



Please help with dialog - Markx - 21.02.2011

Okay i made this:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/vehcontrol", cmdtext, true, 10) == 0)
    {
       
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Vehicle Control Menu {FF0000}0.3c", "{0000FF}Doors \n{0000FF}Bonnet \n{0000FF}Boot \n{0000FF}Engine \n{0000FF}Alarm \n{0000FF}Objectives \n{0000FF}Neons", "Purchase", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
        {
        switch(0)
            {
            case 1:
                {
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{0000FF}Doors", "Open Doors \nClose Doors", "Chose", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "{0000FF}Bonnet", "Open Bonnet \nClose Bonnet", "Chose", "Cancel");
                    }
                    case 2:
                    {
                        ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "{0000FF}Boot", "Open Boot \nClose Boot", "Chose", "Cancel");
                    }
                    case 3:
                    {
                        ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "{0000FF}Engine", "Turn Off Engine \nTurn On Engine", "Purchase", "Cancel");
                    }
                    case 4:
                    {
                         ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "{0000FF}Alarm", "Turn On Alarm \nTurn Off Alarm", "Purchase", "Cancel");
                    }
                    case 5:
                    {
                         ShowPlayerDialog(playerid, 6, DIALOG_STYLE_LIST, "{0000FF}Objectives", "Turn On Objectives \n Turn Off Objectives", "Purchase", "Cancel");
                    }
                    case 6:
                    {
                         ShowPlayerDialog(playerid, 7, DIALOG_STYLE_LIST, "{0000FF}Neon Lights", "Red Neon \nBlue Neon \nYellow Neon \nGreen Neon \nWhite Neon \nPink Neon", "Purchase", "Cancel");
                    }
                }
            }
        }
    }
    return 1;
}
How can i made a responce to the case's, i mean the Door, Bonnet, Boot, Alarm, Objectives, Neon dialog?

Please help.


Re: Please help with dialog - (SF)Noobanatior - 21.02.2011

where you have switch(0) change that to switch(dialogid) and then give every dialog a unique id

you alrealy have two with the id 1 btw


Re: Please help with dialog - Markx - 21.02.2011

can you give me the whole code, with the responce of those case's please?


Re: Please help with dialog - (SF)Noobanatior - 21.02.2011

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/vehcontrol", cmdtext, true, 10) == 0)
    {

        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Vehicle Control Menu {FF0000}0.3c", "{0000FF}Doors \n{0000FF}Bonnet \n{0000FF}Boot \n{0000FF}Engine \n{0000FF}Alarm \n{0000FF}Objectives \n{0000FF}Neons", "Purchase", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response){
        switch(dialogid){
            case 0:{
                switch(listitem) {
                    case 0:ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{0000FF}Doors", "Open Doors \nClose Doors", "Chose", "Cancel");
                    case 1:ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "{0000FF}Bonnet", "Open Bonnet \nClose Bonnet", "Chose", "Cancel");
                    case 2:ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "{0000FF}Boot", "Open Boot \nClose Boot", "Chose", "Cancel");
                    case 3:ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "{0000FF}Engine", "Turn Off Engine \nTurn On Engine", "Purchase", "Cancel");
                    case 4:ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "{0000FF}Alarm", "Turn On Alarm \nTurn Off Alarm", "Purchase", "Cancel");
                    case 5:ShowPlayerDialog(playerid, 6, DIALOG_STYLE_LIST, "{0000FF}Objectives", "Turn On Objectives \n Turn Off Objectives", "Purchase", "Cancel");
                    case 6:ShowPlayerDialog(playerid, 7, DIALOG_STYLE_LIST, "{0000FF}Neon Lights", "Red Neon \nBlue Neon \nYellow Neon \nGreen Neon \nWhite Neon \nPink Neon", "Purchase", "Cancel");
                 }
            }
            case 1:{//opendoors
            }
            case 2:{//Bonnet
            }
            case 3:{ //boot
            }
            case 4:{//engine
            }
            case 5:{//alarm
            }
            case 6:{ //objectives
            }
            case 7:{//Neon

        }
    }
    return 1;
}



Re: Please help with dialog - iggy1 - 21.02.2011

I wont give the whole code you can do that yourself, here i made a start for you try and see what is going on its easy. This is how it should be.
pawn Код:
#include <a_samp>

#define VC_MAIN             (1)
#define DOOR_DIALOG         (2)//i use defines for all of my dialogs. (much easier to see whats going on)

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/vehcontrol", cmdtext, true, 10) == 0)
    {

        ShowPlayerDialog(playerid, VC_MAIN, DIALOG_STYLE_LIST, "Vehicle Control Menu {FF0000}0.3c", "{0000FF}Doors \n{0000FF}Bonnet \n{0000FF}Boot \n{0000FF}Engine \n{0000FF}Alarm \n{0000FF}Objectives \n{0000FF}Neons", "Purchase", "Cancel");
        return 1;
    }
    return 0;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case VC_MAIN:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0://doors
                    {
                        ShowPlayerDialog(playerid, DOOR_DIALOG, DIALOG_STYLE_LIST, "{0000FF}Doors", "Open Doors \nClose Doors", "Chose", "Cancel");
                    }
                    case 1://bonnet
                    {
                        //ShowPlayerDialog(playerid, BONNET_DIALOG, ...
                    }
                }
            }
            else SendClientMessage(playerid, 0xFF0000AA, "Closed");
        }
        case DOOR_DIALOG:
        {
            if(response)
            {
                switch(listitem)//this is the answer to your question
                {
                    case 0://open doors is the first item in your list dialog (cases start from zero in this instance)
                    {
                        SetVehicleParamsEx(GetPlayerVehicleID(playerid), -1, -1, -1, true, -1, -1, -1);
                    }
                    case 1://close doors item
                    {
                        SetVehicleParamsEx(GetPlayerVehicleID(playerid), -1, -1, -1, false, -1, -1, -1);
                    }
                }
            }
            else ShowPlayerDialog(playerid, VC_MAIN, DIALOG_STYLE_LIST, "Vehicle Control Menu {FF0000}0.3c", "{0000FF}Doors \n{0000FF}Bonnet \n{0000FF}Boot \n{0000FF}Engine \n{0000FF}Alarm \n{0000FF}Objectives \n{0000FF}Neons", "Purchase", "Cancel");
        }
    }
    return 1;
}



Re: Please help with dialog - Markx - 21.02.2011

Thanks! thats what i wanted ;P


Re: Please help with dialog - Markx - 21.02.2011

I got Errors:

pawn Код:
C:\Users\Marko\Desktop\Vehicle0.3c.pwn(116) : error 014: invalid statement; not in switch
C:\Users\Marko\Desktop\Vehicle0.3c.pwn(116) : warning 215: expression has no effect
C:\Users\Marko\Desktop\Vehicle0.3c.pwn(116) : error 001: expected token: ";", but found ":"
C:\Users\Marko\Desktop\Vehicle0.3c.pwn(116) : error 029: invalid expression, assumed zero
C:\Users\Marko\Desktop\Vehicle0.3c.pwn(116) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
        {
        switch(0)
            {
            case VEH_DIALOG:
                {
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{0000FF}Doors", "Open Doors \nClose Doors", "Chose", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "{0000FF}Bonnet", "Open Bonnet \nClose Bonnet", "Chose", "Cancel");
                    }
                    case 2:
                    {
                        ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "{0000FF}Boot", "Open Boot \nClose Boot", "Chose", "Cancel");
                    }
                    case 3:
                    {
                        ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "{0000FF}Engine", "Turn Off Engine \nTurn On Engine", "Purchase", "Cancel");
                    }
                    case 4:
                    {
                         ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "{0000FF}Alarm", "Turn On Alarm \nTurn Off Alarm", "Purchase", "Cancel");
                    }
                    case 5:
                    {
                         ShowPlayerDialog(playerid, 6, DIALOG_STYLE_LIST, "{0000FF}Objectives", "Turn On Objectives \n Turn Off Objectives", "Purchase", "Cancel");
                    }
                    case 6:
                    {
                         ShowPlayerDialog(playerid, 7, DIALOG_STYLE_LIST, "{0000FF}Lights", "Lights On \nLights Off", "Purchase", "Cancel");
                    }
                    case 7:
                    {
                         ShowPlayerDialog(playerid, 8, DIALOG_STYLE_LIST, "{0000FF}Neon Lights", "Red Neon \nBlue Neon \nYellow Neon \nGreen Neon \nWhite Neon \nPink Neon", "Purchase", "Cancel");
                    }
                }
            }
        }
        case DOOR_DIALOG: //errors here
            {
            if(response)
                {
                switch(listitem)
                    {
                        case 0: //open doors
                        {
                            new vid = GetPlayerVehicleID(playerid);
                            if(vid != INVALID_VEHICLE_ID) {
                            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                            SetVehicleParamsEx(vid,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
                        }
                        case 1: //close doors
                        {
                            if(strcmp(cmd, "/closedoors",true) == 0) {
                            new vid = GetPlayerVehicleID(playerid);
                            if(vid != INVALID_VEHICLE_ID) {
                            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                            SetVehicleParamsEx(vid,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
                        }
                    }
                }
                else SendClientMessage(playerid, 0xff0000AA, "SERVER: Doors are closed.");
            }
        }
        return 1;
    }
By the way, how can i make it like "Dors are alredy Closed!"


Re: Please help with dialog - iggy1 - 21.02.2011

Look at the code i posted/others posted and re-write your code in that style. BTW switch(0) does nothing, the case will always be zero. Only cases can come after switches.


Re: Please help with dialog - Markx - 21.02.2011

so i have to switch(1)??

Im sorry if im annoying


Re: Please help with dialog - Duck - 21.02.2011

if is your friend,
if(strcmp(cmd, "/closedoors",true) == 0)
then return 1
Your doors script here,
Then put
else return 0