Tomc0 Posted August 31, 2013 Share Posted August 31, 2013 Hello guys, I have a really big problem. I'm writing a DD addon with a GUI system, and there's a statistics system. The problem is, when a player dies, the resource adds everyone +1 deaths, and I don't want that: I only want to add that death to the player that died... How is it possible? How I can refresh the GUI just for one player? Thanks! Link to comment
K4stic Posted August 31, 2013 Share Posted August 31, 2013 Hello guys, I have a really big problem. I'm writing a DD addon with a GUI system, and there's a statistics system.The problem is, when a player dies, the resource adds everyone +1 deaths, and I don't want that: I only want to add that death to the player that died... How is it possible? How I can refresh the GUI just for one player? Thanks! i have one simple question how we can help you without code? Link to comment
Tomc0 Posted August 31, 2013 Author Share Posted August 31, 2013 I've just asked for a technique for it, but here's a part of the code: SERVER: function getDiesOnLogin() totalDies = getAccountData(account,"totalDies") or 0 setAccountData(account,"totalDies",totalDies or 0) totalStatDies = getAccountData(account,"totalStatDies") or 0 setAccountData(account,"totalStatDies",totalStatDies or 0) triggerClientEvent("updateDieStats",getRootElement(),totalDies) triggerClientEvent("updateTotalDieStats",getRootElement(),totalStatDies) end addEventHandler("onPlayerLogin",getRootElement(),getDiesOnLogin) addEvent("onCountDie",true) function countDie() totalDies = tonumber(getAccountData(account,"totalDies")) + 1 totalStatDies = tonumber(getAccountData(account,"totalStatDies")) + 1 triggerEvent("onCountDie",getRootElement()) end addEventHandler("onPlayerWasted",getRootElement(),countDie) function setDieData() setAccountData(account,"totalDies",totalDies) setAccountData(account,"totalStatDies",totalStatDies) triggerClientEvent("updateDieStats",getRootElement(),totalDies) triggerClientEvent("updateTotalDieStats",getRootElement(),totalStatDies) end addEventHandler("onCountDie",getRootElement(),setDieData) CLIENT: addEvent("updateDieStats",true) addEvent("updateTotalDieStats",true) function getDies(dies) totalDies = dies guiSetText(gui["diesLabel"],tostring(totalDies)) end addEventHandler("updateDieStats",getRootElement(),getDies) function getTotalDieStats(dies) totalStatDies = dies guiSetText(gui["totalDiesLabel"],tostring(totalStatDies)) end addEventHandler("updateTotalDieStats",getRootElement(),getTotalDieStats) function drawStatWindow() gui = {} gui._placeHolders = {} local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 270, 178 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "Statistics", false) guiWindowSetSizable(gui["_root"], false) gui["tabWidget"] = guiCreateTabPanel(0, 20, 272, 149, false, gui["_root"]) gui["tab"] = guiCreateTab("Month", gui["tabWidget"]) gui["diesLabel"] = guiCreateLabel(160, 79, 46, 13, "N/A", false, gui["tab"]) guiLabelSetHorizontalAlign(gui["diesLabel"], "left", false) guiLabelSetVerticalAlign(gui["diesLabel"], "center") end addEventHandler("onClientResourceStart",getRootElement(),drawStatWindow) I hope this will be enough... Thanks! Link to comment
Castillo Posted August 31, 2013 Share Posted August 31, 2013 Well, just trigger the event to the player that died, 'source' in this case. triggerClientEvent ( source, "updateDieStats", source, totalDies ) triggerClientEvent ( source, "updateTotalDieStats", source, totalStatDies ) 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