[HELP] Banning Players With Weapons
#1

Hey,

I Added this to my GM to reset player weapons but how would i make it if they have weapons they get banned ? heres the code:

pawn Код:
forward reset();
public reset()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
    ResetPlayerWeapons(playerid);
    }
    return 1;
}
and OnGameModeInit()
pawn Код:
SetTimer("reset",1000,true);
how would that be done ? please help XD
Reply
#2

pawn Код:
if(GetPlayerWeapon(playerid) != 0) { BanEx(playerid, "No Weapon Allowed"); }
Reply
#3

Thank you Vince
Reply
#4

Your code checks for people with weapons every second.

I added a second timer under your timer callback to check if they still have weapons after 10 seconds, if they do, it will ban them with a message:

pawn Код:
forward reset();
public reset()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        ResetPlayerWeapons(playerid);
       
        SetTimerEx("WeaponBan",10000,false,"d",playerid);
    }
    return 1;
}

forward WeaponBan(playerid);
public WeaponBan(playerid)
{
    if(GetPlayerWeapon(playerid) != 0))
    {
        new string[128], name[24];
       
        GetPlayerName(playerid,name,24);
       
        format(string,128,"%s (%d) Has Been Automatically Banned For Weapon Hacks.",name,playerid);
        SendClientMessageToAll(-1,string);

        print(string);
       
        Ban(playerid);
       
        return 1;
    }
}
Reply
#5

Код:
C:\Users\Admin\Desktop\SAMP\Fas FreeRoam\gamemodes\drift.pwn(377) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
also how can i change the fact that i get banned on connect?
Reply
#6

Код:
forward reset();
public reset()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        ResetPlayerWeapons(playerid);
        
        SetTimerEx("WeaponBan",10000,false,"d",playerid);
    }
    return 1;
}

forward WeaponBan(playerid);
public WeaponBan(playerid)
{
    if(GetPlayerWeapon(playerid) != 0)
    {
        new string[128], name[24];

        GetPlayerName(playerid,name,24);

        format(string,128,"%s (%d) Has Been Automatically Banned For Weapon Hacks.",name,playerid);
        SendClientMessageToAll(-1,string);

        print(string);

        Ban(playerid);

        
    }
	return 1;
}
no errors will this still work?
Reply
#7

It should work, I didn't test it myself.

And by default you will get a message saying ' You are banned from this server ' if you attempt to connect while banned.

If you want your own custom message, that takes time and work by creating variables and writing to your userfile, etc..
Reply
#8

nope it spammed bans on every id ever posible into the 10thousends
Reply
#9

Try this:

pawn Код:
forward WeaponBan();
public WeaponBan()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerWeapon(i) != 0))
            {
                new string[128], name[24];

                GetPlayerName(i,name,24);

                format(string,128,"%s (%d) Has Been Automatically Banned For Weapon Hacks.",name,i);
                SendClientMessageToAll(-1,string);

                print(string);

                Ban(i);

            }
        }
    }
    return 1;
}
Reply
#10

crashes server-samp.exe
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)