Castillo Posted June 6, 2010 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
The_Ex Posted June 6, 2010 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. MTASA.LV - Latvian MTA Community
Castillo Posted June 7, 2010 Author 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? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
dzek (varez) Posted June 7, 2010 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) Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Castillo Posted June 7, 2010 Author 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? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted June 7, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Castillo Posted June 7, 2010 Author 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted June 8, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
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