SA-MP Forums Archive
detect spec hack? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: detect spec hack? (/showthread.php?tid=632511)



detect spec hack? - FelipeAndres - 15.04.2017

Someone who has some effective code against this trap they use to spy on other players

Thank you!


Re: detect spec hack? - GangstaSunny. - 15.04.2017

Check if the player is in spectating mode


Respuesta: detect spec hack? - FelipeAndres - 15.04.2017

Does not work, since the player is still on PLAYER_STATE_ONFOOT ...


Re: detect spec hack? - LEOTorres - 15.04.2017

You can compare GetPlayerCameraPos with GetPlayerPos.

https://sampwiki.blast.hk/wiki/GetPlayerCameraPos
https://sampwiki.blast.hk/wiki/GetPlayerPos


Respuesta: Re: detect spec hack? - FelipeAndres - 15.04.2017

Quote:
Originally Posted by LEOTorres
Посмотреть сообщение

I had tried that, but sometimes the position of the camera with that of the player varies a lot.

Would you help me improve it?

PHP код:
new Float:PosPlayer[3], Float:PosCamera[3];
        
GetPlayerCameraPos(playeridPosCamera[0], PosCamera[1], PosCamera[2]);
        
GetPlayerPos(playeridPosPlayer[0], PosPlayer[1], PosPlayer[2]);
        new 
Float:PosFinal[3];
        
PosFinal[0] = PosCamera[0]-PosPlayer[0];
        
PosFinal[1] = PosCamera[1]-PosPlayer[1];
        if(
PosFinal[0] > 20 || PosFinal[0] < -20)
        {
            
//cheat
        
}
        if(
PosFinal[1] > 20 || PosFinal[1] < -20)
        {
            
//cheat
        




Re: detect spec hack? - Unrea1 - 15.04.2017

https://sampforum.blast.hk/showthread.php?tid=631567
https://sampforum.blast.hk/showthread.php?tid=487708


Respuesta: Re: detect spec hack? - FelipeAndres - 15.04.2017

Quote:
Originally Posted by Doesk
Посмотреть сообщение
I do not think it will help my problem


Re: Respuesta: Re: detect spec hack? - LEOTorres - 15.04.2017

Quote:
Originally Posted by FelipeAndres
Посмотреть сообщение
I had tried that, but sometimes the position of the camera with that of the player varies a lot.

Would you help me improve it?

PHP код:
new Float:PosPlayer[3], Float:PosCamera[3];
        
GetPlayerCameraPos(playeridPosCamera[0], PosCamera[1], PosCamera[2]);
        
GetPlayerPos(playeridPosPlayer[0], PosPlayer[1], PosPlayer[2]);
        new 
Float:PosFinal[3];
        
PosFinal[0] = PosCamera[0]-PosPlayer[0];
        
PosFinal[1] = PosCamera[1]-PosPlayer[1];
        if(
PosFinal[0] > 20 || PosFinal[0] < -20)
        {
            
//cheat
        
}
        if(
PosFinal[1] > 20 || PosFinal[1] < -20)
        {
            
//cheat
        

You are correct that the camera position can vary quite a lot, in particular when a player is surfing a vehicle and repeatedly aims his weapon and when a player teleports with G his camera change is delayed.

What I would recommend is having more checks to see whether the player is in fact using the spectate cheat, or it's just a bug or abnormal change in the game. This can be done by changing the players position back to default upon detection of the cheat the first time, then when a quick change is remade, you can be more likely positive that the player is using the spectate cheat.

Код:
new specWarn[MAX_PLAYERS];

forward ResetSpecWarn (playerid);

new Float:PosPlayer[3], Float:PosCamera[3];
GetPlayerCameraPos(playerid, PosCamera[0], PosCamera[1], PosCamera[2]);
GetPlayerPos(playerid, PosPlayer[0], PosPlayer[1], PosPlayer[2]);
new Float:PosFinal[3];

PosFinal[0] = PosCamera[0] - PosPlayer[0];
PosFinal[1] = PosCamera[1] - PosPlayer[1];

new surf = GetPlayerSurfingVehicleID(playerid);
new seat = GetPlayerVehicleSeat (playerid);

if(PosFinal[0] > 20 || PosFinal[0] < -20 || PosFinal[1] > 20 || PosFinal[1] < -20)
{
	if (specWarn[playerid] == 0)
	{
		specWarn[playerid] = 1;
		SetCameraBehindPlayer(playerid);
		SetTimerEx("ResetSpecWarn", 60000, false, "i", playerid);
		return 1;
	}

	if (surf != INVALID_VEHICLE_ID)
	{
		//player is using cheats or surfing is affecting the camera?
		return 1;
	}
		
	if (seat > 0)
	{
		//player is using cheats or g camera bug?
		return 1;
	}
	
	//player is using cheats (most likely)
}

public ResetSpecWarn (playerid)
{
	specWarn[playerid] = 0;
	return 1;
}
Best thing to do in initial stages, send message to admin in the instance of this activating; then proceed to spectate to decide whether the system is adequate enough to detect the cheats.


Re: detect spec hack? - AbyssMorgan - 15.04.2017

The camera is away from the player, in mode 4 so high values are not allowed, also spectating player must be streamed.
http://i.imgur.com/Q5kgK3Q.png


Re: detect spec hack? - AbyssMorgan - 15.04.2017

PHP код:
stock bool:IsPlayerFakeSpectating(playerid,bool:force_disable=true){
    if(
GetPlayerState(playerid) == PLAYER_STATE_SPECTATING && IsPlayerAdmin(playerid)) return false//admins spectacing detect
    
if(GetPlayerCameraMode(playerid) != 4) return false;
    new 
Float:px,Float:py,Float:pz,Float:cx,Float:cy,Float:cz;
    
GetPlayerPos(playerid,px,py,pz);
    
GetPlayerCameraPos(playerid,cx,cy,cz);
    if(
VectorSize(px-cx,py-cy,pz-cz) < 20.0) return false;
    
    if(
force_disableSetCameraBehindPlayer(playerid);
    return 
true;