Krom Posted June 22, 2008 Share Posted June 22, 2008 ^ The function brings me headache, that's the problem. This: function Test(thePlayer) v=isVehicleOnGround(source) outputChatBox(tostring(v)) end addCommandHandler("g", Test) always returns "false", doesn't matter am I driving a car along the street, flying the helicopter or plane, taxiing it to takeoff or jumping down from Chilland in my infernus. Nothing matters. Then, I wonder why, but replacing Command Handler with Event Handler like: addEventHandler ( "onClientVehicleEnter", getRootElement(), setTimer(Test, 1000, 0 )) floods chatbox with "false" even when I'm out on any vehicles, but just spawned after reconnect. That's just two examples among 10 I've performed to reach better result. No success. Has anyone ever tried the function in work? I'm getting strong feeling that function just broken either non-finished or bugged or whatever else. Would be glad to listen to some nice advices here. Thank you. Link to comment
tma Posted June 22, 2008 Share Posted June 22, 2008 Try: function Test(thePlayer) v=isVehicleOnGround(getPlayerOccupiedVehicle(thePlayer)) outputChatBox(tostring(v)) end addCommandHandler("g", Test) Are you running this as client code ? If so it would be more like: function Test() v=isVehicleOnGround(getPlayerOccupiedVehicle(getLocalPlayer())) outputChatBox(tostring(v)) end Link to comment
Krom Posted June 23, 2008 Author Share Posted June 23, 2008 Thank you much, tma. Second one is just the one, I need. I thought that "Source" would be enough to get function know which one vehicle am I thinking about. By the way, can I do the same check in case of uncontrolled vehicle, if I have e.g. 10 vehicles and need to check which are on ground at the moment. Oh, one more, there's no way to make it work with elements (non-vehicles), right? Thought about making some aero-bombs, to put them in rustler. Link to comment
tma Posted June 23, 2008 Share Posted June 23, 2008 You can test it with any vehicle - controlled or not. I just added getPlayerOccupiedVehicle to your code because you weren't calling isVehicleOnGround() with a vehicle element. It's simple enough to apply this check to any/all vehicles e.g. (untested) for _,v in pairs(getElementsByType("vehicle")) do outputChatBox(tostring(isVehicleOnGround(v))) end AFAIK, it won't work with non-vehicles so you'll have to do your cluster bomb another way. There is a cluster bomb resource (or similar) so have a look how they've done it. 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