[FilterScript] Anti-iWeapon / Ammo Spawner
#1

Made this around 1 and half hours ago. Just quick thing for my server - but then decided to release it.

pawn Код:
/*
Filterscript by ya boi GiGi.
============================
ZCMD Include > https://sampforum.blast.hk/showthread.php?tid=91354
FOREACH Include > https://sampforum.blast.hk/showthread.php?tid=92679
*/


#include <a_samp>
#include <foreach>
#include <zcmd>

new PlayerAllowedRestrictedWeapons[MAX_PLAYERS]=0;

#define ALTCOMMAND:%1->%2;                     \
            CMD:%1(playerid, params[])     \
                return cmd_%2(playerid, params);

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    return 1;
}

public OnFilterScriptExit()
{
    print("\n----------------------------------");
    print(" Anti-iWeapSpawner unloaded successfully");
    print("----------------------------------\n");
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Anti-iWepSpawner - Loaded successfully");
    print("----------------------------------\n");
}

#endif

public OnPlayerConnect(playerid)
{
    PlayerAllowedRestrictedWeapons[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerAllowedRestrictedWeapons[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    PlayerAllowedRestrictedWeapons[playerid] = 0;
    return 1;
}

stock IsThereAnyAdmin()
{
    new count = 0;
    foreach(new i : Player) // Player Loop > ******
    {
        switch(IsPlayerAdmin(i)) // Looping threw values of RCON
        {
            case 1: count++; // If Player is RCON Level 1, add's one to the Count
            default: continue;
        }
    }
    return count;
}

stock PlayerHasRestrictedWeapon(playerid)
{
    new weap = GetPlayerWeapon(playerid);
    if(weap == 35 || weap == 36 || weap == 37 || weap == 38 || weap == 39 || weap == 40 || weap == 41 || weap == 42 || weap == 43 || weap == 44 || weap == 45) return 1;
    return 0;
}

public OnPlayerUpdate(playerid)
{
    new globalstring[128];
    if(PlayerAllowedRestrictedWeapons[playerid] < 1)
    {
        if(PlayerHasRestrictedWeapon(playerid) > 0 && !IsPlayerAdmin(playerid))
        {
            foreach(new i : Player)
            {
                new pName[24];
                GetPlayerName(playerid, pName, sizeof(pName));
                if(IsThereAnyAdmin() > 0) // Checking if there is any RCON Administrator online.
                {
                    new Name[ 32 ], Weapon = GetPlayerWeapon(playerid);
                    GetWeaponName(Weapon, Name, sizeof(Name));
                    format(globalstring, sizeof(globalstring),"{edb357}Warning: {f4d8ac}%s possible Weapon Spawn. Weapon: %s (%d Ammo)",pName, Name, GetPlayerAmmo(playerid));
                    SendClientMessage(i, -1, globalstring);
                    ResetPlayerWeapons(playerid);
                }
                else
                {
                    new Name[ 32 ], Weapon = GetPlayerWeapon(playerid);
                    GetWeaponName(Weapon, Name, sizeof(Name));
                    format(globalstring, sizeof(globalstring), "{FF6347}[SERVER]{ffffff} %s has been IP Banned. Suspicion of weapon spawning. (Weapon: %s [%d Ammo])",pName, Name, GetPlayerAmmo(playerid));
                    SendClientMessageToAll(-1, globalstring);
                    Ban(playerid);
                }
            }
        }
        if(GetPlayerAmmo(playerid) > 9999)
        {
            if(!IsPlayerAdmin(playerid))
            {
                foreach(new i : Player)
                {
                    new pName[24];
                    GetPlayerName(playerid, pName, sizeof(pName));
                    if(IsThereAnyAdmin() > 0) // Checking if there is any RCON Administrator online.
                    {
                        new Name[ 32 ], Weapon = GetPlayerWeapon(playerid);
                        GetWeaponName(Weapon, Name, sizeof(Name));
                        format(globalstring, sizeof(globalstring),"{edb357}Warning: {f4d8ac}%s possible Ammo hack. Weapon: %s (%d Ammo)",pName, Name, GetPlayerAmmo(playerid));
                        SendClientMessage(i, -1, globalstring);
                    }
                    else
                    {
                        new Name[ 32 ], Weapon = GetPlayerWeapon(playerid);
                        GetWeaponName(Weapon, Name, sizeof(Name));
                        format(globalstring, sizeof(globalstring), "{FF6347}[SERVER]{ffffff} %s(%d) has been IP Banned. Suspicion of Ammo hacking. (Weapon: %s [%d Ammo])",pName, playerid, Name, GetPlayerAmmo(playerid));
                        SendClientMessageToAll(-1, globalstring);
                        Ban(playerid);
                    }
                }
            }
        }
    }
    return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    return 0;
}
COMMAND:givegun(playerid, params[])
{
    new globalstring[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not allowed to use this command.");
    new iPlayer, iWeap, iAmmo;
    if(sscanf(params, "udd", iPlayer, iWeap, iAmmo)) return SendClientMessage(playerid, -1, "/givegun [Playerid] [Weapon] [Ammo]");
    if(!IsPlayerConnected(iPlayer)) return SendClientMessage(playerid, -1, "Player has not been found. Please try again.");
    if(iAmmo > 9999 || iAmmo < 1) return SendClientMessage(playerid, -1, "Ammo value is invalid");
    GivePlayerWeapon(iPlayer, iWeap, iAmmo);
    PlayerAllowedRestrictedWeapons[playerid] = 1;
    new pName[24], pName2[24];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(iPlayer, pName2, sizeof(pName2));
    new Weapon[24];
    GetWeaponName(iWeap, Weapon, sizeof(Weapon));
    format(globalstring, sizeof(globalstring),"[WEAP] %s has give you the weapon: %s with %d ammo.",pName, Weapon, iAmmo);
    SendClientMessage(iPlayer, -1, globalstring);
    format(globalstring, sizeof(globalstring),"[WEAP] %s you have given %s the weapon: %s with %d ammo.", pName, pName2, Weapon, iAmmo);
    SendClientMessage(iPlayer, -1, globalstring);
    return 1;
}
COMMAND:check(playerid, params[])
{
    new globalstring[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not allowed to use this command.");
    new iPlayer;
    if(sscanf(params, "u", iPlayer)) return SendClientMessage(playerid, -1, "/givegun [Playerid]");
    if(!IsPlayerConnected(iPlayer)) return SendClientMessage(playerid, -1, "Player has not been found. Please try again.");
    new pName[24];
    GetPlayerName(iPlayer, pName, sizeof(pName));
    format(globalstring, sizeof(globalstring),"%s weapons inside inventory:",pName);
    SendClientMessage(playerid, -1, globalstring);
    new Name[ 32 ];
    for(new i=0; i < 13; i++)
    {
        new Weapon, Ammo;
        GetPlayerWeaponData(iPlayer, i, Weapon, Ammo);
        GetWeaponName(Weapon, Name, sizeof(Name));
        if(strlen(Name))
        {
            format(globalstring, sizeof(globalstring), " Weapon:[%s] Ammo:[%d] Slot:[%d]", Name, Ammo, i);
            SendClientMessage(playerid, -1, globalstring);
        }
    }
    return 1;
}
There isn't much to tell, although - it uses:
  • Foreach Include
  • ZCMD Include
If there is an RCON Admin online - it sends a message to them notifying that there is a possible Weapon Spawner / ammo, also it resets the accusers weapons.

If there isn't an RCON Admin online, well then - accuser is going to be IP Banned.

RCON Admins are allowed to have all Weapons - there will be no notification / ban. Also, if a RCON Admin uses /givegun on anyone and the weapon is restricted it allows the player to have the weapon - no ban or notification.

COMMANDS: /givegun | /check

Ammo side of things. Pretty simple - if player has over 9999 bullets inside their weapon - Bans them (If there is no RCON Admin online) but if there is a RCON Admin online, it sends them a message with the following: Weapon Name | Ammo amount and their name of course.

Sorry, I really struggled puttin this in to words. - Anyway I hope it becomes useful to you.

Reply
#2

Well the code you give i didnt check but plz remove the center before your pawn code plz!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)