Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Honey on Oct 24, 2014, 11:09 AM

Title: Unexpected Vehicle Behaviour
Post by: Honey on Oct 24, 2014, 11:09 AM
Hello,

I was trying to make something similar to taxi server in VC but I'm having a weird problem.The Positions are stored properly and they should be loaded properly too but when i try to move a vehicle it starts to move up and down and behaves unexpectedly.



These are my positions : https://www.mediafire.com/?b31wzwxzze2906i
Title: Re: Unexpected Vehicle Behaviour
Post by: Thijn on Oct 24, 2014, 01:56 PM
We need some code.
Title: Re: Unexpected Vehicle Behaviour
Post by: Honey on Oct 25, 2014, 09:04 AM
Now i know some information about the vehicle angle but I have a new problem.When i try to change the direction of my vehicle through angles nothing happens and the vehicle spawns with its original angle )

local coord = ReadIniString( "Files/taxi.ini", "Position" + a, "Pos" + a );
local split1 = split( coord, " " );
local pos = Vector(split1[0].tofloat(), split1[1].tofloat(), 40.0000 );
plr.Vehicle.Angle.x = split1[3].tofloat()
plr.Vehicle.Angle.y = split1[4].tofloat()
plr.Vehicle.Angle.z = split1[5].tofloat()
plr.Vehicle.Angle.w = split1[6].tofloat()

plr.Vehicle.Pos = pos;
//plr.Vehicle.Pos = pos;
a++;

Part of my INI File( the first 3 are Vectors and others are quaternions )  :

[position0]
pos0                           = -295.1447 -481.5813 10.7936 0.6787 -0.0023 -0.0049 0.7344


[position1]
pos1                           = -295.1447 -481.5813 10.7936 0.6787 -0.0023 -0.0049 0.7344


[position2]
pos2                           = -295.1447 -481.5813 10.7936 0.6787 -0.0023 -0.0049 0.7344
Title: Re: Unexpected Vehicle Behaviour
Post by: Honey on Oct 28, 2014, 10:54 AM
Rebump! I tried to use radians but they do not change the vehicle angle either.
Title: Re: Unexpected Vehicle Behaviour
Post by: Gudio on Nov 01, 2014, 02:19 PM
I'd suggest you to save&read vehicle's speed with angle instead of vehicle positions. It will look smooth.
vehicle.Speed = saved vector speed;
vehicle.Angle = saved radians angle;
Title: Re: Unexpected Vehicle Behaviour
Post by: Honey on Nov 02, 2014, 06:23 AM
But the vehicle doesn't move according to the angle i save.As you can see in the INI file above player.Angle has 4 Quaternions but when I try to use them with Quaternion( x, y, z, w ) vehicle still moves in a wrong angle.
Title: Re: Unexpected Vehicle Behaviour
Post by: Gudio on Nov 02, 2014, 09:17 AM
Can you try to use EulerRotation?
Title: Re: Unexpected Vehicle Behaviour
Post by: Honey on Nov 02, 2014, 01:07 PM
I tried to use it but still doesn't work, :-\
Title: Re: Unexpected Vehicle Behaviour
Post by: MacTavish on Nov 18, 2014, 06:49 AM
Same problem for me suppose if our vehicle angle is in North side but in server it will spawn in East side

Also
My server.exe crash when ever i enter vehicle
Title: Re: Unexpected Vehicle Behaviour
Post by: Honey on Nov 18, 2014, 12:40 PM
@The Topic, I fixed this problem long ago but didn't bother to post :P, Therefore this topic is now Marked as "Solved", Thanks to Gudio.

@Rathore, The Vehicle Angles are retrieved in Angle.x, Angle.y and angle.z

so Here's what I Do to set my vehicle angle( I use Vehicle.EulerRotation ) :

/*There's no need to provide the whole code to understand how to set a vehicle angle so I am just going to show you a couple of lines. */

buscar.EulerRotation.x = split1[3].tofloat();
buscar.EulerRotation.y = split1[4].tofloat();
buscar.EulerRotation.z = split1[5].tofloat();

// Buscar is a variable for a vehicle,For players  You can use player.Vehicle.EulerRotation.
// As for Angles you can also use player.Vehicle.Angle.x, y, and z.

Btw, Thanks for Hijacking my topic.
Title: Re: Unexpected Vehicle Behaviour
Post by: Thijn on Nov 18, 2014, 08:37 PM
buscar.EulerRotation.x = ..
buscar.Vehicle.EulerRotation.y = ..

Are you sure?
Is buscar a player or a vehicle?
Title: Re: Unexpected Vehicle Behaviour
Post by: Honey on Nov 19, 2014, 04:11 AM
It's a global variable used for a vehicle, A Bus.

buscar <- CreateVehicle( 167, 0, Vector( -1448.63, -785.747, 14.2235 ),1, 0, 0 ) 
// buscar.Vehicle.EulerRotation.y was mispelled, I updated my post.