Timer - 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: Timer (
/showthread.php?tid=511808)
Timer -
JohnFTW - 07.05.2014
Hey, I got a noobie question:
Will this affect server's ping if it runs every 5 seconds ?
pawn Код:
forward cheatann(playerid);
public cheatann(playerid)
new string[128];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
// JETPACK
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
{
format(string, sizeof(string), "ANTICHEAT: [%d]%s has a JETPACK!",playerid, sendername);
ABroadCast(COLOR_DARKRED, string, 7);
return 1;
}
// WEAPONS
new accheckwp = GetPlayerWeapon(playerid);
if(accheckwp == 35 || accheckwp == 36 || accheckwp == 37 || accheckwp == 38 || accheckwp == 44 || accheckwp == 45)
{
format(string, sizeof(string), "ANTICHEAT: [%d]%s has a FORBIDDEN GUN!", playerid, sendername);
ABroadCast(COLOR_DARKRED, string, 7);
return 1;
}
return 1;
}
SetTimer("cheatann", 5000, 1);
Re: Timer -
TheSimpleGuy - 07.05.2014
Quote:
Originally Posted by JohnFTW
pawn Код:
new accheckwp = GetPlayerWeapon(playerid); if(accheckwp == 35 || accheckwp == 36 || accheckwp == 37 || accheckwp == 38 || accheckwp == 44 || accheckwp == 45) { format(string, sizeof(string), "ANTICHEAT: [%d]%s has a FORBIDDEN GUN!", playerid, sendername); ABroadCast(COLOR_DARKRED, string, 7); return 1; }
|
pawn Код:
//OnPlayerWeaponShot
if(weaponid >= 1)
{
switch(weaponid)
{
case 1..3:
{
SetTimerEx("BanPublic", 1000, false, "d", playerid);
format(string, sizeof(string), "%s [%d] has been banned from weapon hacking.",name1,playerid);
SendClientMessageToAll(0xFF0000FF, string);
}
case 5..15:
{
SetTimerEx("BanPublic", 1000, false, "d", playerid);
format(string, sizeof(string), "%s [%d] has been banned from weapon hacking.",name1,playerid);
SendClientMessageToAll(0xFF0000FF, string);
}
Make anti-weapon cheat based on my code, because it's simple.
Re: Timer -
Calgon - 08.05.2014
Quote:
Originally Posted by JohnFTW
Hey, I got a noobie question:
Will this affect server's ping if it runs every 5 seconds ?
pawn Код:
forward cheatann(playerid); public cheatann(playerid) new string[128]; new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid, sendername, sizeof(sendername)); // JETPACK if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) { format(string, sizeof(string), "ANTICHEAT: [%d]%s has a JETPACK!",playerid, sendername); ABroadCast(COLOR_DARKRED, string, 7); return 1; } // WEAPONS new accheckwp = GetPlayerWeapon(playerid); if(accheckwp == 35 || accheckwp == 36 || accheckwp == 37 || accheckwp == 38 || accheckwp == 44 || accheckwp == 45) { format(string, sizeof(string), "ANTICHEAT: [%d]%s has a FORBIDDEN GUN!", playerid, sendername); ABroadCast(COLOR_DARKRED, string, 7); return 1; } return 1;
}
SetTimer("cheatann", 5000, 1);
|
5 seconds is not often enough, even 1 second can be too slow sometimes. 5 seconds will definitely cause any ping problems however, though you should really consider running your timer more often.
Minor usage even in OnPlayerUpdate is also fine.
Re: Timer -
JohnFTW - 08.05.2014
Thank you!