Jump to content

How to spawn vehicles via lua? PZ39

Recommended Posts



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






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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...