I want to know how to line up my List's propertly and straight...
this is mine now:
Msg = Msg .. "\r\n ( "..Nick.." )\t( "..byOP.." )\t( "..Count.." )\t( "..Reason.." )"
outcome like this:
NXS-3 Ban Info
( [Local]KR ) ( [SU+]NightLitch ) ( 2 ) ( for no reason )
( [Local]KalleAnkasattp ) ( [SU+]NightLitch ) ( 1 ) ( for no reason )
help plz...
want it to be in straight lines no matter the nicks lenghts.
Hope for good answers.
/NL
*hint* strlen() *hint*
One way of solving it is:
Msg = Msg .. "\r\n ( "..Nick.." )"..strrep(" ", 30 - strlen(Nick)).."( "..byOP.." )"..strrep(" ", 30 - strlen(byOP)).."( "..Count.." )"..strrep(" ", 30 - strlen(Count)).."( "..Reason.." )"
Thx Alot Skrollster. Was thinking in that direction but didn't know how to do it.
Thx / NL
Your fine ex. you sent. Is that supposed to work or just a hint for me do get it working in some way?`
cause with yours I get:
( [Local]KR ) ( [SU+]NightLitch ) ( 2 ) ( for no reason )
( [Local]KalleAnkasattp ) ( [SU+]NightLitch ) ( 1 ) ( for no reason )
plz some help.
*EDITED*
HUH!!! how is that possible here and not in my client ???
Noticed that it wasn't compatible with MS Sans Serif
But that is the standard font for the clients...
Why is it that that ( Courier New ) is the only Font I have that lines up the line right.... why Skrollster ???
I would want it to work with MS Sans Serif...
it will only show up right with fixed fonts (all characters have the same width).. ie. terminal would work as well
as tezlo says it only works with fixed fonts...
but you can get almost perfect by using a formula like(i know this isn't right but you might get it):
Msg = Msg .. "\r\n ( "..Nick.." )"..strrep("\t", 30/(1+strlen(Nick))).."( "..byOP.." )"..strrep("\t", 30/(1+strlen(byOP))).."( "..Count.." )"..strrep("\t", 30/(1+strlen(Count))).."( "..Reason.." )"
i'm using (1+strlen(Count)) to not devide by zero
hope you can get my thought so you can get it to work...
i'm in school right now so i don't know how strrep() will reakt to a real instead of an int, you might have to format it so it becomes an int instead...
Thx Skrollster gonna see what I can come by.
had the same problem the other day so i made these two functions..
function pad(str, len)
local diff = len - strlen(str)
if diff <= 0 then return strsub(str, 1, len-2)..".."
else return str..strrep(" ", diff) end
end
function columnize(...)
local str = ""
for i = 1, getn(arg), 2 do str = str..pad(arg[i], arg[i+1]) end
return str
end
columnize(victim, 25, kicker, 25, count, 5, reason, 25)
maybe it helps..
I had to try this out then i came home this was the result i had:
function StraightLines(Nick, byOP, Count, Reason)
Msg = " ( "..Nick.." )"..strrep("\t", 40/(8+strlen(Nick))).."( "..byOP.." )"..strrep("\t", 40/(8+strlen(byOP))).."( "..Count.." )"..strrep("\t", 40/(8+strlen(Count))).."( "..Reason.." )"
return Msg
end
Nice, Nice NICE!!!!
Thx Alot!!!
Wasn't that big of a different from the first.
But I had never got that out.
/NL
Tezlo i get an error the i try to use your functions:
Syntax error: bad argument #1 to `strlen' (string expected, got nil)
stack traceback:
1: function `strlen' [C]
2: function `pad' at line 16 [file `C:\DC-Hub\Op-m?te\scripts\Test.lua']
3: function `columnize' at line 23 [file `C:\DC-Hub\Op-m?te\scripts\Test.lua']
4: function `OnTimer' at line 12 [file `C:\DC-Hub\Op-m?te\scripts\Test.lua']
function Main()
SetTimer(500)
StartTimer()
end
function OnTimer()
StopTimer()
Skrollster = GetItemByName("Skrollster")
Skrollster.Send = function(self, text) return Skrollster:SendData(Bot, text) end
test = "Test"
Bot = 'PtokaX'
Skrollster:SendPM(Bot,columnize(victim, 25, kicker, 25, count, 5, reason, 25))
end
function pad(str, len)
local diff = len - strlen(str)
if diff <= 0 then return strsub(str, 1, len-2)..".."
else return str..strrep(" ", diff) end
end
function columnize(...)
local str = ""
for i = 1, getn(arg), 2 do str = str..pad(arg[i], arg[i+1]) end
return str
end
try to feed it strings
Sorry, i guess i'm just a bit tired ;)
Seems to work :) cheers m8y
victim =
{
"jasdfjasdflh",
"kjasdkja",
"kjashdflkjashdflkjasdfl",
}
kicker =
{
"kjasdkja",
"kjashdflkjashdflkjasdfl",
"jasdfjasdflh",
}
count =
{
"134",
"1234",
"2",
}
reason =
{
"kjasdkja",
"kjashdflkjashdflkjasdfl",
"jasdfjasdflh",
}
function Main()
SetTimer(500)
StartTimer()
end
function OnTimer()
StopTimer()
Stravides = GetItemByName("Stravides")
Stravides.Send = function(self, text) return Stravides:SendData(Bot, text) end
test = "Test"
Bot = 'PtokaX'
for i=1,3 do
Stravides:SendPM(Bot,columnize(victim[i], 30, kicker[i], 30, count[i], 10, reason[i], 25))
end
end
function pad(str, len)
local diff = len - strlen(str)
if diff <= 0 then return strsub(str, 1, len-2)..".."
else return str..strrep(" ", diff) end
end
function columnize(...)
local str = ""
for i = 1, getn(arg), 2 do str = str..pad(arg[i], arg[i+1]) end
return str
end