Jump to content

Text Display Update


rublisk19

Recommended Posts

Hi all i need help on making up to date text display:

i have this script:

function showTextDisplay ( player, command ) 
   local money = getElementData(player, "MONEY") 
   local serverDisplay = textCreateDisplay()                             -- create a text display 
   textDisplayAddObserver ( serverDisplay, player )                      -- make it visible to a player 
   local serverText = textCreateTextItem ( money.." Lt", 0.775, 0.18, "low",34, 139, 34, 255, 3.2, "left", "top", 255)    -- create a text item for the display 
   textDisplayAddText ( serverDisplay, serverText )                      -- add it to the display so it is displayed 
end 
addCommandHandler( "show", showTextDisplay ) 

i wan't it to popup then player joins .And then player get money it would be updated to show current money

Link to comment

Then why you use a command handler for that ?

so i need use like this ??

function showTextDisplay ( player, command ) 
   local money = getElementData(player, "MONEY") 
   local serverDisplay = textCreateDisplay()                             -- create a text display 
   textDisplayAddObserver ( serverDisplay, player )                      -- make it visible to a player 
   local serverText = textCreateTextItem ( money.." Lt", 0.775, 0.18, "low",34, 139, 34, 255, 3.2, "left", "top", 255)    -- create a text item for the display 
   textDisplayAddText ( serverDisplay, serverText )                      -- add it to the display so it is displayed 
end 

Link to comment

Try :

  
 function showTextDisplay ( source,player, command ) 
local account = getPlayerAccount(source) 
local money = getElementData(player, "MONEY") 
local serverDisplay = textCreateDisplay()             -- create a text display 
if money and account then 
textDisplayAddObserver ( serverDisplay, player )   -- make it visible to a player 
local serverText = textCreateTextItem ( money.." Lt", 0.775, 0.18, "low",34, 139, 34, 255, 3.2, "left", "top", 255)    -- create a text item for the display 
textDisplayAddText ( serverDisplay, serverText ) -- add it to the display so it is displayed 
end 
end 
addEventHandler("onPlayerJoin", getRootElement(), showTextDisplay) 
addommandHandler( "show", showTextDisplay ) 

Link to comment
Try :
  
 function showTextDisplay ( player, command ) 
local account = getPlayerAccount(source) 
local money = getElementData(player, "MONEY") 
local serverDisplay = textCreateDisplay()             -- create a text display 
if (money) then 
textDisplayAddObserver ( serverDisplay, player )   -- make it visible to a player 
local serverText = textCreateTextItem ( money.." Lt", 0.775, 0.18, "low",34, 139, 34, 255, 3.2, "left", "top", 255)    -- create a text item for the display 
textDisplayAddText ( serverDisplay, serverText ) -- add it to the display so it is displayed 
end 
end 
addEventHandler("onPlayerJoin", getRootElement(), showTextDisplay) 
addommandHandler( "show", showTextDisplay ) 

Not work i fixed your typing mistake but i don't show's me text

Link to comment

If do you want get the Playermoney when player joins try that:

Easy code

function loginMoney (thePlayer) 
if (getPlayerMoney(thePlayer) then  
    outputChatBox("Welcome to my server, your current money is" ..getPlayerMoney(thePlayer)..".",thePlayer, 255, 0, 0, true) 
end 
    if isGuestAccount then  
        outputChatBox("Sorry you can see how money you have, you must be logged in", thePlayer, 255, 0, 0, true) 
    end 
end) 
addEventHandler("onPlayerJoin", getRootElement(), loginMoney) 
  

Link to comment
If do you want get the Playermoney when player joins try that:

Easy code

function loginMoney (thePlayer) 
if (getPlayerMoney(thePlayer) then  
    outputChatBox("Welcome to my server, your current money is" ..getPlayerMoney(thePlayer)..".",thePlayer, 255, 0, 0, true) 
end 
    if isGuestAccount then  
        outputChatBox("Sorry you can see how money you have, you must be logged in", thePlayer, 255, 0, 0, true) 
    end 
end) 
addEventHandler("onPlayerJoin", getRootElement(), loginMoney) 
  

i know how to make to show money but it doesn't update them

Link to comment

Don't double post, so easy like this, try with it, its not needed to call getAccountData,is stored, and when you logged the data is unpack, so with this you know how many cash you have, so simple like that.

ffunction loginMoney (source) 
local playerMoney = getPlayerMoney(source) 
outputChatBox("Your current money is " .. playerMoney.. " $ cash.", source, 255, 0, 0, true) 
end 
addEventHandler("onPlayerLogin", getRootElement(), loginMoney) 
  
function commandMoney(source,commandName) 
local money = getPlayerMoney(source) 
outputChatBox("Your current money is " .. money.. " $ cash.", source, 255, 0, 0, true) 
end 
addCommandHandler("money", commandMoney) 

Tested.

Ps: The code show's the current money, the code works when playerJoin, and /money command.

moneyloginandcommand.png

Link to comment

-- client side:

addEventHandler("onClientRender",root, 
    function() 
        local money = getElementData(localPlayer, "MONEY") or 0 
        dxDrawBorderedText(tostring(money) .." Lt",800,135,972,165,tocolor(0,180,0,255),1.1,"pricedown","left","top",false,false,false) 
    end 
) 
  
function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) 
    dxDrawText ( text, x - 1, y - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black 
    dxDrawText ( text, x + 1, y - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x - 1, y + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x + 1, y + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x - 1, y, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x + 1, y, w + 1, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) 
end 

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