manve1 Posted December 15, 2012 Share Posted December 15, 2012 I have a problem of trying to make an achievement when player dies he unlocks it, but i just don't get how to make it work properly. Server-side: function achLog( ) local logged1 = getPlayerAccount(source) if (logged1) then setAccountData(logged1, 'achDamage', 2) end end addEventHandler('onPlayerLogout', getRootElement(), achLog) addEventHandler('onPlayerWasted', getRootElement(), function() local logged1 = getPlayerAccount(source) local logged = getAccountData(logged1, 'achDamage') if (logged == tonumber(0)) then triggerClientEvent('needDamage', getRootElement()) setAccountData(logged1, 'achDamage', 2) outputChatBox('#FF0000[Achievement]: #FFFFFF'.. getPlayerName( source ) ..' just unlocked "Death is here." achievement.', root, 255, 255, 255, true) elseif (logged == 2) then triggerClientEvent('logDamage', getRootElement()) end end ) Client-side: addEvent('needDamage', true) addEventHandler('needDamage', getRootElement(), function() local achDamage = guiCreateStaticImage( 0.4, 0.2, 0.6, 0.2, 'pictures/ach.png', true ) local labelDamage = guiCreateLabel( 0.4, 0.6, 0.6, 0.15, 'Death is here ( Die )', true, achDamage ) setTimer( function() if isElement(achDamage) and isElement(labelDamage) then destroyElement(achDamage) destroyElement(labelDamage) end end, 2000, 1 ) end ) addEvent('logDamage', true) addEventHandler('logDamage', getRootElement(), function() guiGridListSetItemText( gridAch, row2, column1, 'Death is here Unlocked', false, false ) end ) Link to comment
Castillo Posted December 15, 2012 Share Posted December 15, 2012 Errors or anything in the debugscript? what is the exact problem? Link to comment
Techial Posted December 15, 2012 Share Posted December 15, 2012 EDIT: The problem here is the getAccountData. It saves strings not numbers. So it would basically be: if(logged == "0") then or if(tonumber(logged) == 0) then Link to comment
manve1 Posted December 15, 2012 Author Share Posted December 15, 2012 no errors, but I done same thing for login on numbers, and it worked, just for some reason not on this Link to comment
Cadu12 Posted December 15, 2012 Share Posted December 15, 2012 Well, you already set to 2 on achDamage in event called onPlayerLogout. Link to comment
manve1 Posted December 15, 2012 Author Share Posted December 15, 2012 Removed it, but still ain't working Link to comment
Cadu12 Posted December 15, 2012 Share Posted December 15, 2012 As I said, your achDamage is already set to 2, you need make it to back 0 or 1. Link to comment
Techial Posted December 15, 2012 Share Posted December 15, 2012 function achLog( ) local logged1 = getPlayerAccount(source) if (logged1) then setAccountData(logged1, 'achDamage', 0) end end addEventHandler('onPlayerLogout', getRootElement(), achLog) Link to comment
manve1 Posted December 15, 2012 Author Share Posted December 15, 2012 Didn't work. Still it doesn't update the GridList 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