Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 did not work --Server function onLogin( player) if not getAccountData(player, "p_money") or getAccountData(player, "p_money") == nil then setAccountData(player, "p_money", 0) end end addEventHandler("onPlayerLogin", root, onLogin) function getPlayerMoney ( player ) local m = false local gPlayerAccount = getPlayerAccount(player) if (gPlayerAccount ~= false) and (isGuestAccount(gPlayerAccount) == false) then m = tonumber ( getAccountData ( gPlayerAccount, "p_money" ) ) if ( not m ) then m = 0 setAccountData ( player, "p_money", 0 ) end end return m end
Et-win Posted August 13, 2014 Posted August 13, 2014 You didn't look what I did. local gPlayerAccount = getPlayerAccount(player) if (gPlayerAccount ~= false) and (isGuestAccount(gPlayerAccount) == false) then First get the player's account and check or he is logged in, if so, if not on Guest account, then continue.
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 player account logged and no Guest account.
Et-win Posted August 13, 2014 Posted August 13, 2014 account thePreviousAccount, account theCurrentAccount, bool autoLogin @ onPlayerLogin. So...... You are getting the PREVIOUS account now. Get the CURRENT account.
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 like what, add yourself these points by P -> Resources -> Execute command -> setElementData (getPlayerFromName ("Seba500PLK"), "p_money", 1) it badly or well?
Et-win Posted August 13, 2014 Posted August 13, 2014 ... function onLogin(previousAccount, currentAccount) if not getAccountData(currentAccount, "p_money") or not getAccountData(currentAccount, "p_money") == nil then setAccountData(currentAccount, "p_money", 0) end end addEventHandler("onPlayerLogin", root, onLogin) Even though you have your answer now, I still want you to answer this question: Do you even use debugscript 3?
Et-win Posted August 13, 2014 Posted August 13, 2014 Good, because by then you would know the entered variable was 'nil'.
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 i add a check point function: function getpoints ( player, command) local gPlayerAccount = getPlayerAccount(player) outputChatBox(tostring(getAccountData ( gPlayerAccount, "p_money" ))) end addCommandHandler ( "getp", getpoints ) Check: http://imagizer.imageshack.us/v2/1920x1 ... fbPaXy.png
Et-win Posted August 13, 2014 Posted August 13, 2014 You are setting it on the element I see @ Admin Panel. But that is impossible, since everything is going on account data, not element data. Use: setAccountData(getPlayerAccount(getPlayerFromName("Yourname")), "p_money", value)
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 ok, quit and join save my points, is another problem Check: http://imagizer.imageshack.us/v2/1920x1 ... Sk2UPU.png
Et-win Posted August 13, 2014 Posted August 13, 2014 You have to trigger the player's money to the client, so you can use it there. (triggerServerEvent as soon as the player joins to request her/his money, then trigger back to her/him with triggerClientEvent)
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 do not know too much on the triggers. please could you help? I'm sorry that so much of the time it takes --Client function getPlayerMoney ( ) local m = tonumber ( getElementData ( localPlayer, "p_money" ) ) if ( not m ) then m = 0 setElementData ( localPlayer, "p_money", 0 ) end return m end function setPlayerMoney ( money ) return setElementData ( localPlayer, "p_money", money ) end function givePlayerMoney ( money ) local c = getPlayerMoney ( localPlayer ) return setPlayerMoney ( localPlayer, c + money ) end local screenWidth, screenHeight = guiGetScreenSize() addEventHandler ( "onClientRender", root, function ( ) dxDrawText ( "Twoje PP: "..tostring ( getPlayerMoney ( ) ), screenWidth * 0.509 / 2, screenHeight * 0.022, screenWidth * 0.5 / 2, screenHeight * 0, tocolor ( 0, 0, 0, 255), 1, "bankgothic", "left", "top", false, false, true, true) dxDrawText ( "#FFC000Twoje PP: #FF4000"..tostring ( getPlayerMoney ( ) ), screenWidth * 0.506 / 2, screenHeight * 0.02, screenWidth * 0.5 / 2, screenHeight * 0, tocolor ( 2, 2, 214, 255), 1, "bankgothic", "left", "top", false, false, true, true) end ) --Server function onLogin(previousAccount, currentAccount) if not getAccountData(currentAccount, "p_money") or not getAccountData(currentAccount, "p_money") == nil then setAccountData(currentAccount, "p_money", 0) end end addEventHandler("onPlayerLogin", root, onLogin) function getPlayerMoney ( player ) local m = false local gPlayerAccount = getPlayerAccount(player) if (gPlayerAccount ~= false) and (isGuestAccount(gPlayerAccount) == false) then m = tonumber ( getAccountData ( gPlayerAccount, "p_money" ) ) if ( not m ) then m = 0 setAccountData ( player, "p_money", 0 ) end end return m end function getpoints ( player, command) local gPlayerAccount = getPlayerAccount(player) outputChatBox(tostring(getAccountData ( gPlayerAccount, "p_money" ))) end addCommandHandler ( "getp", getpoints )
Et-win Posted August 13, 2014 Posted August 13, 2014 local gCurrentMoney = 0 function receiveMoney(gMoney) gCurrentMoney = gMoney end addEvent("onSendMoneyToClient", true) addEventHandler("onSendMoneyToClient", getRootElement(), receiveMoney) --Client function getPlayerMoney ( ) local m = tonumber ( getElementData ( localPlayer, "p_money" ) ) if ( not m ) then m = 0 setElementData ( localPlayer, "p_money", 0 ) end return m end function setPlayerMoney ( money ) return setElementData ( localPlayer, "p_money", money ) end function givePlayerMoney ( money ) local c = getPlayerMoney ( localPlayer ) return setPlayerMoney ( localPlayer, c + money ) end local screenWidth, screenHeight = guiGetScreenSize() addEventHandler ( "onClientRender", root, function ( ) dxDrawText ( "Twoje PP: "..tostring ( getPlayerMoney ( ) ), screenWidth * 0.509 / 2, screenHeight * 0.022, screenWidth * 0.5 / 2, screenHeight * 0, tocolor ( 0, 0, 0, 255), 1, "bankgothic", "left", "top", false, false, true, true) dxDrawText ( "#FFC000Twoje PP: #FF4000"..tostring ( getPlayerMoney ( ) ), screenWidth * 0.506 / 2, screenHeight * 0.02, screenWidth * 0.5 / 2, screenHeight * 0, tocolor ( 2, 2, 214, 255), 1, "bankgothic", "left", "top", false, false, true, true) end ) --Server function onLogin(previousAccount, currentAccount) if not getAccountData(currentAccount, "p_money") or not getAccountData(currentAccount, "p_money") == nil then setAccountData(currentAccount, "p_money", 0) end triggerClientEvent(source, "onSendMoneyToClient", source, getAccountData(currentAccount, "p_money)) end addEventHandler("onPlayerLogin", root, onLogin) function getPlayerMoney ( player ) local m = false local gPlayerAccount = getPlayerAccount(player) if (gPlayerAccount ~= false) and (isGuestAccount(gPlayerAccount) == false) then m = tonumber ( getAccountData ( gPlayerAccount, "p_money" ) ) if ( not m ) then m = 0 setAccountData ( player, "p_money", 0 ) end end return m end function getpoints ( player, command) local gPlayerAccount = getPlayerAccount(player) outputChatBox(tostring(getAccountData ( gPlayerAccount, "p_money" ))) end addCommandHandler ( "getp", getpoints ) EDITED. The rest you can do by yourself, too tired now atm. Try atleast to understand it..
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 7 line getAccountData(currentAccount, "p_money)) should getAccountData(currentAccount, "p_money"))
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 like trying to do it is either "nil" or "0" help
Et-win Posted August 14, 2014 Posted August 14, 2014 Server-side: function saveMoney(tPlayer) if (tPlayer ~= nil) then source = tPlayer end local gAccount = getPlayerAccount(source) if (gAccount ~= false) then local gMoney = getElementData(source, "p_money") if (gMoney ~= false) then setAccountData(gAccount, "p_money", gMoney) end end end addEvent("onRequestSaveMoney", true) addEventHandler("onRequestSaveMoney", getRootElement(), saveMoney) function setMoney(previousAccount, currentAccount) local gMoney = getAccountData(currentAccount, "p_money") if (gMoney ~= false) then setElementData(source, "p_money", gMoney) else setElementData(source, "p_money", 0) end end addEventHandler("onPlayerLogin", getRootElement(), setMoney) You can now work with 'setElementData and 'getElementData'. As soon as you set the money to the player's account in Client-side, then just use this code to save the money to the player's account: triggerServerEvent("onRequestSaveMoney", getLocalPlayer()) As soon as the player logs in, then the money is automatically set. If you want to save the money via Server-side, then use: saveMoney(Fill-in-player-element-HERE) Try to study it, next time you are going to do it by yourself most of the time, instead of let everything done for you by someone else.
Seba500PLK Posted August 14, 2014 Author Posted August 14, 2014 ok I was able to. And now to give yourself the points you need to enter: setElementData(getPlayerFromName("NAME"),"p_money",3)
Seba500PLK Posted August 14, 2014 Author Posted August 14, 2014 thank you for everything, you have from me a huge plus
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