Jump to content

Help needed


Newbie

Recommended Posts

Posted

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

Posted

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

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

Posted

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.

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

Posted

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

Posted

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 
) 

Posted
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 :/

Posted

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 .

Posted
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 
) 

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

Posted
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

Posted
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 
) 

Posted

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) 

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