Anticheat, ID 0 always getting kicked/banned -
Robbin237 - 16.02.2009
Ok guys, listen, im making to try a similair Anticheat to crazybobs XD
But ive already had help here, i cant figure this out. It has to check all players, and check if they have any weapons in the row DetectWeapons. ID 0 is ALWAYS getting banned.
Please help me fix this shit.
Heres the code:
pawn Код:
new DetectWeapons[] = { 8, 9, 16, 17, 21, 35, 36, 37, 38, 42 };
public TestWeapons(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new Name[MAX_PLAYER_NAME+1];
new Player;
GetPlayerName(Player, Name, sizeof(Name));
Player = GetPlayerID(Name);
if (IsPlayerConnected(i))
{
if(!IsPlayerAdmin(i)) {
new pWeapon = GetPlayerWeapon(i);
for (i = 0; i < sizeof(DetectWeapons); i++)
if (pWeapon == DetectWeapons[i])
{
SendClientMessageToAll(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);
SetPlayerInterior(Player, 6);
SetPlayerPos(Player, 264.2752, 81.9539, 1001.0391);
SetPlayerSpecialAction(Player, SPECIAL_ACTION_HANDSUP);
SetPlayerFacingAngle(Player, 260);
new NewKilled = dini_Int("server.ini", "ACKilled") + 1;
dini_IntSet("server.ini", "ACKilled", NewKilled);
Kick(i);
}
}
}
}
return 1;
}
Re: Anticheat, ID 0 always getting kicked/banned -
Nimphious - 16.02.2009
use tags
Re: Anticheat, ID 0 always getting kicked/banned -
Robbin237 - 16.02.2009
changed
Re: Anticheat, ID 0 always getting kicked/banned -
Robbin237 - 16.02.2009
*BUMP* I really need help with this -.-
Plz
Re: Anticheat, ID 0 always getting kicked/banned -
Robbin237 - 16.02.2009
Can't somebody help me
Re: Anticheat, ID 0 always getting kicked/banned -
Nero_3D - 16.02.2009
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
Re: Anticheat, ID 0 always getting kicked/banned -
Robbin237 - 16.02.2009
Can you please post the code of how that would be done?
Re: Anticheat, ID 0 always getting kicked/banned -
Nero_3D - 16.02.2009
Quote:
Originally Posted by Robbin237
Can you please post the code of how that would be done?
|
Look in my previous post
A good idea is to mark or quote it
Its in the emtpy space between, "What we see..." and "How to fix..."
Re: Anticheat, ID 0 always getting kicked/banned -
Robbin237 - 16.02.2009
Ok now i get these two errors.
pawn Код:
E:\_Spellen\bkp\filterscripts\dcanticheat.pwn(75) : error 033: array must be indexed (variable "DetectWeapons")
E:\_Spellen\bkp\filterscripts\dcanticheat.pwn(85) : error 017: undefined symbol "Player"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
How to fix?
Re: Anticheat, ID 0 always getting kicked/banned -
Nero_3D - 16.02.2009
pawn Код:
new DetectWeapons[] = { 8, 9, 16, 17, 21, 35, 36, 37, 38, 42 };
forward TestWeapons();
public TestWeapons()
{
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[y])
{
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, i, pWeapon);
Kick(i);
break; //just to stop the second loop
}
}
}
return 1;
}