Jump to content

[HELP]


GrubaS

Recommended Posts

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

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
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...