Jump to content

setElementHealth and setPedArmor [SOLVED]


DRW

Recommended Posts

addEventHandler ("onPlayerLogin", root, 
    function(prev,cur) 
        if isObjectInACLGroup ("user."..getAccountName(cur), aclGetGroup ( "Reg1" ) ) then 
        setTimer (function(player) 
            setElementHealth (player, getElementHealth (player)+2) 
        end, 2000, 0,source) 
    end 
end) 
  
addEventHandler ("onPlayerLogin", root, 
    function(prev,cur) 
        if isObjectInACLGroup ("user."..getAccountName(cur), aclGetGroup ( "Reg2" ) ) then 
        setTimer (function(player) 
            setPedArmor (player, getPedArmor (player)+2) 
        end, 2000, 0,source) 
    end 
end) 
         

Hello, I made this thing so people in an expected acl group could have health regen, the script works but it spams all the time this to the console:

[2015-06-07 06:37:27] WARNING: zps\script.lua:15: Bad argument @ 'getElementHealth' [Expected element at argument 1]

[2015-06-07 06:37:27] ERROR: zps\script.lua:15: attempt to perform arithmetic on a boolean value

[2015-06-07 06:37:27] WARNING: zps\script.lua:24: Bad argument @ 'getPedArmor' [Expected ped at argument 1]

[2015-06-07 06:37:27] ERROR: zps\script.lua:24: attempt to perform arithmetic on a boolean value

What can I do?

Edited by Guest
Link to comment
Use source instead.

Now it works with armor, but look

[2015-06-07 06:53:47] WARNING: zps\script.lua:15: Bad argument @ 'getElementHealth' [Expected element at argument 1, got nil]

[2015-06-07 06:53:47] ERROR: zps\script.lua:15: attempt to perform arithmetic on a boolean value

Link to comment
hTable = {} 
aTable = {} 
  
addEventHandler("onPlayerLogin", root, 
function(prev, cur) 
    if isObjectInACLGroup ("user."..getAccountName(cur), aclGetGroup("Reg1")) then 
        hTable[source] = setTimer(function(player) 
            if isElement(player) then 
                setElementHealth(player, getElementHealth(player)+2) 
            else 
                if isTimer(hTable[player]) then 
                    killTimer(hTable[player]) 
                    hTable[player] = nil 
                end 
            end 
        end, 2000, 0, source) 
    end 
    if isObjectInACLGroup("user."..getAccountName(cur), aclGetGroup("Reg2")) then 
        aTable[source] = setTimer(function(player) 
            if isElement(player) then 
                setPedArmor(player, getPedArmor(player)+2) 
            else 
                if isTimer(aTable[player]) then 
                    killTimer(aTable[player]) 
                    aTable[player] = nil 
                end 
            end 
        end, 2000, 0, source) 
    end 
end) 

Link to comment
hTable = {} 
aTable = {} 
  
addEventHandler("onPlayerLogin", root, 
function(prev, cur) 
    if isObjectInACLGroup ("user."..getAccountName(cur), aclGetGroup("Reg1")) then 
        hTable[source] = setTimer(function(player) 
            if isElement(player) then 
                setElementHealth(player, getElementHealth(player)+2) 
            else 
                if isTimer(hTable[player]) then 
                    killTimer(hTable[player]) 
                    hTable[player] = nil 
                end 
            end 
        end, 2000, 0, source) 
    end 
    if isObjectInACLGroup("user."..getAccountName(cur), aclGetGroup("Reg2")) then 
        aTable[source] = setTimer(function(player) 
            if isElement(player) then 
                setPedArmor(player, getPedArmor(player)+2) 
            else 
                if isTimer(aTable[player]) then 
                    killTimer(aTable[player]) 
                    aTable[player] = nil 
                end 
            end 
        end, 2000, 0, source) 
    end 
end) 

Perfect, thanks!!

Link to comment

start to set vest when I already 100% or 200% health

one can set this to me? please

hTable = {} 
aTable = {} 
  
addEventHandler("onPlayerLogin", root, 
function(prev, cur) 
    if isObjectInACLGroup ("user."..getAccountName(cur), aclGetGroup("Reg1")) then 
        hTable[source] = setTimer(function(player) 
            if isElement(player) then 
                setElementHealth(player, getElementHealth(player)+2) 
            else 
                if isTimer(hTable[player]) then 
                    killTimer(hTable[player]) 
                    hTable[player] = nil 
                end 
            end 
        end, 2000, 0, source) 
    end 
    if isObjectInACLGroup("user."..getAccountName(cur), aclGetGroup("Reg2")) then 
        aTable[source] = setTimer(function(player) 
            if isElement(player) then 
                setPedArmor(player, getPedArmor(player)+2) 
            else 
                if isTimer(aTable[player]) then 
                    killTimer(aTable[player]) 
                    aTable[player] = nil 
                end 
            end 
        end, 2000, 0, source) 
    end 
end) 

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