Jump to content

help in my cod


XPro

Recommended Posts

Posted

i need to get name player who have best killes in sniper (just the gun sniper)

addEventHandler("onPlayerWasted",getRootElement(), 
function ( ammo, attacker, weapon, bodypart ) 
    if attacker then 
        if ( attacker ~= source and getElementType ( attacker ) == "player" ) then 
        local playergun =  getWeaponNameFromID  ( attacker ) 
            if ( playergun == 34 ) then 
            setElementData ( attacker, "kills" ) 
                end 
            end 
        end 
    end 
) 
  
  
-- 
Snipers = { } 
  
addEventHandler("onElementDataChange",root, 
function (dataName) 
    if dataName == "kills" then 
        for _,v in ipairs (getElementsByType ("player")) do 
            table.insert ( Snipers, { getPlayerName(v), ( getElementData ( v, "kills" ) or 0 ) }) 
        end 
    table.sort (Snipers,function (v1, v2)return v1[2] > v2[2]end) 
    outputChatBox (Snipers[1][1].." - "..Snipers[1][2]) 
    end 
end ) 

cod no work

debug said = Bad argument @ 'getWeaponNameFromID' [Expected number at argument 1,got player ]

+ after fix the cod how to get sccore the player who have best killes sniper

because i need to get hes name + sccor

+ how to put hes name and sccore in GUI use gridlist + row ....?

+ soory for my bad english xD

Posted
local snipers = {} -- snipers table 
  
addEventHandler("onPlayerWasted",getRootElement(), 
    function ( ammo, attacker, weapon, bodypart ) 
        if attacker and getElementType ( attacker ) == "player" and attacker ~= source then 
            if tonumber(weapon) == 34 then 
                snipers[attacker] = (snipers[attacker] or 0) + 1 
            end 
        end 
    end 
) 
  
-- Table sort  
  
function topSniper() 
    sortedTopSniper = {} 
    for a, b in pairs(snipers) do 
        table.insert(sortedTopSniper, {getPlayerName(a), b}) 
    end 
    table.sort(sortedTopSniper, function(a,b) return a[2] > b[2] end) 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

but you don' use Element Data because i need to save number kills ..

and i want getplayername (best kills sniper) and put it in GUI i finshe the gui how to put hes name and sccore in this gui?

use Row??

Posted

open your use i already gave you the solution.

example:

-- sortedTopSniper[1][1] : sinper name 
-- sortedTopSniper[1][2] : Number of kill 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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