Jump to content

setPlayerNameTagShowing/Text


Absence2

Recommended Posts

Hey, I'm working on this Admin skin thing for my event system, would this show a nametag saying "Admin" on whoever used this command? And can I make it visible for myself?

function setAdminSkin (thePlayer) 
    if (exports.global:isPlayerFullAdmin(thePlayer)) then 
            setPedSkin ( thePlayer, 0 ) 
            setPedStat(thePlayer, 23, 700) 
        setPlayerNametagShowing( root, true ) 
        setPlayerNametagText ( root, Admin, true ) 
            addPedClothes ( thePlayer, "tshirtproblk", "tshirt", 20 ) 
            addPedClothes ( thePlayer, "player_face", "head", 1 ) 
            addPedClothes ( thePlayer, "worktrcamogrn", "worktr", 2 ) 
            addPedClothes ( thePlayer, "convproblk", "conv", 3 ) 
            addPedClothes ( thePlayer, "neckdollar", "neck", 13 ) 
            addPedClothes ( thePlayer, "watchcro2", "watch", 14 ) 
            addPedClothes ( thePlayer, "boaterblk", "boater", 15 ) 
    end 
end 
addCommandHandler ( "askin", setAdminSkin) 

Link to comment

setPlayerNametagText use in client side if you want show only you.

setPlayerNametagText ( root, Admin, true ) 

Admin is defined variable?

And why you use 3 arguments if have only 2.

Also root not work here ( tested in run code and return false :/ ). You should loop player elements and set name tag text .

Edited by Guest
Link to comment
setPlayerNametagText use in client side if you want show only you.
setPlayerNametagText ( root, Admin, true ) 

Admin is defined variable?

And why you use 3 arguments if have only 2.

#1 Nop, I was trying to set the text to 'Admin' but I think I covered that one.

#2 I tested, sorry. I thought it would show if true and hide > false as without it didn't work, I re-checked on wiki and noticed that I did wrong.

anyways, I got this now:

Server:

function setAdminSkin (thePlayer) 
    if (exports.global:isPlayerFullAdmin(thePlayer)) then 
            setPedSkin ( thePlayer, 0 ) 
            setPedStat(thePlayer, 23, 700) 
        setPlayerNametagShowing( root, true ) 
triggerClientEvent ( "tagName", getRootElement() ) 
            addPedClothes ( thePlayer, "tshirtproblk", "tshirt", 20 ) 
            addPedClothes ( thePlayer, "player_face", "head", 1 ) 
            addPedClothes ( thePlayer, "worktrcamogrn", "worktr", 2 ) 
            addPedClothes ( thePlayer, "convproblk", "conv", 3 ) 
            addPedClothes ( thePlayer, "neckdollar", "neck", 13 ) 
            addPedClothes ( thePlayer, "watchcro2", "watch", 14 ) 
            addPedClothes ( thePlayer, "boaterblk", "boater", 15 ) 
    end 
end 
addCommandHandler ( "askin", setAdminSkin) 
  

client:

function tagAdminEvent () 
        setPlayerNametagText ( root, "STAFF") 
end 
addEvent ( "tagName", true ) 
addEventHandler( "tagName", getRootElement(), tagAdminEvent ) 

No nametag is showing though

Link to comment
function setAdminSkin ( thePlayer ) 
    if exports.global:isPlayerFullAdmin( thePlayer ) then 
        setElementModel ( thePlayer, 0 ) 
        setPedStat( thePlayer, 23, 700 ) 
        setPlayerNametagText ( thePlayer, 'STAFF' ) 
        setPlayerNametagShowing( thePlayer, true ) 
        addPedClothes ( thePlayer, 'tshirtproblk', 'tshirt', 20 ) 
        addPedClothes ( thePlayer, 'player_face', 'head', 1 ) 
        addPedClothes ( thePlayer, 'worktrcamogrn', 'worktr', 2 ) 
        addPedClothes ( thePlayer, 'convproblk', 'conv', 3 ) 
        addPedClothes ( thePlayer, 'neckdollar', 'neck', 13 ) 
        addPedClothes ( thePlayer, 'watchcro2', 'watch', 14 ) 
        addPedClothes ( thePlayer, 'boaterblk', 'boater', 15 ) 
    end 
end 
addCommandHandler ( 'askin', setAdminSkin ) 
  

Ah forgot.

It's change your nametag so you can't see nick name, but all see.

Edited by Guest
Link to comment
No problem.

Also in wiki have example

https://wiki.multitheftauto.com/wiki/GetPedBonePosition

You can use it.

It draw nick name on the head.

And you can see your nickname.

I noticed that the setPlayerNametagText affects my "custom" nametags so that's great! So I remade most of it into this:

function setAdminSkin ( thePlayer ) 
local playerName = getPlayerName 
    if exports.global:isPlayerFullAdmin( thePlayer ) then 
        setElementModel ( thePlayer, 29 ) 
        setPlayerNametagText ( thePlayer, '" .. playerName .. " (ADMIN)' ) 
    end 
end 
addCommandHandler ( 'askin', setAdminSkin ) 
  

this seems to show the name ONLY,but not (ADMIN) =/

supposed to be: Idjot_Idjot (Admin)

Link to comment
function setAdminSkin ( thePlayer ) 
    if exports.global:isPlayerFullAdmin( thePlayer ) then 
local playerName = getPlayerName(thePlayer) 
        setElementModel ( thePlayer, 29 ) 
        setPlayerNametagText ( thePlayer, playerName .. " (ADMIN)" ) 
    end 
end 
addCommandHandler ( 'askin', setAdminSkin ) 
  
  

Link to comment
function setAdminSkin ( thePlayer ) 
    if exports.global:isPlayerFullAdmin( thePlayer ) then 
local playerName = getPlayerName(thePlayer) 
        setElementModel ( thePlayer, 29 ) 
        setPlayerNametagText ( thePlayer, playerName .. " (ADMIN)" ) 
    end 
end 
addCommandHandler ( 'askin', setAdminSkin ) 
  
  

Oh, I see, that did work, thanks :)

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