Jump to content

How to spawn vehicles via lua? PZ39


ddraigcymraeg

Recommended Posts

Hi,

 

Im trying to spawn vehicles in lua, preferably at a set x,y,z. 

 

AddVehicle()

or

AddVehicle("Base.PickUpVan") 

 

This method looks to be available to lua, but whenever I call it, I get "Object tried to call nil" 

I noticed with:  addAllVehicles() that I seemed to have more luck in testing, I got the messages: "....not spawned, position invalid.." which meant the function actually got called... but my location was in a building which is probably why nothing spawned.

 

from this thread, I see that you should be able to do in MP:  /addvehicle "Base.VanSpiffo" "x,y,z"

 

So calling this code as well does not work: SendCommandToServer("/addvehicle \"" .. "Base.VanSpiffo" .. "\" \"" .. square:getX()..","..square:getY()..","..square:getZ() .. "\"")

Not sure what is going on.... I got the same error with SendCommandToServer("/invisible");

Caused by: java.lang.NullPointerException
    at zombie.network.GameClient.SendCommandToServer(GameClient.java:1802)
    at zombie.Lua.LuaManager$GlobalObject.SendCommandToServer(LuaManager.java:4344)

 

 

So maybe this only works in an MP game... 

 

Any ideas how to spawn a car in an SP (and MP) game at a specific x,y,z? 

 

also tried: square:AddWorldInventoryItem("Base.VanSpiffo", 0.0, 0.0, 0.0); to be sure, but of course that did not work either. :-)

 

Thank you in advance.

 

 

Edited by ddraigcymraeg
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...