Vehicle stuck in the air on SetVehiclePos
#1

Pretty simple, when I do /getcar the car is teleported successfully but it just stucks in the air until I jump at it, touch it. I've searched some old threads and I tried to start the vehicle engine on-off on teleport since someone said its a fix for it but its doing nothing. Any tips?

PHP Code:
CMD:getcar(playerid, params[]) {
  static 
vid;
  static 
Float:x, Float:y, Float:z;
  if(
admin1) return EmTag(playerid, YOU_HAVE_NO_PERMISSION);
  if(
sscanf(params, "i", vid)) return UsageTag(playerid, "/getcar[ID]");
  if(!
IsValidVehicle(vid)) return EmTag(playerid, "The specified vehicle ID is invalid!");
  
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
  
SetVehiclePos(vid, Float:x+2, Float:y+2, Float:z);
  return 
1;
} 
Reply
#2

Try with PutPlayerInVehicle
Reply
#3

Quote:
Originally Posted by v1k1nG
View Post
Try with PutPlayerInVehicle
Well thats a ghetto fix, Im sure with PutPlayerInVehicle its working. There is need to be another fix for this.
Reply
#4

PHP Code:
SetVehiclePos(vid, Float:x+2, Float:y+2, Float:z); 
those +2 are a ghetto fix too, even if I don't think that's related to your problem since your car gets moved in height (z axys, the one you didn't alterate). Try to /getcar while not too far from the vehicle, check how it behaves.
Reply
#5

Quote:
Originally Posted by v1k1nG
View Post
PHP Code:
SetVehiclePos(vid, Float:x+2, Float:y+2, Float:z); 
those +2 are a ghetto fix too, even if I don't think that's related to your problem since your car gets moved in height (z axys, the one you didn't alterate). Try to /getcar while not too far from the vehicle, check how it behaves.
Well its right next to me so still idk.
Reply
#6

This x+2 and y+2 will not work everytime.

That depends on, where you are look and standing.

The correct way, would to use it like this:

PHP Code:
CMD:getcar(playerid, params[]) { 
  new 
vid, Float:x, Float:y, Float:z, Float:a;
  if(
admin1) return EmTag(playerid, YOU_HAVE_NO_PERMISSION); 
  if(
sscanf(params, "i", vid)) return UsageTag(playerid, "/getcar[ID]"); 
  if(!
IsValidVehicle(vid)) return EmTag(playerid, "The specified vehicle ID is invalid!"); 
  
GetPlayerPos(playerid, x, y, z), GetPlayerFacingAngle(playerid, a);
  
x += 2.0 * floatsin(-a + 90.0, degrees);
  
y += 2.0 * floatcos(-a + 90.0, degrees);
  
SetVehiclePos(vid, x,y,z-1.0); 
  return 
1; 
} 
Besides, dont use static like that.
You dont need to reserve continous space...


Anyway the veh should sync better, if it touches the ground.
So set the z Axis a bit down, that should work.
But its a sync Problem...
Reply
#7

Just use colandreas/mapandres FindZ to set in on the ground. It won't be stuck after collision.
Reply
#8

Check the wiki. It says that if you set vehicles position it mostly will just be floating.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)