hey guys! How do I make this function so it sorts from
high to low ??
this is from low to high.
function TopKicks(curUser,data)
local Msg = "\r\n"
Msg = Msg .. "\r\n TOP Kickers "
Msg = Msg .. "\r\n -----=============================================================--- "
local temp = {}
local count = ""
local nick = ""
for n, num in TopKickers do
tinsert(temp, num)
nick = n
end
sort(temp)
for i=1,getn(temp) do
local _,_,vCount = strfind(temp[i],"(%S+)")
Msg = Msg.."\r\n "..i..". "..vCount.." "..nick..""
-- count = i
end
Msg = Msg .. "\r\n "
-- Msg = Msg .. "\r\n Total Users Online: "..count..""
Msg = Msg .. "\r\n -----=============================================================--- "
curUser:SD(BotName,Msg)
end
plz help me out.
maby a wild idea but i think the sort function is the one you need too reverse
Yes but how... Hopping you all have some good explainings &
solves tomorrow. Gonna sleep now.
Plz help me out.
And one other thing. I don't seam to get the right name
with right number.
Getting same name on everyone.
/ThX
local nick = ""
for n, num in TopKickers do
tinsert(temp, num)
nick = n
end
sort(temp)
for i=1,getn(temp) do
local _,_,vCount = strfind(temp,"(%S+)")
Msg = Msg.."\r\n "..i..". "..vCount.." "..nick..""
--count = i
end
Msg = Msg .. "\r\n "
well... I am no good explainer, but...
you do nick = n, well okey then nick will be you last n form for n,num in.... you run through the whole table...
so what do you need, you also need to insert the into your temp table. either as string or staright as a table..
I'll just give you the code..
for n, num in TopKickers do
tinsert(temp, { num,n })
end
sorting
sort(temp, function(a,b) rerutn(a[1] > b[1]) end)
hm... I don#t get this part, but if you need the strfind to get the number, well.. then
for i=1,getn(temp) do
local _,_,vCount = strfind(temp[1],"(%S+)")
Msg = Msg.."\r\n "..i..". "..vCount.." "..temp[2]..""
end
if sort shows it from low 2 high all you gotta do is walk thru it in reverse.
for i=getn(temp),1 do
plop
have you ever tried your func.
only way to do what you want is to do like
for i = -(getn(temp)),-1 do
i = i*-1
end
for i = getn(tmp), 1, -1 do ..
its the same.
but well there are many ways.
when I think of it, even more...
can you also do in a nicer way
for i = -(getn(temp)),-1 do
i = i*-2
end
you shouldnt change i inside the block.. why complicate it anyway?
So is there another way? I guess not,
well if I should have problems then i'll just create another variable.
lua has its own way.. what i just posted
for i = getn(tmp), 1, -1 do ..
QuoteOriginally posted by c h i l l a
its the same.
but well there are many ways.
when I think of it, even more...
can you also do in a nicer way
for i = -(getn(temp)),-1 do
i = i*-2
end
???
Thx alot guys for helping me out on this, learn a few new things again.
final code:
function TopKicks(curUser,data)
local Msg = "\r\n"
Msg = Msg .. "\r\n TOP Kickers "
Msg = Msg .. "\r\n -----=============================================================--- "
Msg = Msg .. "\r\n Rank Kicks Nicks"
Msg = Msg .. "\r\n ????? ????? ?????"
local temp = {}
for n, num in TopKickers do
tinsert(temp, { num,n })
end
sort(temp, function(a,b) return(a[1] > b[1]) end)
for i=1,getn(temp) do
Msg = Msg .. "\r\n "..i..". "..temp[i][1].." "..temp[i][2]..""
end
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n -----=============================================================--- "
curUser:SD(BotName,Msg)
end
How Do I make a total count over the kicks ??? can't seam to get that thing right either.
ThX guys you're the best.
/NL
QuoteOriginally posted by tezlo
for i = getn(tmp), 1, -1 do ..
whoeps your right, forgot the ,-1.
plop
Plop you showed me for a time ago How to "add" values togheter and getting one how did I do that now again.
plz help.
There's no need helping me more here solved it.
Please post the solution, so everybody in here can take benefits from it.
sure no prob.
function TopKicks(curUser,data)
local Msg = "\r\n"
Msg = Msg .. "\r\n TOP Kickers "
Msg = Msg .. "\r\n -----=============================================================--- "
Msg = Msg .. "\r\n Rank Kicks Nicks"
Msg = Msg .. "\r\n ????? ????? ?????"
local temp = {}
local count = 0
local you = ""
for n, num in TopKickers do
tinsert(temp, { num,n })
count = count + num
end
sort(temp, function(a,b) return(a[1] > b[1]) end)
for i=1,getn(temp) do
if curUser.sName == temp[i][2] then
you = "\r\n --------------------------------------------------------------------------------------------------------------\r\n"
else
end
Msg = Msg .. "\r\n"..you.." "..i..". "..temp[i][1].." "..temp[i][2].." "..you..""
if you then
you = ""
end
end
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n Total: "..count.." kick(s)"
Msg = Msg .. "\r\n -----=============================================================--- "
curUser:SD(BotName,Msg)
end
QuoteOriginally posted by NightLitch
Plop you showed me for a time ago How to "add" values togheter and getting one how did I do that now again.
plz help.
don't ask so soon, i knew you could do it. lol
naaa was busy on other things, trying 2 learn lua 5.0.
but if you want a quick answer, pm me in my hub with the url.
plop
what is faster
i = 1,10^6,100
or i = 1,10^4
i = i*100
what about
i = 1,8
i = i^3
can this be done more nicely?