Little Help - 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: Little Help (
/showthread.php?tid=588718)
Little Help -
Sanady - 11.09.2015
Hello everybody, I made special weapon for my server, called shield, it`s DFT with attached objects, but problem is when player exit vehicle, player`s position changed too far from the truck, maybe it`s becouse of attached objects. So I found the way how to fix it, but problem is in that, that my fix doesn`t work. Here is the code, I don`t see anything wrong. Please check it
pawn Код:
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
new Float:X, Float:Y, Float:Z;
if(IsPlayerInVehicle(playerid, vehicleid1))
{
GetVehiclePos(vehicleid1, X, Y, Z);
SetPlayerPos(playerid, X, Y+5, Z);
}
else if(IsPlayerInVehicle(playerid, vehicleid2))
{
GetVehiclePos(vehicleid2, X, Y, Z);
SetPlayerPos(playerid, X, Y+5, Z);
}
}
Re: Little Help -
Crayder - 11.09.2015
The problem is obvious. You are not getting the players last vehicle. The IsPlayerInVehicle function is always going to return invalid because the player's state is already PLAYER_STATE_ONFOOT (he's no longer driving, so he's obviously not in a vehicle).