Newbie Posted March 21, 2014 Share Posted March 21, 2014 (edited) Read lower Edited March 22, 2014 by Guest Link to comment
Karuzo Posted March 21, 2014 Share Posted March 21, 2014 How do you mean that ? If you mean that the dx should be on the back and the gui labels on front: --just think it's like in photoshop with layers, and the background has to be created first so the labels are created after it. dxDrawRectangle(args..) guiCreateLabel(....) Link to comment
Newbie Posted March 21, 2014 Author Share Posted March 21, 2014 First i have done with dx's and the with labels Link to comment
JR10 Posted March 21, 2014 Share Posted March 21, 2014 There's a postGUI parameter that you can use to draw on top of GUI elements. https://wiki.multitheftauto.com/wiki/DxDrawText Link to comment
Newbie Posted March 21, 2014 Author Share Posted March 21, 2014 postGUI = false] hehe Discovered it few second ago thanks for help guys ;D Link to comment
Newbie Posted March 21, 2014 Author Share Posted March 21, 2014 One more Q. Heres the label: GUIEditor_label[2] = guiCreateLabel((screen_width-507)/2,(screen_height-257)/2, 100, 180, " Wins:", false) guiLabelSetHorizontalAlign(GUIEditor_label[2], "left", false) guiLabelSetVerticalAlign(GUIEditor_label[2], "center") And Heres data from server side: local wins = getAccountData( account, "Wins" ) or 0 local deaths = getAccountData( account, "Deaths" ) or 0 local played = getAccountData( account, "Time" ) or 0 local hunt = getAccountData( account, "Hunters" ) or 0 local expp = getAccountData( account, "EXP" ) or 0 local money = getAccountData( account, "Cash" ) or 0 local map = getAccountData( account, "Maps" ) or 0 local buymap = getAccountData( account, "BuyMaps" ) or 0 local luck = getAccountData( account, "Lucky" ) or 0 local sound = getAccountData( account, "Sound" ) or 0 How to get data into client side in the label Link to comment
Karuzo Posted March 21, 2014 Share Posted March 21, 2014 Trigger it or use Element Datas. Link to comment
Newbie Posted March 21, 2014 Author Share Posted March 21, 2014 Trigger it or use Element Datas. Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Trigger it or use Element Datas. Still do not understand.. Link to comment
cheez3d Posted March 22, 2014 Share Posted March 22, 2014 -- SERVER_SIDE addEventHandler("onPlayerLogin",function(_,account) local player_data = {wins = getAccountData( account, "Wins" ) or 0,deaths = getAccountData( account, "Deaths" ) or 0,hunt = getAccountData( account, "Hunters" ) or 0,expp = getAccountData( account, "EXP" ) or 0,money = getAccountData( account, "Cash" ) or 0,map = getAccountData( account, "Maps" ) or 0,buymap = getAccountData( account, "BuyMaps" ) or 0,luck = getAccountData( account, "Lucky" ) or 0,sound = getAccountData( account, "Sound" ) or 0} -- lets create a table with all the player data in it setElementData(source,"data",player_data) -- attach the table to the player using setElementData end) -- CLIENT_SIDE for data,value in pairs (getElementData(localPlayer,"data")) do -- element data is synced between client and server -- your code end Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Here's the code already for onPlayerLogin addEventHandler( "onPlayerLogin",root, function ( ) local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local rWins = getAccountData( account,"Wins" ) or 0 local rDeaths = getAccountData( account,"Deaths" ) or 0 local rTime = getAccountData( account,"Time" ) or 0 local rHunters = getAccountData( account,"Hunters" ) or 0 local rEXP = getAccountData( account,"EXP" ) or 0 local rCash = getAccountData( account,"Cash" ) or 0 local rMaps = getAccountData( account,"Maps" ) or 0 local rBuyMaps = getAccountData( account,"BuyMaps" ) or 0 local rLucky = getAccountData( account,"Lucky" ) or 0 local rSound = getAccountData( account,"Sound" ) or 0 setElementData( source,"Wins",tostring( rWins ) ) setElementData( source,"Deaths",tostring( rDeaths ) ) setElementData( source,"Time",tostring( rTime ) ) setElementData( source,"Hunters",tostring( rHunters ) ) setElementData( source,"EXP",tostring( rEXP ) ) setElementData( source,"Cash",tostring( rCash ) ) setElementData( source,"Maps",tostring( rMaps ) ) setElementData( source,"BuyMaps",tostring( rBuyMaps ) ) setElementData( source,"Lucky",tostring( rLucky ) ) setElementData( source,"Sound",tostring( rSound ) ) end end ) And i have to get data for each label. Link to comment
cheez3d Posted March 22, 2014 Share Posted March 22, 2014 Why are you doing it like that when I provided you with a faster and easier code? Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Why are you doing it like that when I provided you with a faster and easier code? Cause the server side code already made and i dont want to edit onPlayerLogin in that case i will ruine my code.. Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 SERVER SIDE addEventHandler("onPlayerLogin",root, function() local account = getPlayerAccount( source ) local win = tonumber(getAccountData(account, "Wins")) local dead = tonumber(getAccountData(account, "Deaths")) triggerClientEvent(source,"myEvent",win,dead) end ) CLIENT SIDE addEvent("myEvent",true) addEventHandler("myEvent",root, function(win, dead) guiSetText(GUIEditor_Label[2]," Wins:"..win) guiSetText(GUIEditor_Label[3]," Deaths:"..dead) end ) Dont work i dont know why Link to comment
JR10 Posted March 22, 2014 Share Posted March 22, 2014 Because in your triggerClientEvent, you forgot to supply the baseElement argument. Try this: addEventHandler("onPlayerLogin",root, function() local account = getPlayerAccount( source ) local win = tonumber(getAccountData(account, "Wins")) local dead = tonumber(getAccountData(account, "Deaths")) triggerClientEvent(source,"myEvent",root,win,dead) end ) Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Because in your triggerClientEvent, you forgot to supply the baseElement argument.Try this: addEventHandler("onPlayerLogin",root, function() local account = getPlayerAccount( source ) local win = tonumber(getAccountData(account, "Wins")) local dead = tonumber(getAccountData(account, "Deaths")) triggerClientEvent(source,"myEvent",root,win,dead) end ) Didnt worked Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Lets start from the begin, im sure you guys didnt understand what i want to do. Here's the label: GUIEditor_label[2] = guiCreateLabel((screen_width-507)/2,(screen_height-257)/2, 100, 180, " Wins:", false) Part from the server: addEventHandler( "onPlayerLogin",root, function ( ) local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local rWins = getAccountData( account,"Wins" ) or 0 local rDeaths = getAccountData( account,"Deaths" ) or 0 local rTime = getAccountData( account,"Time" ) or 0 local rHunters = getAccountData( account,"Hunters" ) or 0 local rEXP = getAccountData( account,"EXP" ) or 0 local rCash = getAccountData( account,"Cash" ) or 0 local rMaps = getAccountData( account,"Maps" ) or 0 local rBuyMaps = getAccountData( account,"BuyMaps" ) or 0 local rLucky = getAccountData( account,"Lucky" ) or 0 local rSound = getAccountData( account,"Sound" ) or 0 setElementData( source,"Wins",tostring( rWins ) ) setElementData( source,"Deaths",tostring( rDeaths ) ) setElementData( source,"Time",tostring( rTime ) ) setElementData( source,"Hunters",tostring( rHunters ) ) setElementData( source,"EXP",tostring( rEXP ) ) setElementData( source,"Cash",tostring( rCash ) ) setElementData( source,"Maps",tostring( rMaps ) ) setElementData( source,"BuyMaps",tostring( rBuyMaps ) ) setElementData( source,"Lucky",tostring( rLucky ) ) setElementData( source,"Sound",tostring( rSound ) ) end end ) I want to getAccountData in to labels to display my wins data. I have other labels so i need an example for wins . Link to comment
Karuzo Posted March 22, 2014 Share Posted March 22, 2014 Yeah and now you're getting the element data client-side and put it in the label. Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Yeah and now you're getting the element data client-side and put it in the label. But that does not work.. SERVER addEventHandler("onPlayerLogin",root, function() local account = getPlayerAccount( source ) local win = tonumber(getAccountData(account, "Wins")) local dead = tonumber(getAccountData(account, "Deaths")) triggerClientEvent(source,"myEvent",root,win,dead) end ) CLIENT addEvent("myEvent",true) addEventHandler("myEvent",root, function(win, dead) guiSetText(GUIEditor_Label[2]," Wins:"..win) guiSetText(GUIEditor_Label[3]," Deaths:"..dead) end ) Link to comment
Castillo Posted March 22, 2014 Share Posted March 22, 2014 Maybe the data is nil, so do tostring ( win ), tostring ( dead ) in the client side. Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Maybe the data is nil, so do tostring ( win ), tostring ( dead ) in the client side. It doesn't I made a stats check cmd: function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Wins" ) or 0 local deaths = getAccountData( account, "Deaths" ) or 0 local played = getAccountData( account, "Time" ) or 0 local hunt = getAccountData( account, "Hunters" ) or 0 local expp = getAccountData( account, "EXP" ) or 0 local money = getAccountData( account, "Cash" ) or 0 local map = getAccountData( account, "Maps" ) or 0 local buymap = getAccountData( account, "BuyMaps" ) or 0 local luck = getAccountData( account, "Lucky" ) or 0 local sound = getAccountData( account, "Sound" ) or 0 if deaths and wins and played then outputChatBox("STATS TEST Wins: ".. tostring( wins ) .." Deaths: "..tostring( deaths ).." Time: "..tostring( played ).." Hunters: "..tostring( hunt ).." Maps: "..tostring( map ).." Exp: "..tostring( expp ).." Cash: "..tostring( money ).." Buy maps: "..tostring( buymap ).." Lucky: "..tostring( luck ).." Sound: "..tostring( sound ).."", root, 255, 12, 15, true) else outputChatBox("" , root, 255, 12, 15, true) end end else outputChatBox( "" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) ----------------------------- function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) The data is alright all scripts forking fine. Looks like the guiSetText dont even works, it doesn't change any. No errors in ds 3. Link to comment
Castillo Posted March 22, 2014 Share Posted March 22, 2014 Tried checking if the event is being triggered? Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 Tried checking if the event is being triggered? Not sure how to do that.. My En is not so well, but i understand a lot compared past Link to comment
Castillo Posted March 22, 2014 Share Posted March 22, 2014 addEvent("myEvent",true) addEventHandler("myEvent",root, function(win, dead) guiSetText(GUIEditor_Label[2]," Wins:"..win) guiSetText(GUIEditor_Label[3]," Deaths:"..dead) outputChatBox ( "EVENT TRIGGERED!" ) end ) Link to comment
Newbie Posted March 22, 2014 Author Share Posted March 22, 2014 It didnt outPut but i saw something in DB: attempt to index global GUIEditor_Label a nil value on that line: guiSetText(GUIEditor_Label[2]," Wins:"..win) 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