GrubaS Posted February 26, 2015 Share Posted February 26, 2015 Hello, Debug 3: " Bad argument @ 'setElementHealth" [Expected element at argument 1, got number '0'] " whats wrong? setTimer ( function ( player ) for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do if isElementInWater ( vehicle ) then setElementHealth(0) end end end , 1000, 0 ) Link to comment
LaCosTa Posted February 26, 2015 Share Posted February 26, 2015 read the function arguments on the wiki , it's setElementHealth(theElement , health ) so it should be like this setElementHealth(vehicle,0) Link to comment
JR10 Posted February 26, 2015 Share Posted February 26, 2015 It's kinda obvious, you should familiarize yourself with the error message a bit more. setElementHealth has two parameters, a userdata value representing the element and a float representing the health. You only sent the health. It should be: setElementHealth(player, 0) Another problem with your code is that you don't really send the player argument, so player won't be defined in the function. Refer to the wiki for the syntax of each function. The overall logic of your code is kinda wrong. I'm assuming you want to detect when a player is inside a vehicle in water, your code gets all the vehicles and not the one the player is in. If you still need help then explain more what your code should do. Link to comment
Max+ Posted February 26, 2015 Share Posted February 26, 2015 why do you use ( player ) inside function while you want to set the health of the vehicle remove this , ( player ) and do it like this , setElementHealth(vehicle, 0) or use destroyElement Link to comment
JR10 Posted February 26, 2015 Share Posted February 26, 2015 I'm assuming he wants something like in the race gamemode, when the player's vehicle falls in water he dies. Link to comment
Max+ Posted February 26, 2015 Share Posted February 26, 2015 I'm assuming he wants something like in the race gamemode, when the player's vehicle falls in water he dies. Yeah , i think so to , Well He can use something like this , setTimer ( function ( ) for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do if isElementInWater ( vehicle ) then blowVehicle ( vehicle, true ) end end end , 10000, 0 ) it well check all vehicle in water every 10 sec and blow them up . Link to comment
JR10 Posted February 26, 2015 Share Posted February 26, 2015 Killing the player would be better, I find blowing a vehicle when it falls in water undesirable. 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