Will this slow/Lag my server ? - 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)
+--- Thread: Will this slow/Lag my server ? (
/showthread.php?tid=422630)
Will this slow/Lag my server ? -
dr.lozer - 14.03.2013
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;
}
Re: Will this slow/Lag my server ? -
Djole1337 - 14.03.2013
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
Re: Will this slow/Lag my server ? -
Vince - 14.03.2013
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.
Re: Will this slow/Lag my server ? -
dr.lozer - 14.03.2013
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
Re: Will this slow/Lag my server ? -
doreto - 14.03.2013
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