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?

Aftermath

Posted

Yes.

Element data is shared between all resources.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 ) 

Aftermath

Posted

Yes.

By the way, 'source' of onClientGUIClick is the button, not the localPlayer, remove that 'if' check.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (edited)

like this?

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

Edited by Guest

Aftermath

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 

Aftermath

Posted

You have a missing parentheses after 'true' and before 'then'.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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?

Aftermath

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 
) 

Aftermath

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