dialoginput style question
#1

hi,

damn maybe im just too tired now xD but i cant fugure this out.
I want that itgives me the first weapon that is listed on the list if i enter 1 into the dialog.
The 2nd weapon if i enter 2 and so on.
But it just does not work. Nothing happens.

pawn Код:
new Weaponsdialog = 1;

public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{

    new Weaponsdialogue[710] = "{CD5555}Katana - {CDAF95}15800$\n{CD5555}Chainsaw - {CDAF95}2500$\n...


    foreach (Player, i)
   {
    if(IsPlayerInRangeOfPoint(i,2,311.2411,-165.3235,999.6010))

    {
ShowPlayerDialog(i, Weaponsdialog, DIALOG_STYLE_INPUT, "
{CD5555}Weapon                 {CDAF95}Price",Weaponsdialogue,"Buy", "Cancel");

        }
    }
return 1;
}


//OnDialogResponse

    if(dialogid  == Weaponsdialog)
{
if(response)
{

if(strcmp("
1", inputtext, true))
{

GivePlayerWeapon(playerid,8,0);

}
else if(strcmp("
2", inputtext, true))
{

GivePlayerWeapon(playerid,9,0);

}

// and so on...
regards.
Reply
#2

You could just use a list dialog instead of a input dialog... Also you're supposed to check if strcmp(...)==0
Reply
#3

thx for ur answer but if i do it like this it also does not work:

pawn Код:
if(strcmp("1", inputtext, true))==0
And i know about the list dialog cause im using it right now but thats why im asking
I wanna change my list doalog to input.

regards.
Reply
#4

pls can anyone take a quick look at his code
Reply
#5

cmon guys...
realy no one of all this smart samp'ers wanna help me?
Reply
#6

Strcmp is used to compare strings and '1' is a integer so you could easily do..
pawn Код:
if (MyVar == 1)
Reply
#7

could u pls explain?
i cant find anything about MyVar...

is there another way to do this?
Reply
#8

Try:

pawn Код:
[if(dialogid  == Weaponsdialog)
{
    if(response)
    {
        if(!strcmp("1", inputtext)) GivePlayerWeapon(playerid,8,0);
        else if(!strcmp("2", inputtext)) GivePlayerWeapon(playerid,9,0);
    }
}
Reply
#9

Get rid of the ugly strcmp:

pawn Код:
switch(strval(inputtext))
{
    case 1: GivePlayerWeapon(playerid, 8, 1);
    case 2: GivePlayerWeapon(playerid, 9, 1);
    default: SendClientMessage(playerid, COLOR_RED, "Invalid Input");
}
Though it has already been suggested that you should use a list for this kind of stuff. Much easier.
Reply
#10

k thx alot imma try it out


regards, wolf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)