15.04.2017, 17:15
Someone who has some effective code against this trap they use to spy on other players
Thank you!
Thank you!
|
You can compare GetPlayerCameraPos with GetPlayerPos.
https://sampwiki.blast.hk/wiki/GetPlayerCameraPos https://sampwiki.blast.hk/wiki/GetPlayerPos |
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];
if(PosFinal[0] > 20 || PosFinal[0] < -20)
{
//cheat
}
if(PosFinal[1] > 20 || PosFinal[1] < -20)
{
//cheat
}
|
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 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;
}
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_disable) SetCameraBehindPlayer(playerid);
return true;
}