Spam Message
#1

The code is supposed to check if player has these weapons, but instead it spams the message.. any help?

Код:
public AntiWeapon(playerid)
{
new string[256];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new weapon = GetPlayerWeapon(playerid);
if(weapon == 1 || 9 || 16 || 17 || 18 || 21 || 22 || 26 || 28 || 32 || 35 || 36 || 37 || 38 || 39 || 40 || 43 || 44 || 45)
{
Ban(playerid);
format(string, sizeof(string), "Auto-Ban System Banned %s, Reason: Weapon Hacks", sendername);
SendClientMessageToAll(COLOR_RED, string);
}
return 1;
}
Reply
#2

Код:
if(weapon == 1 || 9 || 16 || 17 || 18 || 21 || 22 || 26 || 28 || 32 || 35 || 36 || 37 || 38 || 39 || 40 || 43 || 44 || 45)
Use switch for this.
Reply
#3

Quote:
Originally Posted by GTAguillaume
Код:
if(weapon == 1 || 9 || 16 || 17 || 18 || 21 || 22 || 26 || 28 || 32 || 35 || 36 || 37 || 38 || 39 || 40 || 43 || 44 || 45)
Use switch for this.
Код:
{
switch (weapon)
{
case 1:
{
...................
You mean this?
Reply
#4

Yes, use a switch.
remember it starts with 0. Not 1.
Код:
case:0
case:1 ect.
Reply
#5

pawn Код:
public AntiWeapon(playerid)
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new weapon = GetPlayerWeapon(playerid);
    switch(weapon)
    {
        case 1, 9, 16, 17, 18, 21, 22, 26, 28, 32, 35:
        {
            Ban(playerid);
            format(string, sizeof(string), "Auto-Ban System Banned %s, Reason: Weapon Hacks", sendername);
            SendClientMessageToAll(COLOR_RED, string);
        }
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by MadeMan
pawn Код:
public AntiWeapon(playerid)
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new weapon = GetPlayerWeapon(playerid);
    switch(weapon)
    {
        case 1, 9, 16, 17, 18, 21, 22, 26, 28, 32, 35:
        {
            Ban(playerid);
            format(string, sizeof(string), "Auto-Ban System Banned %s, Reason: Weapon Hacks", sendername);
            SendClientMessageToAll(COLOR_RED, string);
        }
    }
    return 1;
}
Thanks man!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)