Overkillz Posted July 24, 2015 Share Posted July 24, 2015 Hey guys, I want to do a dxDrawText but from userpanel where the guy can set an own mensagge and I would like to know if this is ok. --Client (Just the trigger part) triggerServerEvent("setPlayerDataText",getLocalPlayer(),usuarioTexto) --Server function setPlayerDataText(playerSource) local Cuenta = getPlayerAccount (playerSource) setAccountData(Cuenta,"usuarioTexto",tostring(usuarioTexto)) end addEvent ( "setPlayerDataText", true ) addEventHandler ( "setPlayerDataText", getRootElement(),setPlayerDataText) Thanks for your time. Regards. Link to comment
Gr0x Posted July 24, 2015 Share Posted July 24, 2015 function setPlayerDataText(text) if client then local Cuenta = getPlayerAccount (client) setAccountData(Cuenta,"usuarioTexto",tostring(text)) end end addEvent ( "setPlayerDataText", true ) addEventHandler ( "setPlayerDataText", getRootElement(),setPlayerDataText) https://wiki.multitheftauto.com/wiki/Sc ... erverEvent And you also forgot to get the "usuarioTexto" string. Link to comment
Overkillz Posted July 24, 2015 Author Share Posted July 24, 2015 I read it carefully and I didnt understand some parts, anyways, I'm trying this --Client (Variable and trigger) local userText = dxLibEditGetText(cInterface.tab_6.extraTab.edit) or "" triggerServerEvent("setAccountDataText",getLocalPlayer(),userText) --Server function setAccountDataText(playerSource) local Cuenta = getPlayerAccount (playerSource) setAccountData(Cuenta,"userText",tostring(userText)) setElementData(playerSource, "nameTagText",userText) end addEvent ( "setAccountDataText", true ) addEventHandler ( "setAccountDataText", getRootElement(),setAccountDataText) --Client (Where it will be drawed) if (getElementData(player,"nameTagText")) then dxDrawText(getElementData(player,"nameTagText"), sx, sy - offset, sx, sy*0.94 - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default-bold", "center", "bottom", false, false, false, true ) end What is wrong ? It dxdraw a text which says " nil " Regards. Link to comment
GTX Posted July 24, 2015 Share Posted July 24, 2015 What the hell? function setAccountDataText(playerSource) local Cuenta = getPlayerAccount (playerSource) local userText = getAccountData(Cuenta, "userText") or "none" setElementData(playerSource, "nameTagText",tostring(userText)) end addEvent ( "setAccountDataText", true ) addEventHandler ( "setAccountDataText", getRootElement(),setAccountDataText) Link to comment
Overkillz Posted July 24, 2015 Author Share Posted July 24, 2015 Thanks buy it doesnt draw anything --Server function setAccountDataText(playerSource) local Cuenta = getPlayerAccount (playerSource) local userText = getAccountData(Cuenta, "userText") or "none" setElementData(playerSource, "nameTagText",tostring(userText)) end addEvent ( "setAccountDataText", true ) addEventHandler ( "setAccountDataText", getRootElement(),setAccountDataText) --Client (Draw [b](it's another Script where it will be drawed) [/b]) if (getElementData(player,"nameTagText")) then dxDrawText(getElementData(player,"nameTagText"), sx, sy - offset, sx, sy*0.94 - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default-bold", "center", "bottom", false, false, false, true ) end Regards. Link to comment
Overkillz Posted July 24, 2015 Author Share Posted July 24, 2015 No one know about it ? Link to comment
Overkillz Posted July 27, 2015 Author Share Posted July 27, 2015 Obviously. Use onClientRender. Thanks, but I could chose another way to dxDraw it. Now, I'm getting a problem with setAccountData. It outputChatBox me a nil value --1st script which start the 1st trigger (This is ok) (ClientSide) local userText = dxLibEditGetText(cInterface.tab_6.extraTab.edit) or "" cInterface.tab_6.extraTab.messageText = "#00FF00Preview: #FFFFFF"..userText triggerServerEvent("setAccountDataText",getLocalPlayer(),tostring(userText)) --2nd script which recieve the trigger (ServerSide) function setAccountDataText(thePlayer) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then setAccountData ( playeraccount, "nameTagText",tostring(userText) ) outputChatBox("SetAccountData setted text: "..tostring(userText)) end end addEvent ( "setAccountDataText", true ) addEventHandler ( "setAccountDataText", getRootElement(),setAccountDataText) outputChatBox that I wrote drop me "nil" after the text part. What is wrong ? I hope u can help me, thanks Link to comment
GTX Posted July 27, 2015 Share Posted July 27, 2015 Because parameter you've choosen in function is thePlayer, change it to userText. --1st script which start the 1st trigger (This is ok) (ClientSide) local userText = dxLibEditGetText(cInterface.tab_6.extraTab.edit) or "" cInterface.tab_6.extraTab.messageText = "#00FF00Preview: #FFFFFF"..userText triggerServerEvent("setAccountDataText",getLocalPlayer(),tostring(userText)) --2nd script which recieve the trigger (ServerSide) function setAccountDataText(userText) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then setAccountData ( playeraccount, "nameTagText",tostring(userText) ) outputChatBox("SetAccountData setted text: "..tostring(userText)) end end addEvent ( "setAccountDataText", true ) addEventHandler ( "setAccountDataText", getRootElement(),setAccountDataText) Link to comment
Overkillz Posted July 27, 2015 Author Share Posted July 27, 2015 Because parameter you've choosen in function is thePlayer, change it to userText. --1st script which start the 1st trigger (This is ok) (ClientSide) local userText = dxLibEditGetText(cInterface.tab_6.extraTab.edit) or "" cInterface.tab_6.extraTab.messageText = "#00FF00Preview: #FFFFFF"..userText triggerServerEvent("setAccountDataText",getLocalPlayer(),tostring(userText)) --2nd script which recieve the trigger (ServerSide) function setAccountDataText(userText) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then setAccountData ( playeraccount, "nameTagText",tostring(userText) ) outputChatBox("SetAccountData setted text: "..tostring(userText)) end end addEvent ( "setAccountDataText", true ) addEventHandler ( "setAccountDataText", getRootElement(),setAccountDataText) LOL, thanks bro, I didnt know about it ^^ 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