Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 5 of 5
  1. #1
    Contributor
    shadowslayer133's Avatar
    Join Date
    Jan 2009
    Posts
    53
    Post Thanks / Like
    Rep Power
    17
    Reputation
    92

    Post Players PvP Stats


    Register to remove this ad
    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")
    Fixed 0/0 problem


    › See More: Players PvP Stats
    Last edited by shadowslayer133; 11-06-10 at 06:14 AM.



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Elite Member
    Dimman's Avatar
    Join Date
    Apr 2009
    Posts
    1,091
    Post Thanks / Like
    Rep Power
    21
    Reputation
    319
    Thanks for sharing =)
    2 bad i have no rep power left now lol, but i will give you rep when i can & gratz on contributor in 1 rep =)
    No touching please.

  4. #3
    Senior Sergeant
    .SalMAX™'s Avatar
    Join Date
    Mar 2010
    Location
    Miami, Florida
    Posts
    100
    Post Thanks / Like
    Rep Power
    15
    Reputation
    52
    Nice Nice.

    I will Add You, you're Last reputation so You can Earn that Contributor, hopefully you will be as nice to others as I am to you.
    Don't Forget to for useful releases!. It gives you good luck! Just Like Lucky charms!

  5. #4
    Contributor
    shadowslayer133's Avatar
    Join Date
    Jan 2009
    Posts
    53
    Post Thanks / Like
    Rep Power
    17
    Reputation
    92
    Thanks Dimarxx

  6. #5
    Contributor
    Pedregon's Avatar
    Join Date
    Jul 2008
    Posts
    89
    Post Thanks / Like
    Rep Power
    18
    Reputation
    81

    Register to remove this ad
    Great release, this could be useful when experimenting with armor stats, etc.
    + rep

 

 

Visitors found this page by searching for:

Nobody landed on this page from a search engine, yet!
SEO Blog

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 02:26 AM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org