Players PvP Stats menu

User Tag List

Results 1 to 4 of 4
  1. #1
    shadowslayer133's Avatar Active Member
    Reputation
    61
    Join Date
    May 2008
    Posts
    313
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Players PvP Stats

    I was experimenting with LUA tables and eventually wrote a lua script that stored stats, and displayed stats when requested.

    Type #Stats
    Typing that will display your kills your deaths and you K/D Ratio
    This works well on PvP servers where people are curious on how well they are doing.

    Code:
    TEST_Death = {}
    TEST_Kill = {}
    TEST_KD = {}
    TEST_NAME = {}
    local KDMessage = "#stats"
    
    function KillDeath_OnChat(event, plr, message, type, language)
    
    	if (message == KDMessage) and (TEST_Death[plr:GetName()] == nil) and (TEST_Kill[plr:GetName()] == nil) then
    		TEST_Death[plr:GetName()] = 0
    		TEST_Kill[plr:GetName()] = 0
    	end
    
    	if (message == KDMessage) and (TEST_Kill[plr:GetName()] == nil) then
    		TEST_Kill[plr:GetName()] = 0
    
    	end
    
    	if (message == KDMessage) and (TEST_Death[plr:GetName()] == nil) then
    		TEST_Death[plr:GetName()] = 0
    
    	end
    
    	if (message == KDMessage) then  
    
    		TEST_NAME[plr:GetName()] = plr:GetName()
    		plr:SendBroadcastMessage("|cFF0000FF Stats since last server restart")
    		plr:SendBroadcastMessage("|cFFFF0000 "..TEST_NAME[plr:GetName()].." Stats")
    		plr:SendBroadcastMessage("|cFFFFFF00 Kills: "..TEST_Kill[plr:GetName()].."")
    		plr:SendBroadcastMessage("|cFFFFFF00 Deaths: "..TEST_Death[plr:GetName()].."")
    		TEST_KD[plr:GetName()] =  TEST_Kill[plr:GetName()] / TEST_Death[plr:GetName()]
    			if (TEST_Death[plr:GetName()] == 0) and (TEST_Kill[plr:GetName()] == 0) then
    			TEST_KD[plr:GetName()] =  0
    			end		
    		plr:SendBroadcastMessage("|cFFFFFF00 Kills to deaths ratio: "..TEST_KD[plr:GetName()].."")
    	
    	end
    end
    
    function TEST_Death.OnKillPlayer(event, pPlayer)
    	TEST_Death[pPlayer:GetName()] = TEST_Death[pPlayer:GetName()] or 0 --assigns the variable to 0 if one doesn't exist
            TEST_Death[pPlayer:GetName()] = TEST_Death[pPlayer:GetName()] + 1
    	pPlayer:SendBroadcastMessage("|cFFADD8E6 You have died "..TEST_Death[pPlayer:GetName()].." times since the server restarted.")
    end
    
    function TEST_Kill.OnKillPlayer2(event, pPlayer, pVictim)
    	TEST_Kill[pPlayer:GetName()] = TEST_Kill[pPlayer:GetName()] or 0
    	TEST_Kill[pPlayer:GetName()] = TEST_Kill[pPlayer:GetName()] + 1
    	pPlayer:SendBroadcastMessage("|cFFADD8E6 You have Killed "..TEST_Death[pPlayer:GetName()].." people since the server restarted.")
    end
    
    
    RegisterServerHook(6, TEST_Death.OnKillPlayer)
    RegisterServerHook(2, TEST_Kill.OnKillPlayer2)
    RegisterServerHook(16, "KillDeath_OnChat")
    Edit, fixed and also fixed 0 / 0
    Last edited by shadowslayer133; 06-11-2010 at 01:48 PM.

    Done by piersd
    Gamer tag - Midnight133

    Players PvP Stats
  2. #2
    Kirsebaer's Avatar Banned
    Reputation
    6
    Join Date
    Nov 2008
    Posts
    156
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now we'll just wait for Stoneharry to correct the script :P

  3. #3
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why use so many global tables? Why not use one metatable instead of polluting the global namespace?
    Ignorance is bliss.

  4. #4
    Ground Zero's Avatar ★ Elder ★
    Reputation
    1132
    Join Date
    Aug 2008
    Posts
    3,503
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure to test your script before releasing it.

    I'm going to close this, if you want me to reopen it so you can update it with the working version PM me.

Similar Threads

  1. [Selling] 6x 90's with good pvp stats
    By MikkelKampmann in forum WoW-EU Account Buy Sell Trade
    Replies: 1
    Last Post: 10-08-2013, 05:38 AM
  2. force players' pvp flag on
    By spacemonkey999 in forum WoW EMU Exploits & Bugs
    Replies: 4
    Last Post: 03-25-2010, 11:14 PM
  3. How Do You Change Your Player's Stats On A Private Server?
    By JaredStratton in forum WoW EMU Questions & Requests
    Replies: 8
    Last Post: 05-16-2009, 08:12 AM
  4. [Release] Basic Wotlk Beta style website with signup and pvp stats!
    By Hasbro in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 07-19-2008, 11:08 PM
All times are GMT -5. The time now is 07:48 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search