Castillo Posted June 6, 2010 Share Posted June 6, 2010 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
The_Ex Posted June 6, 2010 Share Posted June 6, 2010 The problem is that you are not passing player element to serverside. And why not to make everything serverside then? Server-client is pretty slow. Link to comment
Castillo Posted June 7, 2010 Author Share Posted June 7, 2010 The problem is that you are not passing player element to serverside.And why not to make everything serverside then? Server-client is pretty slow. well, how i do that? Link to comment
dzek (varez) Posted June 7, 2010 Share Posted June 7, 2010 two ways server side: function test(mytext) -- remove first argument -- and replace all player with source end OR triggerServerEvent ( "ownText", getRootElement(), getLocalPlayer(),mytext) Link to comment
Castillo Posted June 7, 2010 Author Share Posted June 7, 2010 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
50p Posted June 7, 2010 Share Posted June 7, 2010 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
Castillo Posted June 7, 2010 Author Share Posted June 7, 2010 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
50p Posted June 8, 2010 Share Posted June 8, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now