Jump to content

Script Error..need help


Recommended Posts

I made this script to make the player Lay and set his health +5 every 4 seconds...but i got an error..please help

Server:

function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer, Lay_Bac_Loop) 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

ERROR Line:

ERROR: Health\Health.lua:3: attempt to call global 'getPedAnimation' (a nil value) 

Please help me guys :) ... and THANKS alot

Link to comment

try this now

function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer, "Lay_Bac_Loop") 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

Link to comment
try this now
function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer, "Lay_Bac_Loop") 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

Okay gonna try and tell you

Link to comment
try this now
function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer, "Lay_Bac_Loop") 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

Okay gonna try and tell you

Da same ERROR

    ERROR: Health\Health.lua:3: attempt to call global 'getPedAnimation' (a nil value) 

Link to comment

my bad:

try this

function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer) 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

Link to comment
my bad:

try this

function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer) 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

Gonna try

Link to comment
my bad:

try this

function setHealth (theplayer) 
  
local Ganim = getPedAnimation (theplayer) 
local health = getElementHealth(theplayer) 
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 
  
if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
        setPedAnimation(theplayer,false) 
    else 
        setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
end 
if Ganim then 
setElementHealth ( player, health +5) 
    end 
end 
setTimer(setHealth, 4000, 1) 
addCommandHandler ("relax", setHealth) 

Gonna try

The same Problem man :( Check it again....also i feel like there's a problem with SetTimer because i just wanted the health up every 4 sec so i puted this Timer :/...fix it if you can..And THANKS ALOT!

Link to comment
Also replace
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 

with

local daAnim = getElementData(theplayer, "animz") 
local daBlockz = getElementData(theplayer, "blockz") 

    function setHealth (theplayer) 
      
    local daAnim = getElementData(theplayer, "animz") 
    local daBlockz = getElementData(theplayer, "blockz") 
    local daAnim = getElementData(root, "animz") 
    local daBlockz = getElementData(root, "blockz") 
      
    if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
            setPedAnimation(theplayer,false) 
        else 
            setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
    end 
    if Ganim then 
    setElementHealth ( player, health +5) 
        end 
    end 
    setTimer(setHealth, 4000, 1) 
    addCommandHandler ("relax", setHealth) 

ERRORS!

 Bad argument @ 'getElementData' [Expected element at argument 1, got nil] 

 Bad argument @ 'getElementData' [Expected element at argument 1, got nil] 

Warrning: :11: Bad argument @ 'setPedAnimation' 

Link to comment
Also replace
local daAnim = getElementData(root, "animz") 
local daBlockz = getElementData(root, "blockz") 

with

local daAnim = getElementData(theplayer, "animz") 
local daBlockz = getElementData(theplayer, "blockz") 

script:

    function setHealth (theplayer) 
      
    local Ganim = getPedAnimation (theplayer) 
    local health = getElementHealth(theplayer) 
    local daAnim = getElementData(theplayer, "animz") 
    local daBlockz = getElementData(theplayer, "blockz") 
      
    if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
            setPedAnimation(theplayer,false) 
        else 
            setPedAnimation (theplayer, "LAYING", "Lay_Bac_Loop") 
    end 
    if Ganim then 
    setElementHealth ( player, health +5) 
        end 
    end 
    setTimer(setHealth, 4000, 1) 
    addCommandHandler ("relax", setHealth) 

ERROR:

 attempt to call global 'getPedAnimation' ( a nil value) 

Link to comment

try

-- Client Side 
    function setHealth ( ) 
      
    local Ganim = getPedAnimation (localPlayer) 
    local health = getElementHealth(localPlayer) 
    local daAnim = getElementData(root, "animz") 
    local daBlockz = getElementData(root, "blockz") 
      
        if daBlockz == "Laying" and daAnimz == "Lay_Bac_Loop" then 
                setPedAnimation(localPlayer,false) 
            else 
                setPedAnimation (localPlayer, "LAYING", "Lay_Bac_Loop") 
        end 
            if Ganim then 
            setElementHealth ( localPlayer, health +5) 
            end 
    end 
    setTimer(setHealth, 4000, 1) 
    addCommandHandler ("relax", setHealth) 

some Mistakes Solved.

cheak for the Example 2 Client side

https://wiki.multitheftauto.com/wiki/SetPedAnimation

look at setElementData

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