Jump to content

Question elementdata


Bean666

Recommended Posts

Posted

hi, im asking a question

what if i make a function with setElementData in a resource. then if i make another resource

will getElementData work with the data i set in the other resource?

will it get the data from the other resource?

Posted

uhm just a question

will this set the player's ElementData to "tough" when he clicks the button "button"?

function toughperk( ) 
if (source == localPlayer) then 
setElementData(localPlayer,"tough", true) 
end 
end 
addEventHandler ( "onClientGUIClick", button, toughperk ) 

Posted (edited)

like this?

function toughperk( ) 
setElementData(localPlayer,"tough", true) 
end 
addEventHandler ( "onClientGUIClick", button, toughperk ) 

Edited by Guest
Posted

ok thanks i just had to remove 1 end and it's already working , thanks. anyways will this work if i get the player's data?

if (getElementType(player) == "player") and getElementData(player, "toughperk") == true then 

Posted

ok i got it working but , how can i save a player's Element Data when he quits the game? and when he joins game it sets the saved Element Data?

Posted

nvm it works fine when i used:

function quitPlayer () 
    local account = getPlayerAccount (source) 
    local data = getElementData(source, "toughperk") 
    if data == true then 
    setAccountData (account, "toughperk", true ) 
end 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer ) 
  
addEventHandler ( 'onPlayerLogin', getRootElement ( ), 
    function ( _, theCurrentAccount) 
    local ifaccountperk = getAccountData(theCurrentAccount, "toughperk") 
    if ifaccountperk == true then 
    setElementData(source,"toughperk", true) 
    setAccountData (account, "toughperk", false ) 
    else 
    setElementData(source,"toughperk", false) 
end 
end 
) 

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