Join Date: Sep 2010
Sailor hp growing
im a beginner in lua and like to script growing hp for a sailor skin like they have in Vc.
i know it should be something like a timer but i dont know how.
the sailor needs to get 10% hp evry 10 seconds, but just like in singleplayer when the hp is 20 it nolonger growing. Can someone show me how to script this with timers?
thnx in advance
Join Date: Nov 2008
This method just uses 1 timer, meaning the health check is done for all players at the same time every 10 seconds. (untested)
function GiveSailorsHP() -- fetch highest possible player ID local b = getMaxPlayers() - 1 -- create local variables outside the loop to hold data for the players local SkinID, Health, NewHealth -- loop around all possible player IDs for a=0, b do -- check if player is connected and spawned if isPlayerConnected(a) == 1 and isPlayerSpawned(a) == 1 then -- fetch player skin SkinID = getPlayerSkin(a) -- check player is using sailor skin if SkinID == 134 or SkinID == 135 or SkinID == 136 then -- fetch player health Health = getPlayerHealth(a) -- check player's health is more than 20, and less than 100 if Health > 20 and Health < 100 then -- work out new health NewHealth = Health * 1.1 -- if new health is more than 100, change it to 100 if NewHealth > 100 then NewHealth = 100 end -- set player's new health setPlayerHealth(a, NewHealth) end end end end end -- create a timer to call GiveSailorsHP() every 10 seconds, infinite amount of repeitions createTimer("GiveSailorsHP", 10000, 0)
|Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)|