NexiusTailer / Nex-AC

Anticheat system
https://pawn.wiki/index.php?/topic/27641-nex-ac/
GNU Lesser General Public License v3.0
212 stars 156 forks source link

Code #002 when spawn by first time #169

Closed Walter-Correa closed 4 years ago

Walter-Correa commented 4 years ago

Only when spawning for the first time.

I use InterpolateCameraPos before the player logs in, after I use TogglePlayerSpectating (playerid, false); and when spawn I use SetPlayerPos.

NexiusTailer commented 4 years ago

Where exactly you use all this (what callback(s))? Please provide the code of minimal working example so that I'll be able to reproduce it on a blank gm

rt-2 commented 4 years ago

This is VERY simar to me(https://github.com/NexiusTailer/Nex-AC/issues/159), as I also use all of the mentionned functions when I spawn my players.

Walter-Correa commented 4 years ago

Where exactly you use all this (what callback(s))? Please provide the code of minimal working example so that I'll be able to reproduce it on a blank gm

#include <a_samp>
#include <Pawn.RakNet>//http://forum.sa-mp.com/showthread.php?t=640306
#include <Pawn.CMD>//https://github.com/urShadow/Pawn.CMD
#include <sscanf2>
#include <a_npc>
#include <a_actor>
#include <foreach>//https://github.com/Open-GTO/foreach
#include <streamer>//https://github.com/samp-incognito/samp-streamer-plugin
#include <float>
#include <time>
#include <file>
#include <strlib>//https://github.com/oscar-broman/strlib/blob/master/strlib.inc
#include <PlayerESC>
#include <Zones>
#include <mSelection>
#include <core>
#include <progress>
#include <a_http>
#include <a_Email>//http://forum.sa-mp.com/showthread.php?t=654188 | https://github.com/PHPMailer/PHPMailer
#include <a_Sort>
#include <a_mysql>//https://github.com/pBlueG/SA-MP-MySQL/releases
#include <easy-mysql>//https://github.com/ThreeKingz/easy-mysql
#include <ColorConvert>
#include <garage_block>
#include <discord-connector>//http://forum.sa-mp.com/showthread.php?t=631562 | https://github.com/maddinat0r/samp-discord-connector
#include <GeoLocation>//https://github.com/George480/geolite/releases
#include <timerfix>//https://github.com/KashCherry/Timer-Fix-plugin
#include <zmessage>//https://github.com/Open-GTO/zmessage
#include <BustAim>
#include <nex-ac>

new PlayerText:TextLogin;

public OnPlayerConnect(playerid)
{
    TextLogin = CreatePlayerTextDraw(playerid,320.000000, 157.000000, "LOGIN");
    PlayerTextDrawAlignment(playerid,TextLogin, 2);
    PlayerTextDrawBackgroundColor(playerid,TextLogin, 255);
    PlayerTextDrawFont(playerid,TextLogin, 1);
    PlayerTextDrawLetterSize(playerid,TextLogin, 0.349999, 1.700000);
    PlayerTextDrawColor(playerid,TextLogin, -1);
    PlayerTextDrawSetOutline(playerid,TextLogin, 0);
    PlayerTextDrawSetProportional(playerid,TextLogin, 1);
    PlayerTextDrawSetShadow(playerid,TextLogin, 1);
    PlayerTextDrawUseBox(playerid,TextLogin, 1);
    PlayerTextDrawBoxColor(playerid,TextLogin, 0x00000070);
    PlayerTextDrawTextSize(playerid,TextLogin, 10.000000, 116.000000);
    PlayerTextDrawSetSelectable(playerid,TextLogin, 1);

    TogglePlayerSpectating(playerid, true);
    SetPlayerInterior(playerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerTextDrawShow(playerid,TextLogin);
        SelectTextDraw(playerid, 0xAFAFAFAA);
    InterpolateCameraPos(playerid, 1315.031982, -1732.848999, 22.630048, 1813.086425, -1733.901367, 19.433467, 40000, CAMERA_MOVE);
    InterpolateCameraLookAt(playerid, 1319.984375, -1732.782470, 21.944711, 1815.772827, -1729.687377, 19.593595, 1000, CAMERA_MOVE);
    return 1;
}

public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if(playertextid == TextLogin)
    {
        new regstring[128];
        format(regstring,sizeof(regstring),"{EEDD82}PASSWORD: {FFFFFF}Type your password bellow to login:");
        new_ShowPlayerDialog(playerid,8,DIALOG_STYLE_PASSWORD,"LOGIN",regstring,"Login","Back");
        PlayerTextDrawHide(playerid,TextLogin);
        CancelSelectTextDraw(playerid);
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 8)
    {
        if(response)
        {
            new hash[65];
            SHA256_PassHash(inputtext, PlayerInfo[playerid][Salt], hash, 64);
            if(strlen(inputtext) && !strcmp(PlayerInfo[playerid][Key], hash,  false))
            {
                SetSpawnInfo(playerid, NO_TEAM, PlayerInfo[playerid][Skin], PlayerInfo[playerid][Posx],PlayerInfo[playerid][Posy],PlayerInfo[playerid][Posz], PlayerInfo[playerid][Angle], 0, 0, 0, 0, 0, 0);
                TogglePlayerSpectating(playerid, false);
                SetPlayerSkin(playerid,PlayerInfo[playerid][Skin]);
            }
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, PlayerInfo[playerid][Posx],PlayerInfo[playerid][Posy],PlayerInfo[playerid][Posz]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][Angle]);
    SetPlayerInterior(playerid, PlayerInfo[playerid][Interior]);
    SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][World]);
    SetCameraBehindPlayer(playerid);
    return 1;
}
NexiusTailer commented 4 years ago

First of all, there are only a few includes which should be included before the anticheat and all others should be included after it. In your case you need to include before nex-ac these ones only: Pawn.RakNet, sscanf2, foreach and streamer. Second, what is "new_ShowPlayerDialog"? There are no default natives like that.

As for possible solution, try to remove SetSpawnInfo before the first spawn as you're already using SetPlayerPos exactly when a player spawns.

Walter-Correa commented 4 years ago

First of all, there are only a few includes which should be included before the anticheat and all others should be included after it. In your case you need to include before nex-ac these ones only: Pawn.RakNet, sscanf2, foreach and streamer. Second, what is "new_ShowPlayerDialog"? There are no default natives like that.

As for possible solution, try to remove SetSpawnInfo before the first spawn as you're already using SetPlayerPos exactly when a player spawns.

About includes and setspawninfo I will try. About newShowPlayerDialog I forgot to remove new(is my custom function).

NexiusTailer commented 4 years ago

Ok, let me know if something changes.

Walter-Correa commented 4 years ago

It seems that the include caught a virus that screwed everything up. Unbelievable. Yesterday, when I installed everything worked perfectly, the only problem was when the player spawn, but magically everything is showing a false positive.

Look, I think the problem is with GetTickCount that you are using, I think you should use the fix: https://gist.github.com/ziggi/5d7d8dc42f54531feba7ae924c608e73

My server is on the VPS and even after restarting the problems continue.

See this reaload time, is it normal? [Nex-AC debug] Weaponid: 29, Reload time: -2130338752, state: 1

NexiusTailer commented 4 years ago

You should restart your physical server as it seems it works on Windows (and on windows, samp-server returns values for GetTickCount since the physical machine started and not samp-server executable itself, like it's done on linux).

As for this fix:

Look, I think the problem is with GetTickCount that you are using, I think you should use the fix: https://gist.github.com/ziggi/5d7d8dc42f54531feba7ae924c608e73

You can read one useful topic post about some issues in its efficiency: https://pro-pawn.ru/showthread.php?14127-GetTickDiff-исправление-проблемы-переполнения-для-GetTickCount&p=91432&viewfull=1#post91432 (yeah it's in russian, but I hope you have some auto-translator). And as for me, this and the similar solutions are still "stubs" and they don't fix the real problem, only incurring additional unnecessary operations because of its using. The only wise and true solution would be to simply reboot your server (physical if it is on Windows or samp-server executable if on it runs on Linux) at least once every two weeks.

Walter-Correa commented 4 years ago

FIXED: change GetTickCount to tickcount.

I would be very happy if you made this change to include as well. Thanks for everything!

NexiusTailer commented 4 years ago

I still think that something prevented you to fully reboot your physical server so that was the problem, and not that I and hundreds of other people use GetTickCount instead of tickcount.

Walter-Correa commented 4 years ago

I still think that something prevented you to fully reboot your physical server so that was the problem, and not that I and hundreds of other people use GetTickCount instead of tickcount.

All VPS are running in a physical server and only the provider can reboot, so, as the samp wiki says: tickcount() is the alternative for GetTickCount(). Why not change it?

NexiusTailer commented 4 years ago

Because the vast majority of people host their servers on Linux where GetTickCount gets the ticks from the moment of the samp-server start, not the physical one. I'm more than sure that you are running it on Windows, where the logic of this function is different for some unknown reason and at the same time I'm not sure how tickcount would behave under linux.

Walter-Correa commented 4 years ago

Because the vast majority of people host their servers on Linux where GetTickCount gets the ticks from the moment of the samp-server start, not the physical one. I'm more than sure that you are running it on Windows, where the logic of this function is different for some unknown reason and at the same time I'm not sure how tickcount would behave under linux.

Mmm... Understood now. Yes, my VPS is windows. No problem, I will keep tickcount() after every include updadte. Thanks for your time and work in this amazing anti cheat!

rt-2 commented 4 years ago

I am also hosting on Windows