Will this slow/Lag my server ?
#1

Will this slow/Lag my server?

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerWeapon(playerid) != 0) {
        SetPlayerArmedWeapon(playerid, 0);
        return 0;
    }
   
    for(new i=0, j = sizeof(BadWeapons); i != j; i++) {

        new WeaponID,Ammo;
        GetPlayerWeaponData(playerid, BadWeapons[i][1], WeaponID, Ammo);
       
        if(WeaponID == BadWeapons[i][0] && Ammo >= 0) {
       
            new WeaponName[24],string[128];
            GetWeaponName(WeaponID, WeaponName, sizeof(WeaponName));
            format(string,128,"(ANTI-CHEAT) %s has been banned from server (Reason: Weapon/Ammo Hack (%s) )",PlayerName(playerid),WeaponName);
            SendClientMessageToAll(COLOR_RED, string);
            GameTextForPlayer(playerid,"~r~BANNED~n~Post Unban App in forums~n~To get Unban",3000,3);
            format(string,128,"Weapon/Ammo Hack (%s)",WeaponName);
            BanEx(playerid, string);

            return 0;
        }
    }
   
    return 1;
}
Reply
#2

What about:
pawn Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_FIRE))
    {
        switch(GetPlayerWeapon(playerid))
        {
            case 38, 42: // Your weapon ids.
            {
                Ban(playerid);
            }
        }
    }
    return 1;
}

No need for OPU. It gets called more than 2 times per second if I'm not wrong
Reply
#3

Depends on what the size of 'BadWeapons' is. I recommend you use an implementation of OnPlayerWeaponChange:

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;
   
    // ----- OnPlayerWeaponChange -----
    static
        oldWeapon[MAX_PLAYERS char];
    new
        newWeapon = GetPlayerWeapon(playerid);
       
    if(newWeapon != oldWeapon{playerid})
    {
        OnPlayerWeaponChange(playerid, newWeapon, oldWeapon{playerid});
        oldWeapon{playerid} = newWeapon;
        return 1;
    }

    // Rest of your onplayerupdate stuff
    return 1;
}
pawn Код:
public OnPlayerWeaponChange(playerid, newweapon, oldweapon)
{
    // called when player changes weapon
    return 1;
}
In before ****** comes nagging about profiler plugin.
Reply
#4

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
What about:
pawn Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_FIRE))
    {
        switch(GetPlayerWeapon(playerid))
        {
            case 38, 42: // Your weapon ids.
            {
                Ban(playerid);
            }
        }
    }
    return 1;
}

No need for OPU. It gets called more than 2 times per second if I'm not wrong
Quote:
Originally Posted by Vince
Посмотреть сообщение
Depends on what the size of 'BadWeapons' is. I recommend you use an implementation of OnPlayerWeaponChange:

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;
   
    // ----- OnPlayerWeaponChange -----
    static
        oldWeapon[MAX_PLAYERS char];
    new
        newWeapon = GetPlayerWeapon(playerid);
       
    if(newWeapon != oldWeapon{playerid})
    {
        OnPlayerWeaponChange(playerid, newWeapon, oldWeapon{playerid});
        oldWeapon{playerid} = newWeapon;
        return 1;
    }

    // Rest of your onplayerupdate stuff
    return 1;
}
pawn Код:
public OnPlayerWeaponChange(playerid, newweapon, oldweapon)
{
    // called when player changes weapon
    return 1;
}
In before ****** comes nagging about profiler plugin.
Thanks. but i want that even Bad Weapons its not armed, Player should get a sexy ban. and should not get too laggy or slow the server :P
Reply
#5

or you could make a timer (sort of global timer that repeat 1 second) and put everything that you need to check about player (money, weapons , ammo ..... ) insted of frequently same thing over and over
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)