Nico.de Posted July 29, 2011 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 !!
Castillo Posted July 29, 2011 Posted July 29, 2011 A "stats" system can be many things... a little more expecific won't kill you. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Nico.de Posted July 29, 2011 Author Posted July 29, 2011 Ehm I want to save Kills , deaths and how many kills were headshots
Zafire Posted July 29, 2011 Posted July 29, 2011 yes it can be many things.. but if you want for load/save data, i recommend u.. use mysql
Castillo Posted July 29, 2011 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Nico.de Posted July 29, 2011 Author 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
Castillo Posted July 29, 2011 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted July 29, 2011 Posted July 29, 2011 That's right. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted July 29, 2011 Posted July 29, 2011 server. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Nico.de Posted July 29, 2011 Author Posted July 29, 2011 Doesn't work It doesn't count kills and deaths..
Castillo Posted July 29, 2011 Posted July 29, 2011 You're logged in? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Nico.de Posted July 29, 2011 Author Posted July 29, 2011 Yes I am.. ! When I play and Kill my Friend o kills 0 deaths 0.00 ratio
Castillo Posted July 29, 2011 Posted July 29, 2011 I don't know, it's suposed to be working fine. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Nico.de Posted July 29, 2011 Author Posted July 29, 2011 On Scoreboard : Kills 3 Deaths 1 But stats everything 0
MTA Team qaisjp Posted July 30, 2011 MTA Team Posted July 30, 2011 Use the EDIT button instead of double posting.
Castillo Posted July 30, 2011 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Nico.de Posted July 30, 2011 Author Posted July 30, 2011 So when the server is online the stats get's saved automaticaly ?
bandi94 Posted July 30, 2011 Posted July 30, 2011 yes if the player is loged in Ingame Name : |DGT|Puma DGT Clan Server 24/7 Owner/Scripter MultiGameMode in progress :
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