Check Position bugged
#1

I'm trying to make a ANTI Teleport Hack, but i got some problems

It's so simple, get player position, after sometime check if player is in a valid range
If this range is so high and player was not teleported for a server command (SetPlayerPosEx)
It punish the teleport hack

But i'm stuck in the part to if player use server command, dont detect was a hacker

The values here:
Код:
format(string, sizeof(string), "Xtp[%i], Ytp[%i], Ztp[%i]", Xtp[playerid], Ytp[playerid], Ztp[playerid] );
Should be (i used /save in the same place i've got this string /\ ):
Код:
-25.3970,-185.8796,1003.5469
But instead of it, its showing:
Код:
[05:50:29] Xtp[-1043649266], Ytp[-1019616979], Ztp[1148904192]
Full code:
Код:
stock SetPlayerPosEx(playerid,Float:x,Float:y,Float:z,Float:angle,int,vw, bool:carregar = false) {
    // update anti TP (to dont detect)
    Xtp[playerid] = x;
    Ytp[playerid] = y;
    Ztp[playerid] = z;
    INTtp[playerid] = int;
    VWtp[playerid] = vw;
    // 
    SetPlayerInterior(playerid,int);
    SetPlayerVirtualWorld(playerid, vw);
    SetPlayerPos(playerid, x,y,z);
    if(angle == 0) SetCameraBehindPlayer(playerid);
    if(carregar == true) PlayerCarregando(playerid);
    // active anti TP
    ContadorTeleport[playerid] = SetTimerEx("DetectTeleport", 50, false, "i", playerid);
    return 1;
}
forward CheckTeleport(playerid); public CheckTeleport(playerid) {
    KillTimer(ContadorTeleport[playerid]);
    if(IsPlayerConnected(playerid) && playerid != INVALID_PLAYER_ID) {
        GetPlayerPos(playerid, Xtp[playerid], Ytp[playerid], Ztp[playerid]);
        INTtp[playerid] = GetPlayerInterior(playerid);
        VWtp[playerid] = GetPlayerVirtualWorld(playerid);
        ContadorTeleport[playerid] = SetTimerEx("DetectTeleport", 500, false, "i", playerid);
    }
}
forward DetectTeleport(playerid); public DetectTeleport(playerid) {
    KillTimer(ContadorTeleport[playerid]);
    if(gSpectateID[playerid] == 65535 && paused[playerid] == false) {
        if(!IsPlayerInRangeOfPoint(playerid, 60.0, Xtp[playerid], Ytp[playerid], Ztp[playerid])) {
            new string[128];
            format(string, sizeof(string), "Xtp[%i], Ytp[%i], Ztp[%i]", Xtp[playerid], Ytp[playerid], Ztp[playerid] );
            ABroadCast(-1,string,3);
            format(string, sizeof(string), "HACK: %s TELEPORT", PlayerName(playerid) );
            ABroadCast(-1,string,3);
            SetPlayerPosEx(playerid, Xtp[playerid], Ytp[playerid], Ztp[playerid], 0, INTtp[playerid], VWtp[playerid]);
        }
    }
    ContadorTeleport[playerid] = SetTimerEx("CheckTeleport", 500, false, "i", playerid);
}
What do i doing wrong?
Reply
#2

What i'm doing wrong guys?
Still stuck in this
Reply
#3

You're trying to make a float, work with integer in your format, so that will throw out incorrect results in the first instance.


You need %f when dealing with floats, not %i (Integer).
Reply
#4

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You're trying to make a float, work with integer in your format, so that will throw out incorrect results in the first instance.


You need %f when dealing with floats, not %i (Integer).
Ohhhhhh thanks!

Now i think i got the problem...
[22:06:17] Xtp[1978.745239], Ytp[-1761.960449], Ztp[13.546875]
[22:06:20] -> OnFoot position saved (1978.7452,-1761.9604,13.5469)

Is this because
Xtp is 1978.745239
When should be 1978.7452 ?

Limit it to take only max 4 numbers after .
Should be the fix or would cause another problems latter?
If it is the right way to fix, how to take only the 4 numbers after .?
Reply
#5

Should be fine, /save probably just does to 4 decimal places, where float isn't inhibited by the decimals.

If you want your script to return the 4 decimal places, use %.4f, instead of just %f as the format specifier.
Reply
#6

How to do it?

Xtp[playerid] = x.4f; ?
Reply
#7

replace %i with %.4f or %f
Reply
#8

From this...

Код:
format(string, sizeof(string), "Xtp[%i], Ytp[%i], Ztp[%i]", Xtp[playerid], Ytp[playerid], Ztp[playerid] );
to this...

Код:
format(string, sizeof(string), "Xtp[%.4f], Ytp[%.4f], Ztp[%.4f]", Xtp[playerid], Ytp[playerid], Ztp[playerid] );
And it will show in the log as what it is in the save command, but it doesn't matter as it's less than an inch in movement at that far down the decimals.


And this will ONLY show in the logs/chat, in the GetPlayerPosition it's still showing 8 decimals, but you just won't see them unless you look at the users saved data in their accounts if the enum is saved to their player file.
Reply
#9

format(string, sizeof(string), "Xtp[%.4f], Ytp[%.4f], Ztp[%.4f]", Xtp[playerid], Ytp[playerid], Ztp[playerid] );
Is just where it print, the error will still happen, you need to get a way to change:
Xtp[playerid] = x;
Ytp[playerid] = y;
Ztp[playerid] = z;
To get only the 4 numbers after dot

Because else if it will still bugging on
if(!IsPlayerInRangeOfPoint(playerid, 60.0, Xtp[playerid], Ytp[playerid], Ztp[playerid])) {
Reply
#10

Quote:
Originally Posted by maikons
Посмотреть сообщение
Because else if it will still bugging on
if(!IsPlayerInRangeOfPoint(playerid, 60.0, Xtp[playerid], Ytp[playerid], Ztp[playerid])) {
What are you on about? It's HIGHLY unlikely that it will bug because it has 8 decimal places, compared to 4...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)