rublisk19 Posted January 10, 2012 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
CapY Posted January 10, 2012 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 ?
rublisk19 Posted January 10, 2012 Author 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
Klesh Posted January 10, 2012 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 )
rublisk19 Posted January 10, 2012 Author 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
BinSlayer1 Posted January 10, 2012 Posted January 10, 2012 add this after the first line player = player or source Also @ getPlayerAccount use 'player' not 'source'
Klesh Posted January 10, 2012 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)
rublisk19 Posted January 10, 2012 Author 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
Klesh Posted January 10, 2012 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.
rublisk19 Posted January 10, 2012 Author 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")
rublisk19 Posted January 10, 2012 Author 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
Klesh Posted January 10, 2012 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.
rublisk19 Posted January 10, 2012 Author Posted January 10, 2012 you are dump or me . I think you as i said before i need text display not fcking chatbox
Castillo Posted January 10, 2012 Posted January 10, 2012 You could make it client-side, using dxDrawText, would be easier.
rublisk19 Posted January 10, 2012 Author 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$ ??
Castillo Posted January 10, 2012 Posted January 10, 2012 It should update the money when you get more, but I'm not completely sure.
Klesh Posted January 10, 2012 Posted January 10, 2012 You dind't say nothing about no outputChatBox, and like solids says, its easy, just replace output to your code.
arezu Posted January 10, 2012 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)
Xeno Posted January 10, 2012 Posted January 10, 2012 Rublisk19 he's trying to help you, theres no need to be rude
rublisk19 Posted January 11, 2012 Author 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
Castillo Posted January 11, 2012 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
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