Jump to content

guiLabelSetColor Problem


=FAS=Shigawire

Recommended Posts

Posted

I do recall an oddity when you create GUI elements before onClientResourceStart is triggered. Try to create the GUI labels inside onClientResourceStart and let me know if it makes any difference.

Posted

EEhhm, how do you mean that?

I dont use Events in the Gui part

bullets = 0 
  
local health = guiCreateLabel ( 0.35, 0.025, 0.5, 0.5, "Bullets shot: " .. bullets .." ", true )  
  
bulletshit = 0 
  
local bhit = guiCreateLabel ( 0.45, 0.025, 0.5, 0.5, "Bullets hit: " .. bulletshit .." ", true ) 
  
local hitrtio = guiCreateLabel ( 0.55, 0.025, 0.5, 0.5, "Hit Ratio:  " .. bulletshit / bullets .. " ", true ) 
  
guiLabelSetColor ( health , 0, 0, 255 ) 
guiLabelSetColor ( bhit , 0, 144, 255 ) 
guiLabelSetColor ( hitrtio , 0, 144, 255 ) 
  
  
function bulletscheck (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
bullets = bullets + 1 
  
guiSetText ( health, "Bullets shot: " .. bullets .. "" ) 
  
--outputChatBox ("" ..getElementType(hitElement)) 
  
 if getElementType(hitElement) == "player" then 
  
bulletshit = bulletshit + 1 
  
guiSetText ( bhit, "Bullets hit: " .. bulletshit .. "" ) 
  
end 
  
guiSetText ( hitrtio, "Hit Ratio: " .. math.floor(0.5 + (bulletshit / bullets)*100) / 100 .. " " ) 
  
end 
  
addEventHandler ("onClientPlayerWeaponFire", getLocalPlayer(), bulletscheck, guiLabelSetColor ( health , 0, 0, 255 )) 
  
  
function resetCounter () 
bullets = 0 
bulletshit = 0 
  
guiSetText ( health, "Bullets shot: " .. bullets .. "" ) 
guiSetText ( bhit, "Bullets hit: " .. bulletshit .. "" ) 
guiSetText ( hitrtio, "Hit Ratio: " .. math.floor(0.5 + (bulletshit / bullets)*100) / 100 .. " " ) 
end 
addEventHandler ("onClientPlayerSpawn", getLocalPlayer(), resetCounter) 

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