Anticheat, ID 0 always getting kicked/banned
#6

pawn Код:
new Name[MAX_PLAYER_NAME+1];
        new Player;
        GetPlayerName(Player, Name, sizeof(Name));
        Player = GetPlayerID(Name);
What does this do
Line 1: It creats an array with 25 cells called "Name"
Line 2: It creats a variable called "Player" which is 0
Line 3: We get the playername of id 0 because Player is 0
Line 4: We get the playerid of the name from playerid 0 result is playerid 0 which get stored in the Variable Player

What we see, Player will always be 0 because we never set it to annother number or replace it with the same number


new DetectWeapons[] = { 8, 9, 16, 17, 21, 35, 36, 37, 38, 42 };

public TestWeapons(playerid)
{
new i, Name[MAX_PLAYER_NAME], pWeapon, y;
for (; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && !IsPlayerAdmin(i))
{
pWeapon = GetPlayerWeapon(i);
for (y = 0; y < sizeof(DetectWeapons); y++)
if (pWeapon == DetectWeapons[i])
{

SetPlayerInterior(i , 6);
SetPlayerFacingAngle(i, 260);
GetPlayerName(i, Name, sizeof(Name));
SetPlayerPos(i , 264.2752, 81.9539, 1001.0391);
SetPlayerSpecialAction(i , SPECIAL_ACTION_HANDSUP);
dini_IntSet("server.ini", "ACKilled", (dini_Int("server.ini", "ACKilled") + 1));
SendClientMessage(i, COLOR_RED, "You've Been Caught Using A Forbidden Weapon!");
printf("[DC-AntiCheat] %s (%d) Has Been Killed By DC Anticheat. (Weapon ID: %d)", Name, Player, pWeapon);
Kick(i);
break; //just to stop the second loop
}
}
}
return 1;
}


How to fix it ? Easy, you need to use the variable called "i" because with it you loop through MAX_PLAYERS
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)