Jump to content

Nicknames


Piorun

Recommended Posts

Hi!

I've got next problem. I want to create some function like this:

local localPlayer = getLocalPlayer ( )
 
function test ( )
addEventHandler( "onClientRender", getRootElement(),
function( )
local px, py, pz = getElementPosition ( localPlayer )
local x, y, z = getScreenFromWorldPosition( px, py, pz+1 );
if x then
        example = dxDrawText( "Imię Nazwisko", x, y );
end
end
)
end
addEventHandler ( "onClientPlayerJoin", getLocalPlayer(), test )

How it should work?

When player join into the server this function should create a Text and show this text at the top of head. With "addCommandHandler" it's work. Any sugestions?

Link to comment

onClientPlayerJoin will NEVER be triggered for local player.. This can be use on local player to do something on ANY player join, but not local player.

Why?

Becouse first you join the server, then download scripts. When scripts got run - you are already joined for few secounds..

This is popular mistake.

Use onClientResourceStart instead

And don't forget to attach it to getResourceRootElement(getThisResource()) instead of getRootElement() :)

ps. I'm almost sure that you can't draw Polish letters like "ę"

ps2. Notice that on wiki page of onClientPlayerJoin there is text: "It is triggered for all players other than the local player.". Read carefully next time :)

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