Jump to content

[HELP]About Progressbars


Recommended Posts

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. :roll: Anyone PRO man know how to write the code? help me please! :) Thanks! :D

PS:China mtasa server technology blockade,so i hope i can learn something form here. :D

   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) 
outputChatBox ( "successfully", player ) 
triggerClientEvent ("loadhunger", getRootElement(), lhunger) 
outputServerLog ("send to client successfully.") 
addEventHandler( "onPlayerLogin", getRootElement(), chushihua ) 

function dqjie1 (player) 
if ( client ) then 
 local playeracc = getPlayerAccount ( client ) 
 setAccountData (playeracc, "player.hunger", tostring(dqjie)) 
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)   
addEvent ( "loadjied", true ) 
addEventHandler ("loadjied", getRootElement() ,abcda) 

addEventHandler ("onClientPlayerQuit",getRootElement(), 
function () 
  dqjie = guiProgressBarGetProgress (mainbar) 
  triggerServerEvent ( "saveje", getRootElement(), tostring(dqjie)) 

but it doesn't work = = Who can help me please :roll:

Link to comment

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