Nico.de Posted July 29, 2011 Share Posted July 29, 2011 Hey Scripters Admins and Fans I need help.. I want to make a stats system for our new stealth server.. Please dudes i need help !! Link to comment
Castillo Posted July 29, 2011 Share Posted July 29, 2011 A "stats" system can be many things... a little more expecific won't kill you. Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 Ehm I want to save Kills , deaths and how many kills were headshots Link to comment
Zafire Posted July 29, 2011 Share Posted July 29, 2011 yes it can be many things.. but if you want for load/save data, i recommend u.. use mysql Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 Can somone give me a start ? Link to comment
Castillo Posted July 29, 2011 Share Posted July 29, 2011 addEventHandler("onPlayerLogin",getRootElement(), function () local account = getPlayerAccount(source) local kills = getAccountData(account,"kills") local deaths = getAccountData(account,"deaths") local headshots = getAccountData(account,"headshots") if not kills then setAccountData(account,"kills",0) end if not deaths then setAccountData(account,"deaths",0) end if not headshots then setAccountData(account,"headshots",0) end end) function updatePlayerStats(ammo, attacker, weapon, bodypart) local account = getPlayerAccount(killer) if account then local kills = getAccountData(account,"kills") local headshots = getAccountData(account,"headshots") setAccountData(account,"kills",kills+1) if bodypart == 9 then setAccountData(account,"headshots",headshots+1) end end local accountS = getPlayerAccount(source) if accountS then local deaths = getAccountData(accountS,"deaths") setAccountData(accountS,"deaths",deaths+1) end end addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) function getPlayerStats(thePlayer) local account = getPlayerAccount(thePlayer) if account then local kills = getAccountData(account,"kills") or 0 local headshots = getAccountData(account,"headshots") or 0 local deaths = getAccountData(account,"deaths") or 0 local ratio = string.format("%.2f", kills / deaths) outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) end end addCommandHandler("stats",getPlayerStats) That's a good start, I think. Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 Yeah but i'm a new scripter anyway.. And I ask u is that finished in the way .. ? And what do i need to do then ? Sorry for bad English Link to comment
Castillo Posted July 29, 2011 Share Posted July 29, 2011 You put that in a script .lua you create the meta.xml for it and start the resource, if you don't know how resources works, then take a look here: https://wiki.multitheftauto.com/wiki/Resources Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 And which type is it ? Client or Server ? Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 Doesn't work It doesn't count kills and deaths.. Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 Yes I am.. ! When I play and Kill my Friend o kills 0 deaths 0.00 ratio Link to comment
Castillo Posted July 29, 2011 Share Posted July 29, 2011 I don't know, it's suposed to be working fine. Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 On Scoreboard : Kills 3 Deaths 1 But stats everything 0 Link to comment
Nico.de Posted July 29, 2011 Author Share Posted July 29, 2011 I would say there is no save function Link to comment
qaisjp Posted July 30, 2011 Share Posted July 30, 2011 Use the EDIT button instead of double posting. Link to comment
Castillo Posted July 30, 2011 Share Posted July 30, 2011 Do you know what 'account data' is? is a MTA database system, you can 'save' data in it, and that's what my script does. Link to comment
Nico.de Posted July 30, 2011 Author Share Posted July 30, 2011 So when the server is online the stats get's saved automaticaly ? Link to comment
bandi94 Posted July 30, 2011 Share Posted July 30, 2011 yes if the player is loged in 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