CreateVehicle issues

Started by Mötley, May 13, 2016, 04:00 PM

Previous topic - Next topic

Mötley

http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/CreateVehicle

Okay I am converting vehicles over to onScriptLoad so I can remove cars from the xml as well be cappable of having a command to add the vehicle info to file(pos, angle, etc).

The version I am using is
CreateVehicle(model, Vector(x.tofloat(), y.tofloat(), z.tofloat()), angle.tofloat(), col1, col2);

When I add in vehicles from the ini file there position is off.
and the outcome is

CreateVehicle("+player.Vehicle.Model+", "+player.Vehicle.Pos.x+", "+player.Vehicle.Pos.y+", "+player.Vehicle.Pos.z+", "+player.Vehicle.Angle+", -1, -1);I will then get the outcome of

[vehicles]
159                            = CreateVehicle(159, 489.287, -507.997, 10.6818, (2.57802e-005, -4.6761e-005, 0.0177964, 0.999842), -1, -1)
158                            = CreateVehicle(158, 495.452, -520.251, 11.1376, (0.000181303, 9.85927e-005, -0.878657, 0.477454), -1, -1);

The command is

  if (cmd == "vsave") {
     
    if (player.Vehicle) {
      WriteIniString("Cars.ini", "Vehicles", ""+player.Vehicle.Model+"", "CreateVehicle("+player.Vehicle.Model+", "+player.Vehicle.Pos.x+", "+player.Vehicle.Pos.y+", "+player.Vehicle.Pos.z+", "+player.Vehicle.Angle+", -1, -1);
      print("CreateVehicle("+player.Vehicle.Model+", "+player.Vehicle.Pos.x+", "+player.Vehicle.Pos.y+", "+player.Vehicle.Pos.z+", "+player.Vehicle.Angle+", -1, -1); "+text);
    }
    return true;
  } 

The print as well returns

CreateVehicle(158, 495.452, -520.251, 11.1376, (0.000181303, 9.85927e-005, -0.878657, 0.477454), -1, -1); 
Some help with this would be liked!
Also if you know of better ways to store the vehicle info, basically so when I get the time to copy and paste the vehicle locations they will be perfect. The setting I am using now will just erase any vehicle with the same model ID.
I know the mistakes are small and I am just tired of fooling with it.

Mötley

I have tried all of the other methods from. Other users for the broken vehicle.Angle code but doesn't really help . And or I am doing it wrong .

I want to keep the code as close as possible to
   CreateVehicle("+player.Vehicle.Model+", "+player.Vehicle.Pos.x+", "+player.Vehicle.Pos.y+", "+player.Vehicle.Pos.z+", "+player.Vehicle.Angle+", -1, -1);
 

So any help is thanked!

KAKAN

Dunno what you're trying to say, but by looking at your code, I can say that the postion should be a float and not a string, same for angle. And the color can't be -1
oh no

Mötley

Yes I actually created a function to clear that up so when the car is created its converted to.tofloat()  I can use player.Angle to an extent but it's not the proper way. What I need Is a fix for player.Vehicle.Angle..

But I can't seem to alter the code to print the correct angle.. I know this is a common issue. It's part of a release I am working on..

KAKAN

oh no

Mötley

@KAKAN It does n0t work. as well as create's errors in the class. I will have to look into other methods,. Shame Vehicle.Angle is broken with faults

Cool

why you dont use kusnangi vehicle system

Mötley

#7

KAKAN

Quote from: Mötley on May 15, 2016, 11:07 PM@KAKAN It does n0t work. as well as create's errors in the class. I will have to look into other methods,. Shame Vehicle.Angle is broken with faults
Do you know how to use that even?
And also, vehicle.Angle is not broken, I think it returns a Quaternion.
oh no

Mötley

Yes it does return Quaternion,

what I am referring to as in angle is the same method as player.Angle but for cars.

I understand that script. But I find the method to be not proper and uses to much when I need to keep the build very simple.

KAKAN

Quote from: Mötley on May 16, 2016, 02:06 AMI understand that script. But I find the method to be not proper and uses to much when I need to keep the build very simple.
Can't get it. Care to explain? You don't want to use it because it seems complex? It's simple :P
oh no

Mötley

#11
I know that its simple,
but If i add that to a release for newbies They would never understand it.
It would appear to look like nuclear codes to them.
I need it to be simple so thats why this was such an issue and a delay



KAKAN

Quote from: Mötley on May 16, 2016, 02:31 AMI know that its simple,
but If i add that to a release for newbies They would never understand it.
It would appear to look like nuclear codes to them.
I need it to be simple so thats why this was such an issue and a delay
Here, the newbies won't even care what you have done. They will just download the script and run.
oh no