Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: MatheuS on Jan 06, 2015, 04:45 AM

Title: How to use this function?
Post by: MatheuS on Jan 06, 2015, 04:45 AM
someone can tell me how to use this function?

vehicle.Angle ?

use only when the function vehicle.Pos the angle goes wrong.
Title: Re: How to use this function?
Post by: Honey on Jan 06, 2015, 05:01 AM
Vehicle.Angle.x
Vehicle.Angle.y
Vehivle.Angle.z
Title: Re: How to use this function?
Post by: MatheuS on Jan 06, 2015, 07:16 AM
example? o.O
Title: Re: How to use this function?
Post by: Honey on Jan 06, 2015, 07:58 AM
I also had many problems using Vehicle.Angle because I thought that you can just set it like this Vehicle.Angle = 1; but this crashes the server. Then i went to the source code and studied it's parameters,

Here's how you use it :

player.Vehicle.Angle.x = 11.55;
player.Vehicle.Angle.y = 11.55;
player.Vehicle.Angle.x = 11.55;

OR

player.Vehicle.Angle = Quaternion( X, Y, Z, W ); The parameters should be in float

I used them to get vehicle angles from an ini so that the vehicle would move on it's own,. You can study my code here :

local coord = ReadIniString( "Files/Malibu.ini", "Position" + taxia[ plr.ID ].Malibu , "Pos" + taxia[ plr.ID ].Malibu );
local split1 = split( coord, " " );
plr.Vehicle.EulerRotation.x = split1[3].tofloat();
plr.Vehicle.EulerRotation.y = split1[4].tofloat();
plr.Vehicle.EulerRotation.z = split1[5].tofloat();
plr.Vehicle.Pos = Vector(split1[0].tofloat(), split1[1].tofloat(), split1[2].tofloat() );
taxia[ plr.ID ].Malibu++;
Title: Re: How to use this function?
Post by: . on Jan 06, 2015, 11:38 AM
Quote from: Honey on Jan 06, 2015, 07:58 AMI also had many problems using Vehicle.Angle because I thought that you can just set it like this Vehicle.Angle = 1; but this crashes the server.

You can't use that directly because Angle is a Quaternion and the Quaternion class doesn't have an implicit integer constructor. Actually I'm not sure if Squirrel uses implicit constructors. Your code would have to be explicit in order for that to work:
Vehicle.Angle = Quaternion(1, 1, 1, 1) // x, y, z, w
Title: Re: How to use this function?
Post by: MatheuS on Jan 06, 2015, 03:42 PM
local veh = player.Vehicle;
veh.Angle = Quaternion(0.864632, -0.000780538, -0.00151615, 0.502404);

more rotation is wrong, the car is down :o

I use "+ veh.Angle +" to get the coordinates (and an example of this)
Title: Re: How to use this function?
Post by: Honey on Jan 06, 2015, 04:10 PM
Try EulerRotation see example in my code.
Title: Re: How to use this function?
Post by: MatheuS on Jan 07, 2015, 05:33 AM
veh.EulerRotation.x = 0;
veh.EulerRotation.y = 0;
veh.EulerRotation.z = 1;

do not know why I used that's worked!