erm... im stuck :/ please help!?
#1

Hello i have this code but then when i type /vbuy then a dialog pops up with the correct stuff but then when i click, Cars and then Elegy, it doesnt do anything, the dialog doesnt even close, anyone know whay? Heres the code...

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/vbuy", true) == 0)
    {
        ShowPlayerDialog(playerid, 1,DIALOG_STYLE_LIST,"Vehicles.","1. Cars\r\n2. Bikes\r\n3. Choppers\r\n4. Planes\r\n5. Cheap.","Continue", "Cancel");
        return 1;
    }
    return SendClientMessage(playerid, COLOR_RED, "Unknown command: Type /help or /cmds for the right commands!");
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, COLOR_RED, "You cancelled");
                return 1;
            }
           
            switch(listitem)
            {
                case 0:
                {
                    ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Cars","1. Elegy","Continue", "Cancel");
                }
            }
        }
        case 2:
        {
            if(!response)
            {
                SendClientMessage(playerid, COLOR_RED, "You cancelled!");
                return 1;
            }
            switch(listitem)
            {
                case 0:
                {
                    if(GetPlayerMoney(playerid) < 5000) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money for the elegy!");
                    GivePlayerMoney(playerid, -5000);
                    new Float:X,Float:Y,Float:Z,Float:ROT;
                    GetPlayerPos(playerid,X,Y,Z);
                    GetPlayerFacingAngle (playerid,ROT);
                    SpawnedVehicles[playerid] = CreateVehicle(562, X+4,Y,Z,ROT,-1,-1,60);
                }
            }
        }
    }
    return 1;
}
Can anyone please help me. :/ im sorry for asking for help so much, but how else am i going to learn this. Before you say, i have looked at tutorials and other posts to see if there is a solution but could not find anything :/ im sorry.

For example. I type "/vbuy" a dialog pops up with Cars etc then i click "Cars" then another dialog pops up with Elegy but then i click "Elegy" and then it spawns an elegy for X ammount of money! Thanks for trying though!

No errors but the dialog did BLINK at me so went on and off so quick literally, and that is the problem!
Reply
#2

You didn't tell the server about another possible "else" statement;

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 1:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0: ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Cars","1. Elegy","Continue", "Cancel");
                }
            }
            else SendClientMessage(playerid, COLOR_RED, "You canceled!");
        }
        case 2:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(GetPlayerMoney(playerid) < 5000) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money for the elegy!");
                        GivePlayerMoney(playerid, -5000);
                        new Float:X,Float:Y,Float:Z,Float:ROT;
                        GetPlayerPos(playerid,X,Y,Z);
                        GetPlayerFacingAngle (playerid,ROT);
                        SpawnedVehicles[playerid] = CreateVehicle(562, X+4,Y,Z,ROT,-1,-1,60);
                    }
                }
            }
            else SendClientMessage(playerid, COLOR_RED, "You canceled!");
        }
    }
    return 1;
}
That should work.
Reply
#3

Edit: Nvm, you don't need to add so many case's and swiches.
Reply
#4

@ Realcop: it should work without else statement to. The else statement is not the problem.

The real problem is you have used dialogid 1 twice. You just tell the server to use dialog id 1, so case 2: won't be called

And @ FreshDoubleX: Can you ident first, please? This is unreable :P
Reply
#5

Yea, Im not used to ident it here
I edited my post.
Reply
#6

Thankyou! I am just going to go test it and i will get back to u as soon as possible!
Reply
#7

Quote:
Originally Posted by BigAl
Посмотреть сообщение
Thankyou! I am just going to go test it and i will get back to u as soon as possible!
100% sure, but just come back here to tell it works :P
Reply
#8

This didnt work :/
Reply
#9

Give us your errors or what happened ? Dialog closed or what ?
Reply
#10

BUMP!?! NEED HELP? Please?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)