Jump to content

text display


Recommended Posts

hey there, i was just checking the wiki and wanted to do somthing with this text display functions, and i tryed to do somthing like if u do the cmd /text ..mytext.. will print in player screen what i typed, but i failed while trying so i will like to know if someone can give me a hand with this,

server side:

local myTextDisplay = textCreateDisplay ()
myTextItem = textCreateTextItem ( mytext, .5, .5, "low", 255, 0, 0, 150, 4.0, "center" )
 
function test( player, mytext )
textDisplayAddObserver ( myTextDisplay, player )
setTimer ( textDisplayRemoveObserver, 3000, 1, myTextDisplay, player )
textDisplayAddText ( myTextDisplay, myTextItem )
end
addEvent("ownText", true)
addEventHandler( "ownText",getRootElement(), test )

client side:

function drawText ( playerSource, mytext )
if(mytext) then
triggerServerEvent ( "ownText", getRootElement(), mytext )
end
end
addCommandHandler ( "text", drawText )

greetings

Link to comment

ok well i did that but now dosnt work and dosnt give me any error/warning in debug scipt :?

function drawText ( mytext )
if(mytext) then
triggerServerEvent ( "ownText", getRootElement(), getLocalPlayer(),mytext)
end
end
addCommandHandler ( "text", drawText )

local myTextDisplay = textCreateDisplay ()
myTextItem = textCreateTextItem ( mytext, .5, .5, "low", 255, 0, 0, 150, 4.0, "center" )
 
function test(mytext)
textDisplayAddObserver ( myTextDisplay, source )
setTimer ( textDisplayRemoveObserver, 3000, 1, myTextDisplay, source )
textDisplayAddText ( myTextDisplay, myTextItem )
end
addEvent("ownText", true)
addEventHandler( "ownText",getRootElement(), test )

any idea?

Link to comment

You misunderstood what varez said.

He said use either "this" OR "this" but you did both and you failed again.

In your triggerServerEvent you pass getLocalPlayer as the first parameter to your test function... but it expects string which is not even used at all.

At line 2, what is mytext?

Is this your whole script?

Your command will try to send command name in triggerServerEvent since first parameter in command handlers (client-side) are command names not what player typed after space when typing command in.

If you want the whole text after command to be displayed you need to make a trick:

function text( _, ... )
local textToBeDisplayed = table.concat( arg, " " );
triggerServerEvent( "ownText", getLocalPlayer(), textToBeDisplayed );
end
addCommandHandler( "text", text );

Why don't you make the command server-side? Easier and quicker.

Link to comment
You misunderstood what varez said.

He said use either "this" OR "this" but you did both and you failed again.

In your triggerServerEvent you pass getLocalPlayer as the first parameter to your test function... but it expects string which is not even used at all.

At line 2, what is mytext?

Is this your whole script?

Your command will try to send command name in triggerServerEvent since first parameter in command handlers (client-side) are command names not what player typed after space when typing command in.

If you want the whole text after command to be displayed you need to make a trick:

function text( _, ... )
local textToBeDisplayed = table.concat( arg, " " );
triggerServerEvent( "ownText", getLocalPlayer(), textToBeDisplayed );
end
addCommandHandler( "text", text );

Why don't you make the command server-side? Easier and quicker.

i dont know, i will do that later maybe btw this code still dosnt work.

Link to comment

Of course it doesn't. I asked you a few questions and you haven't replied to them..

...

At line 2, what is mytext?

Is this your whole script?

...

Why don't you make the command server-side? Easier and quicker.

I suppose "i don't know" answers the last question.

Also, you send the text but you do not set it to text item. Try to find mytext in your test function.

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