Jump to content

Help me some Script


Evil-Cod3r

Recommended Posts

Hi all

i have idea i want Make a resource that

show the Players Name and there Health Only and get the Players team

example if iam team 1 and team 1 got Players can see the Name of there frinds and there Health

and team 2 the same

every team see there frinds info only

can any one give me the functions and events so i can start Make it ?

:D

Link to comment

is this right ?

local name = getPlayerName(getLocalPlayer()) 
local team = getPlayerTeam ( source ) 
local dm = getElementHealth ( getLocalPlayer() ) 
function hp () 
label1 = guiCreateLabel(1240,585,125,17,"Health :",false) 
guiLabelSetColor(label1,255,255,0) 
guiSetFont(label1,"clear-normal") 
guiSetText ( label1, dm, team ) 
setTimer ( hp, 2000, 1) 
end 
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), hp ) 

Link to comment

No.

First, a label gets created every time the local player spawns.. If he spawns 30 times, the screen will have 30 labels and the handle element for each will be lost

Secondly, you're using guiSetText with 3 arguments when it only has 2 and the second one should be a STRING.

Thirdly, guiSetText syntax aside, it is simply wrong because 'team' and 'dm' never really change. They are only called once when the script loads up.

Fourthly, but not least, the setTimer screws everything up even more.. (function called multiple times, see first, second and third points above)

Link to comment
label1 = guiCreateLabel(1240,585,125,17,"Health :",false) 
  
guiLabelSetColor(label1,255,255,0) 
guiSetFont(label1,"clear-normal") 
function hp () 
if getLocalPlayer()==source then 
local name = getPlayerName(getLocalPlayer()) 
local team = getPlayerTeam ( source ) 
team=getTeamName(team) 
local dm = getElementHealth ( getLocalPlayer() ) 
  
guiSetText ( label1,"Your name:  "..name.."  Your Team:  "..team.."  Your Health:  "..dm ) 
setTimer ( hp, 2000, 1) 
end 
end 
addEventHandler ( "onClientPlayerSpawn", getRootElement(), hp ) 

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