Author Topic: Getting the vehicle from it's spawn  (Read 1190 times)

Everything's working now. Thanks peeps.




(Note: I am aware that there was a similar topic made back in 2009. However this is still a problem)


Title says it all. I can't find a way to get the vehicle that a vehicle spawn brick owns.

Now, before you say
Quote from: Space Guy
%brick.vehicle
%brick.vehicleDatablock

Doing that returns an empty string, both in the console (%brick being replaced with the spawn bricks' id) and in code. Same with
Code: [Select]
%brick.getDatablock().vehicle
%brick.getDatablock().vehicleDatablock

Here's part of the script, where %brick = a fxDTSBrick.
Code: [Select]
echo(%brick.getId()); //Returns the spawn bricks' id
echo(%brick.getClassName());   //Returns fxDTSBrick
echo(%brick.vehicle); //Returns an empty string
echo(%brick.vehicleDatablock);       //Returns an empty string




If it helps, the code 'seemed' to work after about 20 minutes in single player, and '%brick.vehicle' accurately returned the vehicle's id. I would rather not wait 20 minutes and hope that this code works though...


Any ideas to what's going on?
« Last Edit: August 03, 2010, 09:46:58 PM by Snaily »

%brick.vehicle

Make sure the vehicle is spawned first.

%vehicle.spawnBrick

%brick.vehicle


Very funny.


Make sure the vehicle is spawned first.

%vehicle.spawnBrick

The vehicle is spawned. I don't need to get the spawn brick from the vehicle (although %vehicle.spawnBrick returns an empty string too).

Ya, I barely ready your post, didn't notice you mentioned it already.
« Last Edit: August 02, 2010, 10:54:03 AM by MegaScientifical »

Setting %brick in the console will most likely have its value erased if you try "%brick = 27801;" "echo(%brick.vehicle);".

Sorry, I'll stop posting. Everyone is being loud and annoying and stuff around me. I can't concentrate, but this shouldn't be a problem, so I don't get how you're making it one.

Setting %brick in the console will most likely have its value erased if you try "%brick = 27801;" "echo(%brick.vehicle);".

I didn't type %brick in the console. I listed serverConnection objects, found the spawn brick's id, and used that as a reference.

Something like this:
Code: [Select]
echo(27801.vehicle);

I didn't type %brick in the console. I listed serverConnection objects, found the spawn brick's id, and used that as a reference.

Something like this:
Code: [Select]
echo(27801.vehicle);

That's your problem. The ServerConnection doesn't take the variables, the server does. ServerConnection is your connection to the server. As host, you are just directly perceiving your server.

Also to get the ID of almost anything you can look at it and do "/getid" and it will return the id of the object :s

Also to get the ID of almost anything you can look at it and do "/getid" and it will return the id of the object :s

Ooh, forgot about that :P


Ok, thanks people, I think I found the problem: %brick didn't equal the vehicle spawn brick id. Now, I'm not sure why, but I can probably figure it out. If not, I'll post all the code up.

Thanks everyone.

I would do echo(_BrickNameHere.Vehicle);

I would do echo(_BrickNameHere.Vehicle);
Go away, you're not helping.

I didn't type %brick in the console. I listed serverConnection objects, found the spawn brick's id, and used that as a reference.

Something like this:
Code: [Select]
echo(27801.vehicle);

That's your problem. The ServerConnection doesn't take the variables, the server does. ServerConnection is your connection to the server. As host, you are just directly perceiving your server.

Okay, since you just completely f*cking ignored me, I will say again: You've been taking your Client-Side objects, not Server-Side. Even as the host, your ServerConnection technically works as a client. You have to get the Server-Side objects, because Client-Side objects don't get most of the data. They're just meant to display.

Do you hear me? You can't use ServerConnection to get the brick's information.

I'm aware, and I fixed the problem.
Everything's working now. Thanks peeps.

Go away, you're not helping.
Hey, I'm not that good at scripting.  I just whipped that up. Sheesh.