enum
{
DIALOG_UNUSED,
DIALOG_LOGIN,
DIALOG_REGISTER,
DIALOG_WEAPONS
};
CMD:build(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2795.5701,2793.7720,17.6763))
{
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Knife\nBaseball Bat\nAk-47\nMP5\nGrenade\nSniper", "Build", "Cancel");
}
return 1;
}
if(dialogid == DIALOG_WEAPONS)
{
switch(listitem)
{
case 0:
{
InventoryWeapon[playerid][Knife]++;
SendClientMessage(playerid,-1,"Knife Given!");
}
case 1:
{
InventoryWeapon[playerid][BaseballBat]++;
}
case 2:
{
InventoryWeapon[playerid][Ak47]++;
}
case 3:
{
InventoryWeapon[playerid][MP5]++;
}
case 4:
{
InventoryWeapon[playerid][Grenade]++;
}
case 5:
{
InventoryWeapon[playerid][Sniper]++;
}
}
#define DIALOG_WEAPON 1
//or something like that.
|
Use
PHP код:
|
|
Wary, use enums for that, it'll auto increace numbers.
akib, you only change InventoryWeapon value, but you didn't use anywhere GivePlayerWeapon, to give weapon for player. |
if(dialogid == DIALOG_WEAPONS)
{
switch(listitem)
{
case 0:
{
InventoryWeapon[playerid][Knife]++;
SendClientMessage(playerid,-1,"Knife Given!");
}
case 1:
{
InventoryWeapon[playerid][BaseballBat]++;
}
case 2:
{
InventoryWeapon[playerid][Ak47]++;
}
case 3:
{
InventoryWeapon[playerid][MP5]++;
}
case 4:
{
InventoryWeapon[playerid][Grenade]++;
}
case 5:
{
InventoryWeapon[playerid][Sniper]++;
}
}
#define DIALOG_UNUSED 0 #define DIALOG_LOGIN 1 #define DIALOG_REGISTER 2 #define DIALOG_WEAPONS 3
CMD:build(playerid)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2795.5701,2793.7720,17.6763)) return SendClientMessage(playerid, -1, "You Cannot Use This CMD While You Are Not In Range !");
new str[2500];
format(str, sizeof str, "Knife\nBaseball Bat\nAk-47\nMP5\nGrenade\nSniper");
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", str, "Build", "cancel");
return 1;
}
|
Remove Params Cause You're not using it, And instead of wasting Your time on enums, Just Use defines
P.S: in enums the ID Will be generated Randomly So It can Cause a bug :P (it can Generate Same IDs For 2 Dialogs) Код:
#define DIALOG_UNUSED 0 #define DIALOG_LOGIN 1 #define DIALOG_REGISTER 2 #define DIALOG_WEAPONS 3 Код:
CMD:build(playerid)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2795.5701,2793.7720,17.6763)) return SendClientMessage(playerid, -1, "You Cannot Use This CMD While You Are Not In Range !");
new str[2500];
format(str, sizeof str, "Knife\nBaseball Bat\nAk-47\nMP5\nGrenade\nSniper");
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", str, "Build", "cancel");
return 1;
}
|
|
Lol this dude thinks saying weapon given will actually give user weapon.
You have to give the weapon using GivePlayerWeapon. |