GetPlayerPos and SetPlayerPos - AC detect. -
KubiPL - 12.11.2013
Hello,
I have a question. How the fck my AC isn't work properly.
I use arrays when SetPlayerPos to AC to detect teleports etc.
But I don't know why the GetPlayerPos return false position.
Look at the code:
Function which I test (command /warp x y z)
Код:
stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z)
{
SetPVarInt(playerid, "teleport", 1);
PlayerInfo[playerid][pPos][0] = x;
PlayerInfo[playerid][pPos][1] = y;
PlayerInfo[playerid][pPos][2] = z;
PlayerInfo[playerid][pOldPos][0] = x;
PlayerInfo[playerid][pOldPos][1] = y;
PlayerInfo[playerid][pOldPos][2] = z;
SetPlayerPos(playerid, x, y, z);
printf("Player %d pos set to: %f, %f, %f DEBUG (NEW: %f, %f, %f __ OLD: %f, %f, %f)", playerid, x, y, z,PlayerInfo[playerid][pPos][0],PlayerInfo[playerid][pPos][1],PlayerInfo[playerid][pPos][2],PlayerInfo[playerid][pOldPos][0],PlayerInfo[playerid][pOldPos][1],PlayerInfo[playerid][pOldPos][2]);
}
And in Anti Cheat (in loop):
Код:
GetPlayerPos(i, PlayerInfo[i][pPos][0],PlayerInfo[i][pPos][1],PlayerInfo[i][pPos][2]);
AC_CheckTeleport(i);
AC_CheckAirBreak(i);
AC_CheckFly(i);
AC_CheckCar(i);
PlayerInfo[i][pOldPos][0] = PlayerInfo[i][pPos][0];
PlayerInfo[i][pOldPos][1] = PlayerInfo[i][pPos][1];
PlayerInfo[i][pOldPos][2] = PlayerInfo[i][pPos][2];
AC_CheckTeleport function:
Код:
public AC_CheckTeleport(playerid)
{
if(GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID(playerid) == INVALID_OBJECT_ID)
{
if(GetDistanceBetweenPoints(PlayerInfo[playerid][pOldPos][0], PlayerInfo[playerid][pOldPos][1], PlayerInfo[playerid][pOldPos][2], PlayerInfo[playerid][pPos][0], PlayerInfo[playerid][pPos][1], PlayerInfo[playerid][pPos][2]) > 350)
{
if(GetPVarInt(playerid, "spawned") == 1 && GetPVarInt(playerid, "ac_jump") == 0)
{
CallRemoteFunction("OnPlayerHack", "ii", playerid, 6);
}
}
}
}
Logs from testing:
Код:
[12/11/2013 21:02:50] Player 0 pos set to: -1720.089965, 1018.739074, 17.583700 DEBUG (NEW: -1720.089965, 1018.739074, 17.583700 __ OLD: -1720.089965, 1018.739074, 17.583700)
[12/11/2013 21:02:50] Player 0 pos set to: -1613.584106, 732.961669, -5.243100 DEBUG (NEW: -1613.584106, 732.961669, -5.243100 __ OLD: -1613.584106, 732.961669, -5.243100)
[12/11/2013 21:02:50] Anti-Cheat: Kubi (UID: 1) banned for Teleport (pos: -1720.089965|1018.739074|17.585937 old: -1613.584106|732.961669|-5.243100)
Look at time - all is in 1 second.
AC check players every 1.5 sec.
warp command I type every about 1s all time - when AC won't send any msg.
It is possible that the functions overlap?
Please, help me.
Re: GetPlayerPos and SetPlayerPos - AC detect. -
KubiPL - 13.11.2013
Any help?
Re: GetPlayerPos and SetPlayerPos - AC detect. -
cessil - 13.11.2013
you're not taking into account lag, things like setting a players position doesn't happen instantly
Re: GetPlayerPos and SetPlayerPos - AC detect. -
KubiPL - 13.11.2013
I'll try make debug with gettime() and post it here late.
I think the code is made good, isn't it?
Re: GetPlayerPos and SetPlayerPos - AC detect. -
cessil - 13.11.2013
kind of, but you're lacking parts that you've half implemented
SetPVarInt(playerid, "teleport", 1);
this I believe should mean that they're about to teleport however its not in the detection part so its useless
PlayerInfo[playerid][pPos][0] = x;
PlayerInfo[playerid][pPos][1] = y;
PlayerInfo[playerid][pPos][2] = z;
these I believe should not be set in SetPlayerPos and should just store their last position from GetPlayerPos and they don't have to be global variables
I'd do something like this
pawn Код:
stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z)
{
SetPVarInt(playerid, "teleport", 1);
PlayerInfo[playerid][pOldPos][0] = x;
PlayerInfo[playerid][pOldPos][1] = y;
PlayerInfo[playerid][pOldPos][2] = z;
SetPlayerPos(playerid, x, y, z);
}
pawn Код:
public AC_CheckTeleport(playerid)
{
if(GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID(playerid) == INVALID_OBJECT_ID)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
new Float:dist = GetDistanceBetweenPoints(PlayerInfo[playerid][pOldPos][0], PlayerInfo[playerid][pOldPos][1], PlayerInfo[playerid][pOldPos][2], PlayerInfo[playerid][pPos][0], PlayerInfo[playerid][pPos][1], PlayerInfo[playerid][pPos][2]);
if(!GetPVarInt(playerid,"teleport"))
{
if(dist > 350)
{
if(GetPVarInt(playerid, "spawned") == 1 && GetPVarInt(playerid, "ac_jump") == 0)
{
CallRemoteFunction("OnPlayerHack", "ii", playerid, 6);
}
}
}
else
{
if(dist < an appropriate amount)
{
DeletePVarInt(playerid,"teleport");
}
}
}
}
this is the basics there's more things to look at with the link in my signature
Re: GetPlayerPos and SetPlayerPos - AC detect. -
KubiPL - 13.11.2013
OK, I do local varibles and add check for PVar - teleport. Seems to be good.
Thanks for help