||09-26-2010 02:46 PM
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 :)
This method just uses 1 timer, meaning the health check is done for all players at the same time every 10 seconds. (untested)
-- 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
-- create a timer to call GiveSailorsHP() every 10 seconds, infinite amount of repeitions
createTimer("GiveSailorsHP", 10000, 0)
||09-27-2010 05:51 AM
Thnx verymuch Mex this works ecelent :)
|All times are GMT -6. The time now is 01:55 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2015, vBulletin Solutions, Inc.