SA-MP Forums Archive
I have problem with a weapon 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)
+--- Thread: I have problem with a weapon dialog (/showthread.php?tid=278462)



I have problem with a weapon dialog - saker277 - 22.08.2011

I am making a weapon dialog. When i compile it in pawno no errors show up, but when i use the /getweapon command on my server nothing happens. it doesn't say server unknown command, it just does nothing. i have looked over the code and i see no reson why it should work

here is the code:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new idx;
	cmd=strtok(cmdtext,idx);

	if(strcmp(cmd,"/getweapon",true)==1)
	{
	    ShowPlayerDialog(playerid,DIALOG_WEAPONSHOP, DIALOG_STYLE_LIST, "Weapon Shop", "9MM   $1000,\nAK47    $3000,\nM4    $3000,\nKatana    $750,\nDesert Eagle    $2000", "Buy", "Cancel");
	    return 1;
	}
	return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

	switch(dialogid)
	{
	    case DIALOG_WEAPONSHOP:
	    {
	        if(response)
	        {
				switch(listitem)
				{
				    case 0:
				    {
				        GivePlayerWeapon(playerid,22,100);
				    }
				    case 1:
				    {
				        GivePlayerWeapon(playerid, 30, 1000);
				    }
				    case 2:
				    {
				    	GivePlayerWeapon(playerid,31, 1000);
					}
					case 3:
					{
						GivePlayerWeapon(playerid,8, -1);
					}
				}
	        }
	    }
	}
	return 1;
}
if there is somethings wrong with it, can someone please tell me what it is?


Re: I have problem with a weapon dialog - Improvement™ - 22.08.2011

I removed if(response) and both brackets, Also fully indented your codes.
Perhaps give it a try now:


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd=strtok(cmdtext, idx);

    if(strcmp(cmd, "/getweapon", true) == 1)
    {
        ShowPlayerDialog(playerid, DIALOG_WEAPONSHOP, DIALOG_STYLE_LIST, "Weapon Shop", "9MM   $1000,\nAK47    $3000,\nM4    $3000,\nKatana    $750,\nDesert Eagle    $2000", "Buy", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_WEAPONSHOP:
        {
            switch(listitem)
            {
                case 0:
                {
                    GivePlayerWeapon(playerid, 22, 100);
                }
                case 1:
                {
                    GivePlayerWeapon(playerid, 30, 1000);
                }
                case 2:
                {
                    GivePlayerWeapon(playerid, 31, 1000);
                }
                case 3:
                {
                    GivePlayerWeapon(playerid, 8, -1);
                }
            }
        }
    }
    return 1;
}



Re: I have problem with a weapon dialog - PhoenixB - 22.08.2011

Should it now be like this:

pawn Код:
if(listitem == 0):
        {
            GivePlayerWeapon(playerid,22,100);
            GivePlayerMoney(playerid, -Amount..)
        }
        if(listitem == 1):
        {
            GivePlayerWeapon(playerid, 30, 1000);
            GivePlayerMoney(playerid, -Amount..)
        }
        if(listitem == 2):
        {
            GivePlayerWeapon(playerid,31, 1000);
            GivePlayerMoney(playerid, -Amount..)
        }
        if(listitem == 3):
        {
            GivePlayerWeapon(playerid,8, -1);
            GivePlayerMoney(playerid, -Amount..)
        }
    }

Because in the menu it shows the price its going to cost, just fill where Amount.. is to the amount you want taking away, Its got to be Listitem right? Give that a try etc?


Re: I have problem with a weapon dialog - Improvement™ - 22.08.2011

Quote:
Originally Posted by PhoenixB
Посмотреть сообщение
Because in the menu it shows the price its going to cost, just fill where Amount.. is to the amount you want taking away, Its got to be Listitem right? Give that a try etc?
I guess hes worrying about that nothing happends if hes executing the command, not that any ammount of cash isn't being taken.. Not to offend you, but you should read the Main Post more often :P.


Quote:
Originally Posted by saker277
Посмотреть сообщение
I am making a weapon dialog. When i compile it in pawno no errors show up, but when i use the /getweapon command on my server nothing happens. it doesn't say server unknown command, it just does nothing.



Re: I have problem with a weapon dialog - saker277 - 22.08.2011

thanks improvement. the code worked perfectly


Re: I have problem with a weapon dialog - [MWR]Blood - 22.08.2011

Quote:
Originally Posted by PhoenixB
Посмотреть сообщение
Should it now be like this:

pawn Код:
if(listitem == 0):
        {
            GivePlayerWeapon(playerid,22,100);
            GivePlayerMoney(playerid, -Amount..)
        }
        if(listitem == 1):
        {
            GivePlayerWeapon(playerid, 30, 1000);
            GivePlayerMoney(playerid, -Amount..)
        }
        if(listitem == 2):
        {
            GivePlayerWeapon(playerid,31, 1000);
            GivePlayerMoney(playerid, -Amount..)
        }
        if(listitem == 3):
        {
            GivePlayerWeapon(playerid,8, -1);
            GivePlayerMoney(playerid, -Amount..)
        }
    }

Because in the menu it shows the price its going to cost, just fill where Amount.. is to the amount you want taking away, Its got to be Listitem right? Give that a try etc?
Aswell your code is wrong.
Why are you putting the colon after listitem?
That would give an error.


Re: I have problem with a weapon dialog - Devilxz97 - 14.05.2012

DIALOG_WEAPON_SHOP = change it to DIALOG_STYLE_LIST