[FilterScript] Example Anti-Teleport Vehicle - 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: Filterscripts (
https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Example Anti-Teleport Vehicle (
/showthread.php?tid=272182)
Example Anti-Teleport Vehicle -
AirKite - 27.07.2011
This is Example Anti-Teleport Vehicle. (Anti-Cheat system).
Only SAMP 0.3c R3
Code:
/*
Example Anti-Teleport Vehicle
by AirKite
Not finished!!!
*/
new Float:OldVehiclePos[2000][4];
new LastCar[500];
#include <a_samp>
stock Float:GetDistanceBetweenPoints(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2)
{
return floatsqroot(floatpower(floatabs(floatsub(x2,x)),2)+floatpower(floatabs(floatsub(y2,y)),2)+floatpower(floatabs(floatsub(z2,z)),2));
}
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
{
new string[128], Float:vpos_x, Float:vpos_y, Float:vpos_z, Float:vpos_a;
GetVehiclePos(vehicleid, vpos_x, vpos_y, vpos_z); GetVehicleZAngle(vehicleid,vpos_a);
if(OldVehiclePos[vehicleid][0] != 0.0 && OldVehiclePos[vehicleid][1] != 0.0 && OldVehiclePos[vehicleid][2] != 0.0 && OldVehiclePos[vehicleid][3] != 0.0)
{
new Float:vehicledistance = GetDistanceBetweenPoints(vpos_x, vpos_y, vpos_z, OldVehiclePos[vehicleid][0], OldVehiclePos[vehicleid][1], OldVehiclePos[vehicleid][2]);
//format(string, sizeof(string), "Update Distance: %f", vehicledistance);
//SendClientMessage(playerid, 0xFFFFFFFF, string);
if(vehicledistance > 15.0)
{
SetVehiclePos(vehicleid, OldVehiclePos[vehicleid][0], OldVehiclePos[vehicleid][1], OldVehiclePos[vehicleid][2]);
SetVehicleZAngle(vehicleid,OldVehiclePos[vehicleid][3]);
return;
}
}
OldVehiclePos[vehicleid][0]=vpos_x;
OldVehiclePos[vehicleid][1]=vpos_y;
OldVehiclePos[vehicleid][2]=vpos_z;
OldVehiclePos[vehicleid][3]=vpos_a;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
LastCar[playerid]=GetPlayerVehicleID(playerid);
}
else if(oldstate == PLAYER_STATE_DRIVER)
{
new lastveh = LastCar[playerid];
GetVehiclePos(lastveh,OldVehiclePos[lastveh][0],OldVehiclePos[lastveh][1],OldVehiclePos[lastveh][2]);
GetVehicleZAngle(lastveh,OldVehiclePos[lastveh][3]);
}
return 1;
}
pastebin.com: http://pastebin.com/Xh3ZeNEw
AW: Example Anti-Teleport Vehicle -
Pablo Borsellino - 27.07.2011
Imitate!
It's also occurred to me yesterday, I have but wit Admin Warnings etc. and without Angle - thanks, now I have some Bug less in my Script!
Good Job!
Re: Example Anti-Teleport Vehicle -
JernejL - 27.07.2011
You need to track.. onvehiclespawn, setvehiclepos, onplayerupdate to track original coordinates too, otherwise this script will cause strange problems with vehicles respawning.
ALSO, make use of GetVehicleDistanceFromPoint to optimize code for speed better.
Re: Example Anti-Teleport Vehicle -
AirKite - 28.07.2011
I first show, example use for OnUnoccupiedVehicleUpdate