russelvelt Posted February 20, 2014 Posted February 20, 2014 buenas a todos tengo un problemita en el resource para guardar dinero osea todo anda bien me guarda normal exepto cuando por ejemplo tengo $8000 de dinero y compro algo de $5000 mi dinero queda en $3000 pero a la hora de reconectar al servidor este vuelve a $8000 y quisiera saber el problema aqui muestro como es node = xmlLoadFile ("player.xml") function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) if not (isGuestAccount (getPlayerAccount(source))) then local accountData = getAccountData (theCurrentAccount, "money") if (accountData) then local playerMoney = getAccountData(theCurrentAccount, "money") setPlayerMoney(source, playerMoney) end end end addEventHandler("onPlayerLogin", getRootElement(), playerLogin) function onQuit() if not (isGuestAccount (getPlayerAccount (source))) then account = getPlayerAccount (source) if (account) then setAccountData(account,"money", tostring(getPlayerMoney(source))) end end end addEventHandler("onPlayerQuit", getRootElement(), onQuit)
russelvelt Posted February 20, 2014 Author Posted February 20, 2014 GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"",true) guiSetAlpha(GUIEditor_Window[1],225) guiCreateStaticImage ( 0, 0, 1, 0.8,"image.png",true,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1],false) GUIEditor_Button[1] = guiCreateButton(0.52,0.85,0.45,0.1,"SI",true,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(0,0.85,0.45,0.1,"NO",true,GUIEditor_Window[1]) function showGUI2() guiSetVisible (GUIEditor_Window[1],true) showCursor(true) end addEvent("showGUI2",true) addEventHandler("showGUI2",getRootElement(),showGUI2) addEvent("hideGUI2",true) addEventHandler("hideGUI2",getRootElement(), function () guiSetVisible(GUIEditor_Window[1],false) showCursor (false) end) addEventHandler("onClientGUIClick",getRootElement(), function (player) if (source == GUIEditor_Button[2]) then guiSetVisible (GUIEditor_Window[1],false) showCursor (false) elseif (source == GUIEditor_Button[1]) then money = getPlayerMoney (source) if (money < 10) then outputChatBox ("vas a pagar $10?",225,0,0) else player = getLocalPlayer() playSound( "item.mp3", false ) outputChatBox ("compraste comida",225,225,0) takePlayerMoney(10) setElementHealth ( player, getElementHealth(player) + 25 ) end end end)
Alexs Posted February 20, 2014 Posted February 20, 2014 Lo que sucede es que al quitar dinero desde el client-side, el de server-side no se ve afectado, así que el guardado conseguirá el mismo dinero sin importar la compra, tendrás que utilizar 'triggerServerEvent' para quitar el dinero y que esto afecte a server-side.
Recommended Posts