30.12.2013, 20:16
(
Последний раз редактировалось dusk; 30.12.2013 в 21:03.
)
Hello, recently some annoying individuals teleported all unused vehicles to the same spot causing crashes for everyone near. And that got me where I am now.
I created(I believe I did) something that will help my server to avoid similiar situations.
I used the idea from this: https://sampforum.blast.hk/showthread.php?tid=272182 + the notes from JernejL in that same topic.
I want opinions. How effective will it be(if I will at all)?
I hooked the SetVehiclePos function
Funny, when a player exited the vehicle it would be set back to it's position...so I added this OnPlayerExitVehicle:
All feedback about the code will be appreciated.
(Now that I think about it, perhaps this should have been in the "Discussion" forum? But I'm actually asking for help, so I'll leave it here).
I created(I believe I did) something that will help my server to avoid similiar situations.
I used the idea from this: https://sampforum.blast.hk/showthread.php?tid=272182 + the notes from JernejL in that same topic.
I want opinions. How effective will it be(if I will at all)?
I hooked the SetVehiclePos function
pawn Код:
stock AC_SetVehiclePos(vehicleid,Float:x,Float:y,Float:z)
{
RealVehiclePositions[vehicleid][0] = x;
RealVehiclePositions[vehicleid][1] = y;
RealVehiclePositions[vehicleid][2] = z;
return SetVehiclePos(vehicleid, x, y, z);
}
#if defined _ALS_SetVehiclePos
#undef SetVehiclePos
#else
#define _ALS_SetVehiclePos
#endif
#define SetVehiclePos AC_SetVehiclePos
pawn Код:
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
{
new time = gettime();
if(time >LastVehicleACCheck[vehicleid])
{
LastVehicleACCheck[vehicleid] = time;
new Float:x,Float:y,Float:z;
GetVehiclePos(vehicleid, x, y, z);
if(RealVehiclePositions[vehicleid][0] == 0.0 && RealVehiclePositions[vehicleid][1] == 0.0 && RealVehiclePositions[vehicleid][2] == 0.0)
{
RealVehiclePositions[vehicleid][0] = x;
RealVehiclePositions[vehicleid][1] = y;
RealVehiclePositions[vehicleid][2] = z;
return;
}
new Float:distance = GetVehicleDistanceFromPoint(vehicleid,RealVehiclePositions[vehicleid][0],RealVehiclePositions[vehicleid][1],RealVehiclePositions[vehicleid][2]);
if(distance > MAX_VEHICLE_DISTANCE_CHANGE)
{
SetVehiclePos(vehicleid,RealVehiclePositions[vehicleid][0],RealVehiclePositions[vehicleid][1],RealVehiclePositions[vehicleid][2]);
}
RealVehiclePositions[vehicleid][0] = x;
RealVehiclePositions[vehicleid][1] = y;
RealVehiclePositions[vehicleid][2] = z;
}
return;
}
pawn Код:
new Float:x,Float:y,Float:z;
GetVehiclePos(vehicleid,x,y,z);
RealVehiclePositions[vehicleid][0] = x;
RealVehiclePositions[vehicleid][1] = y;
RealVehiclePositions[vehicleid][2] = z;
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new Float:x,Float:y,Float:z;
GetVehiclePos(vehicleid, x, y, z);
RealVehiclePositions[vehicleid][0] = x;
RealVehiclePositions[vehicleid][1] = y;
RealVehiclePositions[vehicleid][2] = z;
return 1;
}
(Now that I think about it, perhaps this should have been in the "Discussion" forum? But I'm actually asking for help, so I'll leave it here).