XPro Posted August 22, 2015 Posted August 22, 2015 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
Walid Posted August 22, 2015 Posted August 22, 2015 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
XPro Posted August 22, 2015 Author Posted August 22, 2015 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??
Walid Posted August 22, 2015 Posted August 22, 2015 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
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