trying to do IsPlayerOnVehicle
#1

Does anyone know how i can detect if player is standing on vehicle. Not surfing, only standing
Reply
#2

Check this thread: https://sampforum.blast.hk/showthread.php?tid=453546
I think this impossible, What do you want to do?
Reply
#3

Quote:
Originally Posted by xRadical3
View Post
Check this thread: https://sampforum.blast.hk/showthread.php?tid=453546
I think this impossible, What do you want to do?
There is a SA:MP bug when you teleport to random location and players that are standing on your vehicle will teleport with you.
Reply
#4

Alternatively, you can use the SAMap plugin to retrieve the Z position (if the player is on the ground) and do it like that?
Reply
#5

Quote:
Originally Posted by ChampDotChamp
View Post
There is a SA:MP bug when you teleport to random location and players that are standing on your vehicle will teleport with you.
Maybe this method will help, I have no other idea.

1) Check if the player is in the vehicle.
2) If he is in a vehicle, save the model and coordinates then destroy the vehicle.
3) Create the vehicle after the player is teleported.
4) Put the player in the vehicle as driver.
That way, players are standing on vehicle won't teleport with driver.
Reply
#6

Quote:
Originally Posted by Runn3R
View Post
Alternatively, you can use the SAMap plugin to retrieve the Z position (if the player is on the ground) and do it like that?
But that has nothing to do with teleport ?

Quote:
Originally Posted by xRadical3
View Post
Maybe this method will help, I have no other idea.

1) Check if the player is in the vehicle.
2) If he is in a vehicle, save the model and coordinates then destroy the vehicle.
3) Create the vehicle after the player is teleported.
4) Put the player in the vehicle as driver.
That way, players are standing on vehicle won't teleport with driver.
I think this method is not optimized, because it takes a little time to destroy, create and than put players.
Some servers have check like this function IsPlayerOnVehicle(..);
Reply
#7

You have to use MapAndreas include by Ryder to get this in the working state..
pawn Code:
#include <mapandreas>

new jumping[MAX_PLAYERS];

native IsValidVehicle(vehicleid);

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
       if (PRESSED(KEY_JUMP))
       {
              jumping[playerid] = 1;
              SetTimerEx(JumpTimer, 1500, 0, "i", playerid);
       }
       return 1;
}

forward JumpTimer(playerid);
public JumpTimer(playerid)
{
     jumping[playerid] = 0;
     return 1;
}

stock IsPlayerOnVehicle(playerid) // By GameOvr, just made for you :D
{
       if(IsPlayerInAnyVehicle(playerid)) return 0;
       new Float:x, Float:y, Float:z, Float:px, Float:py, Float:pz, Float:Zval;
       GetPlayerPos(playerid, px, py, pz);
       for(new i = 0; i < MAX_VEHICLES; i++)
       {
              if(IsValidVehicle(i))
              {
                       GetVehiclePos(i, x, y, z);
                       if(IsPlayerInRangeOfPoint(playerid, x, y, z, 2) && !jumping[playerid])
                       {
                                GetPointZPos(px, py, Zval);
                                if(pz > Zval) return 1;
                       }
               }
      }
      return 0;
}
EDIT:I didnt test it or compile, if it's not working tell me
Reply
#8

Quote:
Originally Posted by GameOvr
View Post
You have to use MapAndreas include by Ryder to get this in the working state..
EDIT:I didnt test it or compile, if it's not working tell me
I changed your code because you had some mistakes. But, no help

pawn Code:
stock IsPlayerOnVehicle(playerid) // By GameOvr, just made for you :D
{
    if(IsPlayerInAnyVehicle(playerid)) return INVALID_VEHICLE_ID;

    new Float:x, Float:y, Float:z, Float:px, Float:py, Float:pz, Float:Zval;
    GetPlayerPos(playerid, px, py, pz);

    foreach(new i : Vehicle)
    {
        GetVehiclePos(i, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z) && jumping[playerid] == 0)
        {
            MapAndreas_FindZ_For2DCoord(px, py, Zval);
            if(pz > Zval) return i;
        }      
    }

    return INVALID_VEHICLE_ID;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)