Jump to content

Nametag error!


MisterQuestions

Recommended Posts

Posted

Hi, on this time i want to show player team over nick, but what is wrong, if dont get the player team, should appear a random phrase how to do it?

Client-Side

                     
local team = getElementData(player, "team") or " " 
dxDrawText (team.." \n"..getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, raceInterface.font, "center", "bottom", false, false, false, true ) 

Server-Side

addEventHandler( 'onPlayerLogin', root, 
    function ( ) 
        team = getPlayerTeam(source) 
        setElementData(source, "team", team)             
    end 
) 
  
addEventHandler( 'onPlayerQuit', root, 
function ( ) 
local team = getElementData(source, "team") 
    if team then 
        removeElementData(source,"team") 
    end 
end) 
  

How to do it?

Posted

The problem here is that teams will not be saved so getPlayerTeam when the player login will return nil use

setAccountData -- when the player quit to save the team and use 
getAccountData -- when the player join to get this team 

Posted
I dont like to leave him in dark i like to help others

... I never said anything about something about or even something referring to this.

--

Anyway, I posted a wrong code. I meant just use this:

local team = getPlayerTeam(player) 
if (team ~= false) and (team ~= nil) then 
    team = getTeamName(team) 
end 
if (team == false) or (team == nil) then 
    team = "N/A" 
end 

As soon as a player gets placed into a team, it will draw the team above the nickname.

Posted

You actually don't need to remove element data because once player leaves the server then element data is set to nil or simply it's lost.

Posted

Mmm error?

why?

this is the nametags draw text...

dxDrawText (getPlayerTeam(player)" \n"..getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, raceInterface.font, "center", "bottom", false, false, false, true ) 

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