TTT Posted January 7, 2009 Share Posted January 7, 2009 well this is my first script so i aint much.. and i has a little problem >.< when you type/getcar (id) then you get the car.. but when you leave the car then it doesnt dissappear or remove :'S function createVehicleForThePlayer(thePlayer, command, vehID) vehID = tonumber(vehID) local x,y,z = getElementPosition(thePlayer) newX = x + 5 createVehicle ( vehID, newX, y, z ) end addCommandHandler("getcar", createVehicleForThePlayer) Link to comment
Gamesnert Posted January 7, 2009 Share Posted January 7, 2009 Removing the vehicle doesn't happen by itself, you should script that. So let me help you a little. You may want to use these things: addEventHandler onVehicleExit destroyElement A quick hint: local vehicle=createVehicle ( vehID, newX, y, z ) --Save the vehicle, so the script knows which it is addEventHandler("onVehicleExit",vehicle,destroyThisVehicle) When using this piece, make a new function destroyThisVehicle, in which only vehicles spawned with this method will be destroyed. (with destroyElement) There's a clear reason why I did "local vehicle=...", because if you look in the addEventHandler, I'm actually using that variable. On this argument: Note that in destroyThisVehicle you can get the vehicle by typing source. This will get the vehicle the vehicle that triggered the event. Meaning the vehicle which one of the players exited. attachedTo: The element you wish to attach the handler to. The handler will only be called when the event it is attached to is triggered for this element, or one of its children. Often, this can be the root element (meaning the handler will be called when the event is triggered for any element). In this way, it will only trigger destroyThisVehicle if it's created by this code. Hope you understand it, and good luck. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now