SA-MP Forums Archive
Spam Message - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spam Message (/showthread.php?tid=145124)



Spam Message - Antonio [G-RP] - 01.05.2010

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;
}



Re: Spam Message - GTAguillaume - 01.05.2010

Код:
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.


Re: Spam Message - Antonio [G-RP] - 01.05.2010

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?


Re: Spam Message - -Rebel Son- - 01.05.2010

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



Re: Spam Message - MadeMan - 01.05.2010

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;
}



Re: Spam Message - Antonio [G-RP] - 02.05.2010

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!