18.11.2013, 22:54
There are A LOT of improvements to do... You could achieve the same result with just ONE check.
https://sampwiki.blast.hk/wiki/GetPlayerWeapon.
You have a lot more to learn; but you are in the right track.
Consider the following issues:
1) Why do you need two timers if you can do the same with one?
2) Why is the banning variable needed in this case? (referring to #1)
3) So many unnecessary CHECKS... What a waste of resources... GetPlayerWeapon(playerid) returns true if the player posses ANY weapon.. and returns false if not.
4) Why do you need pname to have 200 chars when the MAXIMUM for player name is only 24 chars? (MAX_PLAYER_NAME)
5) Let's agree that you don't really need 200 chars for that string, do you? You need exactly 50 chars to show the full message..
https://sampwiki.blast.hk/wiki/GetPlayerWeapon.
You have a lot more to learn; but you are in the right track.
Consider the following issues:
1) Why do you need two timers if you can do the same with one?
2) Why is the banning variable needed in this case? (referring to #1)
3) So many unnecessary CHECKS... What a waste of resources... GetPlayerWeapon(playerid) returns true if the player posses ANY weapon.. and returns false if not.
4) Why do you need pname to have 200 chars when the MAXIMUM for player name is only 24 chars? (MAX_PLAYER_NAME)
5) Let's agree that you don't really need 200 chars for that string, do you? You need exactly 50 chars to show the full message..
pawn Code:
//Made By Meow22
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define COLOR_GREEN 0x00FF00
forward weaponanti();//checks if a player has an illegal weapon
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Anti-Weapon Cheat By Meow22");
print("--------------------------------------\n");
SetTimer("weaponanti", 5000, true);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#endif
public weaponanti()
{
new pname[MAX_PLAYER_NAME], string[200];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (GetPlayerWeapon(i)) // is player posses a ANY weapon? - the loop ignores the following code if does not (returns false)
{
GetPlayerName(i, pname, sizeof(pname));
format(string, sizeof(string), "[ANTI-CHEAT] %s Banned for Weapon Hack", pname);
SendClientMessageToAll(COLOR_GREEN, string);
}
}
}