Jump to content

[Help] setElementData


LasHa

Recommended Posts

guys i am new scripter and i am going to make great script just a problem that i have got. i want to set element data like this one, when player click button, setelementdata playersJoined and when second player hits in this button, it adds in the same elementdata playersJoined but +1 and when player leave game or write /cansel maybe -1? but how? :(:S i don't know anything in datas and in wiki i didn't understand what to do because there are not things like i want :( please help me :(:(

Link to comment

What?

When a player clicks a button.. hm

Use this:

onClientGUIClick: setElementData(localPlayer, "yourDataKey", true)

.. This is what I understand..

And btw, when a player quits the server all his elementData gets lost,

for the /cansel thing, maybe you can do setElementData(localPlayer, "yourDataKey", nil)

You should explain more what you're trying to do. It's really hard to help if you don't put some effort to make your post be understandable.

Link to comment

Use this i think it will help you

  
function JoinCounter() 
    if not getElementData(localPlayer,"YouR_Data") then 
             setElementData(localPlayer,"Your_data",0) 
      end 
end 
addEventHandler("onClientPlayerJoin", getRootElement(), JoinCounter) 
  
function initGUI( ) 
  --make your gui here 
local count = getElementData(localPlayer,"Your_Data") 
setElementData(localPlayer,"Your_Data",count+1) 
  
end 
  
    addEventHandler ( "onClientGUIClick", btnOutput, intiGUI ) 
  
function onQuitGame( ) 
 local count = getElementData(localPlayer,"Your_Data") 
setElementData(localPlayer,"YOur_Data",count-1) 
end 
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame ) 
  

I also suggest you to set player account data on quit so when it come back and click count wont get abuse.

I think that what you need if no then please explain some more about your idea.

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