Jump to content

[Trigger]Does it is triggered correctly ?


Overkillz

Recommended Posts

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

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

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

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

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

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