Prevent AFK Drivers Bug -
Grimrandomer - 14.06.2012
There is a SA-MP bug, that when someone goes AFK in a vehicle, and a player who does not have them streamed in comes and gets in the car.
So when the other player is back from AFK, both players are driving the same vehicle ID, but different vehicles localy
While making my anti cheat system I saw that without preventing this bug, vehicle health cheat systems would be spammed and ban innocent players. Other hacks such as the CLEO cheats that make people very quickly be a vehicle driver to move the vehicle are also prevented by this system.
This can be both a Filter script or a game mode, as the only code used goes into OnPlayerUpdate
pawn Код:
#include <a_samp>
public OnFilterScriptInit() {
print("AFK Driver Protection Started");
return 1;
}
public OnFilterScriptExit() {
print("AFK Driver Protection Stopped");
return 1;
}
public OnPlayerUpdate(playerid) {
new playerState=GetPlayerState(playerid);
if (playerState == PLAYER_STATE_DRIVER) {
new vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid>0) {
for (new plid=0; plid<MAX_PLAYERS; plid++) {
if (plid!=playerid) {
if (IsPlayerConnected(plid)) {
if(!IsPlayerNPC(plid)) {
if (GetPlayerState(plid)==PLAYER_STATE_DRIVER) {
if (GetPlayerVehicleID(plid)==vehicleid) {
kick = true;
RemovePlayerFromVehicle(plid);
}
}
}
}
}
}
}
}
if (kick) RemovePlayerFromVehicle(playerid);
return 1;
}
Hopefully I have posted this in the right section, correct me if im wrong, Thanks.
AW: Prevent AFK Drivers Bug -
Nanory - 14.06.2012
What is with vehicleid 0 ?
if (vehicleid>0) {
should be:
if(vehicleid != INVALID_VEHICLE_ID)
Re: Prevent AFK Drivers Bug -
Master_Gangster - 14.06.2012
I agree with Nanory,
if(vehicleid != INVALID_VEHICLE_ID) is the appropriate code to check if the vehicle is valid.
Re: Prevent AFK Drivers Bug -
Littlehelper - 14.06.2012
I dont get it, what is this?
Re: Prevent AFK Drivers Bug -
Faisal_khan - 14.06.2012
Good work dude! Simple but nice and useful.
Re: Prevent AFK Drivers Bug -
Niko_boy - 14.06.2012
useful ,
i too developed a code for such abuser/lamer(s)
Re: Prevent AFK Drivers Bug -
Master_Gangster - 14.06.2012
Quote:
Originally Posted by Littlehelper[MDZ]
I dont get it, what is this?
|
As he stated in his topic:
Quote:
There is a SA-MP bug, that when someone goes AFK in a vehicle, and a player who does not have them streamed in comes and gets in the car, then the other player is back from AFK, both players are driving the same vehicle ID, but different vehicles locally.
|
Re: Prevent AFK Drivers Bug -
RedWingz - 14.06.2012
Nice work man, Simple but it's good.
Respuesta: AW: Prevent AFK Drivers Bug -
[DOG]irinel1996 - 14.06.2012
Quote:
Originally Posted by Nanory
What is with vehicleid 0 ?
if (vehicleid>0) {
should be:
if(vehicleid != INVALID_VEHICLE_ID)
|
In my opinion both ways are valid.
INVALID_VEHICLE_ID is
65535, I think.
Vehicles ids start from 1, try make a command to teleport to vehicle with ID 1000 just having 5 vehicles in your server and checking if the typed id isn't the same as
INVALID_VEHICLE_ID. For example:
pawn Код:
COMMAND:gotoveh(playerid, params[])
{
new veh_id;
if(sscanf(params,"d",veh_id)) return 1;
if(veh_id != INVALID_VEHICLE_ID)
{
//Teleport
} else { SendClientMessage(playerid,-1,"You won't get this message never"); }
return 1;
}
_______________________
Good idea, and good job.
As they say, I think the looping form isn't the best.
Best regards!
AW: Prevent AFK Drivers Bug -
Extremo - 14.06.2012
Quote:
Originally Posted by Nanory
What is with vehicleid 0 ?
if (vehicleid>0) {
should be:
if(vehicleid != INVALID_VEHICLE_ID)
|
That won't work because INVALID_VEHICLE_ID is 0xFFFF. However
GetPlayerVehicleID returns 0 if the player is not inside a vehicle. So if you were to check if the result is INVALID_VEHICLE_ID you'd always loop through the players even if they are not in a vehicle.
EDIT:
What you however could have mentioned is that if the state of the player is "PLAYER_STATE_DRIVER" he MUST be inside of a vehicle so how could it return 0?