rublisk19 Posted January 10, 2012 Share Posted January 10, 2012 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
CapY Posted January 10, 2012 Share Posted January 10, 2012 i wan't it to popup then player joins .And then player get money it would be updated to show current money Then why you use a command handler for that ? Link to comment
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 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
Klesh Posted January 10, 2012 Share Posted January 10, 2012 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
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 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
BinSlayer1 Posted January 10, 2012 Share Posted January 10, 2012 add this after the first line player = player or source Also @ getPlayerAccount use 'player' not 'source' Link to comment
Klesh Posted January 10, 2012 Share Posted January 10, 2012 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
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 not work any other ideas ? Link to comment
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 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
Klesh Posted January 10, 2012 Share Posted January 10, 2012 It cant be, cuz you are joining, are you sure the money is saving on your server? Default server doesn't save money. Removed : addCommandHandler("show", loginMoney) totally useless if you want to show when player joins. Link to comment
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 yes it saves i making rpg gamemode so it saves position exp money job bank and other so any suggestions and your code don't work becouse my money code is getElementData(source, "MONEY") Link to comment
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 i wan't to show all time and update money on real time example: i have 50$ text displays 50$ then if money increase decrease it need to update that to text Link to comment
Klesh Posted January 10, 2012 Share Posted January 10, 2012 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. Link to comment
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 you are dump or me . I think you as i said before i need text display not fcking chatbox Link to comment
Castillo Posted January 10, 2012 Share Posted January 10, 2012 You could make it client-side, using dxDrawText, would be easier. Link to comment
rublisk19 Posted January 10, 2012 Author Share Posted January 10, 2012 in client side it would up to date text like i have 50$ it writes 50$ if i got paid and now i have 120$ it will write 120$ ?? Link to comment
Castillo Posted January 10, 2012 Share Posted January 10, 2012 It should update the money when you get more, but I'm not completely sure. Link to comment
Klesh Posted January 10, 2012 Share Posted January 10, 2012 You dind't say nothing about no outputChatBox, and like solids says, its easy, just replace output to your code. Link to comment
arezu Posted January 10, 2012 Share Posted January 10, 2012 Ehm... onPlayerJoin has no parameters, and source is the player. function showText() -- source is the player end addEventHandler("onPlayerJoin", getRootElement(), showTest) Link to comment
Xeno Posted January 10, 2012 Share Posted January 10, 2012 Rublisk19 he's trying to help you, theres no need to be rude Link to comment
rublisk19 Posted January 11, 2012 Author Share Posted January 11, 2012 you guys didn't read server post ?? as i writed it need to be textDisplay on screen to capture player money Link to comment
Castillo Posted January 11, 2012 Share Posted January 11, 2012 -- 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
rublisk19 Posted January 12, 2012 Author Share Posted January 12, 2012 thanks very works great ! 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