a952637635 Posted February 9, 2015 Share Posted February 9, 2015 Hello,guys . I'm a chineseplayer,so,Sorry my English is not good.I wish I could express what I mean. Yesterday, I want to write a server .The server has a Progressbars,it told us player's hunger level. I need save the barProgress when player exit the game and load the barProgress when he login. I reason in this way about the matter. When a player exit game. Use guiProgressBarGetProgress in client side to send barProgress to server side when player exit.Then save the barProgress to this player's AccountData. Then, when player login, set player barProgress.I try to write it, but it doesn't work. Anyone PRO man know how to write the code? help me please! Thanks! PS:China mtasa server technology blockade,so i hope i can learn something form here. mainbar = guiCreateProgressBar(0.84, 0.92, 0.16, 0.04, true) My write:Server Side: function chushihua (_,player) local pac = getPlayerAccount ( source ) local lhunger= getAccountData (pac, "player.hunger") local chushi = 0 local chushijie = 100 if not getAccountData (pac, "player.hunger") then setAccountData (pac, "gongneng.jiedu", chushijie) outputChatBox ( "Set successfully.", player ) triggerClientEvent ("loadhunger", getRootElement(), lhunger) else outputChatBox ( "successfully", player ) triggerClientEvent ("loadhunger", getRootElement(), lhunger) outputServerLog ("send to client successfully.") end end addEventHandler( "onPlayerLogin", getRootElement(), chushihua ) function dqjie1 (player) if ( client ) then local playeracc = getPlayerAccount ( client ) setAccountData (playeracc, "player.hunger", tostring(dqjie)) end end addEvent ( "saveje", true ) addEventHandler ( "saveje", root, dqjie1 ) Client side : function abcda () mainbar = guiCreateProgressBar(0.84, 0.92, 0.16, 0.04, true) hungerLabel1 = guiCreateLabel(0.96, 0.89, 0.04, 0.03, "hungerBar", true) guiProgressBarSetProgress(mainbar,lhunger) guiLabelSetColor(hungerLabel1,255,255,255) guiSetFont(hungerLabel1,"default-small") end addEvent ( "loadjied", true ) addEventHandler ("loadjied", getRootElement() ,abcda) addEventHandler ("onClientPlayerQuit",getRootElement(), function () dqjie = guiProgressBarGetProgress (mainbar) triggerServerEvent ( "saveje", getRootElement(), tostring(dqjie)) end) but it doesn't work = = Who can help me please Link to comment
Malak Posted February 9, 2015 Share Posted February 9, 2015 Just use ur variable player.hunger it will be the same. where this variable decrease or increase ? (If the variable doesn't move you don't need to save it ) Link to comment
a952637635 Posted February 9, 2015 Author Share Posted February 9, 2015 Just use ur variable player.hunger it will be the same.where this variable decrease or increase ? (If the variable doesn't move you don't need to save it ) I did not show here, he is reduced to a certain time 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