Dialog List Proglem
#1

I searched but I didn`t found anything. I`m trying to make a List and this is what I made:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/shop", true) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop Menu", "Health \nArmour \nGuns", "Select", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1)
    {
        if(response)
        {
            new message[256+1];
            if(listitem == 0)
            {
            format(message, 256, "You successfuly bought health for $500!", 0);
            SetPlayerHealth(playerid, 100);
            GivePlayerMoney(playerid, -500);
            return 1;
            }
            if(listitem == 1)
            {
              format(message, 256, "You successfuly bought armour for $1000!", 1);
              SetPlayerArmour(playerid, 100);
                GivePlayerMoney(playerid, -1000);
                return 1;
                }
            if(listitem == 2)
                {
                    format(message, 256, "You successfuly bought three guns for $2500!", 2);
                    GivePlayerWeapon(playerid, 23, 1000);
                    GivePlayerWeapon(playerid, 29, 1000);
                    GivePlayerWeapon(playerid, 31, 1000);
                GivePlayerWeapon(playerid, 34, 1000);
                GivePlayerMoney(playerid, -2500);
                    return 1;
            }
        }
    }
    return 1;
}
I have no errors, but when I type /shop ingame it opens the list. I choose Armour or Guns and it fills my Health only. I want to make everything work. Help me!
Reply
#2

Quote:
Originally Posted by BaFTa
I searched but I didn`t found anything. I`m trying to make a List and this is what I made:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/shop", true) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop Menu", "Health \nArmour \nGuns", "Select", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1)
    {
        if(response)
        {
            new message[256+1];
            if(listitem == 0)
            {
            format(message, 256, "You successfuly bought health for $500!", 0);
            SetPlayerHealth(playerid, 100);
            GivePlayerMoney(playerid, -500);
            return 1;
            }
            if(listitem == 1)
            {
              format(message, 256, "You successfuly bought armour for $1000!", 1);
              SetPlayerArmour(playerid, 100);
            GivePlayerMoney(playerid, -1000);
            return 1;
            }
            if(listitem == 2)
            {
                    format(message, 256, "You successfuly bought three guns for $2500!", 2);
                    GivePlayerWeapon(playerid, 23, 1000);
                    GivePlayerWeapon(playerid, 29, 1000);
                    GivePlayerWeapon(playerid, 31, 1000);
                GivePlayerWeapon(playerid, 34, 1000);
                GivePlayerMoney(playerid, -2500);
                return 1;
            }
        }
    }
    return 1;
}
I have no errors, but when I type /shop ingame it opens the list. I choose Armour or Guns and it fills my Health only. I want to make everything work. Help me!
use else if function
Reply
#3

I tryed but it doesn`t work too. I might be wrong somewhere. Here`s the code now
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/shop", true) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop Menu", "Health \nArmour \nGuns", "Select", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1)
    {
        if(response)
        {
            new message[256+1];
            if(listitem == 0)
            {
            format(message, 256, "You successfuly bought health for $500!", 0);
            SetPlayerHealth(playerid, 100);
            GivePlayerMoney(playerid, -500);
            return 1;
            }
            else if(listitem == 1)
            {
              format(message, 256, "You successfuly bought armour for $1000!", 1);
              SetPlayerArmour(playerid, 100);
                GivePlayerMoney(playerid, -1000);
                return 1;
                }
                else if(listitem == 2)
                {
                    format(message, 256, "You successfuly bought three guns for $2500!", 2);
                    GivePlayerWeapon(playerid, 23, 1000);
                    GivePlayerWeapon(playerid, 29, 1000);
                    GivePlayerWeapon(playerid, 31, 1000);
                GivePlayerWeapon(playerid, 34, 1000);
                GivePlayerMoney(playerid, -2500);
                    return 1;
            }
        }
    }
    return 1;
}
Reply
#4

why you have new message[256+1];?? it should be new message[256];??
Reply
#5

Quote:
Originally Posted by whitedragon
why you have new message[256+1];?? it should be new message[256];??
It should be lower, that string is way higher then it have to, and that would cause lag if you just do that with all of your strings.
Reply
#6

And again it doesn`t work...Can someone write the whole thing again for me
Reply
#7

Here you go:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/shop", true) == 0)
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop Menu", "Health \nArmour \nGuns", "Select", "Cancel");
return 1;
}
return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1)
{
if(response)
{
new message[256];
if(listitem == 0)
{
format(message, 256, "You successfuly bought health for $500!", 0);
SetPlayerHealth(playerid, 100);
 GivePlayerMoney(playerid, -500);
 
 }
else if(listitem == 1)
{
  format(message, 256, "You successfuly bought armour for $1000!", 1);
  SetPlayerArmour(playerid, 100);
    GivePlayerMoney(playerid, -1000);
    
    }
else if(listitem == 2)
    {
format(message, 256, "You successfuly bought three guns for $2500!", 2);
  GivePlayerWeapon(playerid, 23, 1000);
  GivePlayerWeapon(playerid, 29, 1000);
  GivePlayerWeapon(playerid, 31, 1000);
  GivePlayerWeapon(playerid, 34, 1000);
  GivePlayerMoney(playerid, -2500);
    
  }
}
}
return 1;
Reply
#8

you may use switch to
Reply
#9

Quote:
Originally Posted by whitedragon
you may use switch to
Wont really matter when it's only 3.
Reply
#10

It doesn`t work whatever I make..
DJDhan, I didn`t see any difference between mine and your script.
I want to make this because it`s stupid to type 3 commands for a simple thing..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)