Old 09-26-2010   #1
[TTH]BiZkiT
Registered User
 
Join Date: Sep 2010
Posts: 11
[TTH]BiZkiT is on a distinguished road[TTH]BiZkiT is on a distinguished road
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
[TTH]BiZkiT is offline   Reply With Quote
Old 09-26-2010   #2
Mex
Registered User
 
Join Date: Nov 2008
Posts: 44
Mex is on a distinguished roadMex is on a distinguished roadMex is on a distinguished road
This method just uses 1 timer, meaning the health check is done for all players at the same time every 10 seconds. (untested)

Code:
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)
Mex is offline   Reply With Quote
Old 09-27-2010   #3
[TTH]BiZkiT
Registered User
 
Join Date: Sep 2010
Posts: 11
[TTH]BiZkiT is on a distinguished road[TTH]BiZkiT is on a distinguished road
Thnx verymuch Mex this works ecelent
[TTH]BiZkiT is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -6. The time now is 12:46 PM.