Jump to content

Why not working this script?


Turbe$Z

Recommended Posts

function autostat(thePlayer)
	setPlayerStat(thePlayer, 24, 1000)
	setElementHealth(thePlayer, 255)
end
addEventHandler("onResourceStart", resourceRoot, autostat)

i got this warnings:
[22:09:28] WARNING: autostat\autostat.lua:2: Bad argument @ 'setPlayerStat' [Expected element at argument 1, got resource-data]
[22:09:34] WARNING: autostat\autostat.lua:3: Bad argument @ 'setElementHealth' [Expected element at argument 1, got resource-data]

Link to comment

onResourceStart
When a resource starts, the handler of that start will pass the passed resource as first parameter. There's no player to work with. You may want to loop all players and set the stats.

Note that setPlayerStat is deprecated.

Regarding setElementHealth, just to make sure you know: it will set the current HP, not the "stat" of health. Looking at the 2nd example of setPedStat can help you dealing with health values depending on variable max health stat.

Link to comment
function autostat()
  for i,v in ipairs(getElementsByType("player")) do
    setPedStat(v,24,1000)
    setElementHealth(v,255)
    end
  end
addEventHandler("onResourceStart",resourceRoot,autostat)

that should probably work as u wish

Edited by SuperCroz
  • Like 1
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...