PDA

View Full Version : [HELP]if(GetPlayerWeapon(playerid) == (1 or 2 or 3 or 3 or 4....)


ic3cr3am
13/10/2013, 12:24 PM
Code i tried.
if(GetPlayerWeapon(playerid) == 4, 9, 10, 11, 12, 13, 14, 15, 17, 34, 35, 36, 37, 38, 43, 44, 45)
{
new weaponname[32];
GetWeaponName((GetPlayerWeapon(playerid)),weaponna me,sizeof(weaponname));
SendClientMessage(playerid, 0xFF0000AA, "<|| {FFCC00}You have been {FF6600}Banned {FFCC00}from the server, {00FF00}REASON: {FFFF00}Weapon Hacking. {FF0000}||>");
new pname[MAX_PLAYER_NAME], string[124 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
BanEx(playerid, "Weapon Hacking [%s]", weaponname);
format(string, sizeof(string), "{FF0000}<|| {00CC00}%s {FFCC00}has been {FF6600}Banned {FFCC00}from the server, {00FF00}REASON: {FFFF00}Weapon Hacking. {FF0000}||>", pname);
SendClientMessageToAll(0xFF0000AA, string);
}

i don't know how to explain what i'm, tring to do, lol, but.... i want to see if player has any of the weapons in if(GetPlayerWeapon(playerid) == part.

help me = rep+

xVIP3Rx
13/10/2013, 12:27 PM
if(GetPlayerWeapon(playerid) == 4, 9, 10, 11, 12, 13, 14, 15, 17, 34, 35, 36, 37, 38, 43, 44, 45)

That can't be
You should add GetPlayerWeapon(playerid) == Number for every number, OR, make a switch (http://wiki.sa-mp.com/wiki/Control_Structures#switch_2)and put all the numbers in one case.

Konstantinos
13/10/2013, 12:27 PM
switch(GetPlayerWeapon(playerid))
{
case 4, 9 .. 15, 17, 34 .. 38, 43 .. 45:
{
new weaponname[32];
GetWeaponName((GetPlayerWeapon(playerid)),weaponna me,sizeof(weaponname));
SendClientMessage(playerid, 0xFF0000AA, "<|| {FFCC00}You have been {FF6600}Banned {FFCC00}from the server, {00FF00}REASON: {FFFF00}Weapon Hacking. {FF0000}||>");
new pname[MAX_PLAYER_NAME], string[124 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
BanEx(playerid, "Weapon Hacking [%s]", weaponname);
format(string, sizeof(string), "{FF0000}<|| {00CC00}%s {FFCC00}has been {FF6600}Banned {FFCC00}from the server, {00FF00}REASON: {FFFF00}Weapon Hacking. {FF0000}||>", pname);
SendClientMessageToAll(0xFF0000AA, string);
}
}

ic3cr3am
13/10/2013, 12:42 PM
Thanks!