Jump to content

Stats system script


Recommended Posts

Hi guys,I am not even close to a person,who could call himself a scripter,im just regular MTA player,who plays all gamemodes....................(short pause and a lot uninteresting facts about servers my gaming history in MTA,i play etc,etc)

......................................................................................................................................................

and thenI founded a new GCC clan,and decided to make 3 very good non lagging,pro scripted servers,with stats system and all kind a stuff.

Plan is to make a servers with a simple additions,and maybe some new inovative ones.I am not going to reveal all ideas in public but I would like if you could bring some ideas here about scripts,resources and other stuff you want to see in the server,including what type of new gamemode(if you have idea on that issue)

But first just one simple question,does anyone here know how to make a stats system for a stealth server(also Base Mode,and all kinds of shooting modes) I found one realy good on the Server Gta.RU and i was wondering if any of you could help me with making a stats system ?

it looks like this

stats.jpg

AGAIN SORRY FOR MY BAD ENGLISH,AND NOT VERY CLEAR IDEAS,I just wrote this minds on top of my head. Tnx all in advance!

Link to comment

Well.. you'll need to store the kills, deaths, headshots somewhere and then make a simple script to get them & the ratio.

This should be a good start:

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) 

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