Jump to content

[Solved] Custom Tag


HunT

Recommended Posts

Posted (edited)

Hi Guys. I have the epic problem for call the element from database (number rank) and set in nametags (image client).

Example rank number 0 = rank0.png (type last job in scoreboard . . .remember? )

type :

  
local nameimage = "rank" 
local rank = -- this is my problem, for call the rank number from database 
dxDrawImage(drawX-1, drawY-1, width+2, height+2, "img/"..nameimage..rank..".png" ) 
  

The function server side for call the number + triggerClientEvent i test every time . . . .every Fail. :wink:

S.O.S :|

Edited by Guest
Posted
I would use setElementData to save the image and then getElementData in the client side.

oh yep . . .but i never use setElementData :| and the wiki no help me about this argument.

Posted

Maybe i need the "alternative" nametags.

Type original nametag for name and bar,and nametag2 for image,why is impossible import the element from db in original nametags.

Server side for call the elements with event onPlayerSpawn and trigg for dx image.

Mhh . . .is hard :D i hate dx function

Posted

Maybe :

local nameimage = "rank" 
local rank = triggerServerEvent -- Maybe no   
dxDrawImage(drawX-1, drawY-1, width+2, height+2, "img/"..nameimage..rank..".png" ) 

Posted

Like that ?

Client-side:

  
local nameimage = "rank" 
addEvent("yourEvent", true) 
addEventHandler("yourEvent", getRootElement(), 
function(rank) 
    if rank then 
        addEventHandler("onClientRender", getRootElement(), 
        function() 
            dxDrawImage(drawX-1, drawY-1, width+2, height+2, "img/"..nameimage..rank..".png" ) 
        end) 
    end 
end) 
  

Server side:

  
triggerClientEvent("yourEvent", getRootElement(), rank) 
  

Posted
Like that ?

Client-side:

  
local nameimage = "rank" 
addEvent("yourEvent", true) 
addEventHandler("yourEvent", getRootElement(), 
function(rank) 
    if rank then 
        addEventHandler("onClientRender", getRootElement(), 
        function() 
            dxDrawImage(drawX-1, drawY-1, width+2, height+2, "img/"..nameimage..rank..".png" ) 
        end) 
    end 
end) 
  

Server side:

  
triggerClientEvent("yourEvent", getRootElement(), rank) 
  

Tnx for this but i need the element server in nametags.

Anyway i make this patetich soluction and now the debugscript 3 is live :mrgreen:

Maybe the server number is ok but the dxDrawImage sure is fail . . . why i'm very nab in dx Function :|

nametag client :

  
if NAMETAG_BAR_FRAME == 1 then  
            local nameimage = "rank" 
            local rank =  triggerServerEvent ("rankTab",getLocalPlayer()) 
            dxDrawImage(drawX-1, drawY-1, width+2, height+2, tostring(":race\\img\\"..nameimage..rank..".png" )) end 
  

server side event :

  
addEvent("rankTab", true) 
addEventHandler("rankTab", rootElement, 
  function(rank)  
   local account = getPlayerAccount(source) 
    local rank = getAccountData(account, "rank") 
    end 
) 

Debugscript 3 report : attempt to concatenate local 'rank' (a boolean value) -- from dx string client

Posted

/push post

Sorry for push but i very need help :(

I never use the dx functions.

The problem is the string dx or rank = trigg

Tnx :|

P.S. I'm not wait the code,i want only the info.

Posted

But debugscript report me the error in dxDrawImage :| ,maybe the script run and the dx don't check the png.

Posted

-- client side:

triggerServerEvent ("rankTab",getLocalPlayer()) -- This will trigger so it get's the rank and set element data, don't trigger it in the event "onClientRender", it must be outside. 
  
if NAMETAG_BAR_FRAME == 1 then 
            local nameimage = "rank" 
            local rank = getElementData(localPlayer,"rank") 
            if (not fileExists(":race/img/"..rank..".png")) then return end 
            dxDrawImage(drawX-1, drawY-1, width+2, height+2, ":race/img/"..rank..".png") end 

-- server side:

addEvent("rankTab", true) 
addEventHandler("rankTab", root, 
function() 
    local account = getPlayerAccount(source) 
    local rank = getAccountData(account, "rank") 
    setElementData(source,"rank",tostring(rank)) 
end 
) 

Posted
-- client side:
triggerServerEvent ("rankTab",getLocalPlayer()) -- This will trigger so it get's the rank and set element data, don't trigger it in the event "onClientRender", it must be outside. 
  
if NAMETAG_BAR_FRAME == 1 then 
            local nameimage = "rank" 
            local rank = getElementData(localPlayer,"rank") 
            if (not fileExists(":race/img/"..rank..".png")) then return end 
            dxDrawImage(drawX-1, drawY-1, width+2, height+2, ":race/img/"..rank..".png") end 

-- server side:

addEvent("rankTab", true) 
addEventHandler("rankTab", root, 
function() 
    local account = getPlayerAccount(source) 
    local rank = getAccountData(account, "rank") 
    setElementData(source,"rank",tostring(rank)) 
end 
) 

Tnx Castillo later test,now i can't :(

But u forget the ..nameimage.. In dxDrawImage? Or no need this now?

Anyway later test :D

Posted

Debug Say : attempt to concatenate local 'rank' (a boolean value) :cry:

on dxDrawImage

  
dxDrawImage(drawX-1, drawY-1, width+2, height+2, ":race/img/"..rank..".png") 
  

i have the image rank0.png in race/img . . . and rank 0 in stats

Where is the problem :cry:

Posted

Castillo the set/get elementData need the event or the botton,why i call the r,g,b and r1,g1,b1 for change the color dxname tag and dxrectangle whit colorPicker and work.

For rank number i need the botton in panel or event onPlayerSpawn :D

Event server side

Get account data

Set element data with tonumber

Client

Get element data whth tonumber

dxDrawImage ..rank..".png"

else

Default.png

Tnx for info about element data :D

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