PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: electronic_Psycho on 29 March, 2005, 20:22:30

Title: Need Help With convert. someon plz,,,
Post by: electronic_Psycho on 29 March, 2005, 20:22:30
Hello..
i have a problem with this script..
i want 2 convert it 2 lua 5.. someon can help
please..

Code:
-----------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
---// Loggin by TiMeTrAVelleR Fixed By Optimus //----------
-----------------------------------------------------------------------------------mor status by: ElecTronic??.Psycho!
------------------------------------------------------------------------------------------------------------------------------

BotName = "bot" --// Set here your bot name

kb = 1024
mb = kb*kb
gb = kb*kb*kb

function NewUserConnected(user)
Message(user)
end

function OpConnected(user)
Message(user)
end

--// Profile Counter
function ProfileCounter(profile)
local table, count = GetUsersByProfile(profile), 0
for i, User in table do
if GetItemByName(User) then
count = count + 1
end
end
return count
end

function Message(user)
if user.sMyInfoString then
local disp = ""
doGetProfile = GetProfileName(user.iProfile) or "Not registerd"
hubshare = format("%0.2f", frmHub:GetCurrentShareAmount()/(1024)/(1024)/(1024))
local _,_,share = strfind(user.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )

if share then
minshare = format("%0.2f", tonumber(share)/gb).." GB"
else
minshare = "Corrupt"
end
end

border1 = "       ::?:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::?::"
border2 = "       ::?:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::?::"
disp = "\r\n\r\n"..border1.."\r\n"
disp = disp.."       - ? - Welcome .. "..user.sName.."\r\n"
disp = disp.."       - ? - Welcome To.. "..frmHub:GetHubName().." ! enjoy.. \r\n"
disp = disp.."       - ? - Your IP is: "..user.sIP.."\r\n"
disp = disp.."       - ? - Your Share is: "..minshare.."\r\n"
disp = disp.."       - ? - Your Status in this Hub is: "..doGetProfile.."\r\n"
disp = disp.."       - ? - Actual Share in the Hub is: "..hubshare.." GB\r\n"
disp = disp.."       - ? - There are: "..ProfileCounter("Master").." [Masters] - "..ProfileCounter("Netfounder").." [S'ops] - "..ProfileCounter("Operator").." [Op'S] - "..ProfileCounter("Moderator").." [S'Vips] - "..ProfileCounter("Vip").." [Vips] - "..ProfileCounter("reg").." [reg]  online\r\n"
disp = disp.."       - ? - There are now: "..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online\r\n"
disp = disp.."       - ? - Hub description is: "..frmHub:GetHubDescr().."\r\n"
disp = disp.."       - ? - Hub MinShare is: - 5 - GB.\r\n"
disp = disp.."       - ? - Hub MinSlots is: - 3 - \r\n"
disp = disp.."       - ? - Redirect address is : "..frmHub:GetRedirectAddress().."\r\n"  
disp = disp.."       - ? - Hub Powerd By: Ruri_Ruri?\r\n"..border2.."\r\n"


user:SendData(BotName, disp)
end
Title:
Post by: jiten on 29 March, 2005, 20:34:52
Try this:

-----------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
---// Loggin by TiMeTrAVelleR Fixed By Optimus //----------
-- Converted to Lua 5 by jiten
-----------------------------------------------------------------------------------mor status by: ElecTronic??.Psycho!
------------------------------------------------------------------------------------------------------------------------------

BotName = "bot" --// Set here your bot name

kb = 1024
mb = kb*kb
gb = kb*kb*kb

function NewUserConnected(user)
Message(user)
end

function OpConnected(user)
Message(user)
end

--// Profile Counter
function ProfileCounter(profile)
local table, count = GetUsersByProfile(profile), 0
for i, User in table do
if GetItemByName(User) then
count = count + 1
end
end
return count
end

function Message(user)
if user.sMyInfoString then
local disp = ""
doGetProfile = GetProfileName(user.iProfile) or "Not registerd"
hubshare = string.format("%0.2f", frmHub:GetCurrentShareAmount()/(1024)/(1024)/(1024))
local _,_,share = string.find(user.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
if share then
minshare = string.format("%0.2f", tonumber(share)/gb).." GB"
else
minshare = "Corrupt"
end
end

border = "  ::?:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::?::"
disp = "\r\n\r\n"..border.."\r\n"
disp = disp.." - ? - Welcome .. "..user.sName.."\r\n"
disp = disp.." - ? - Welcome To.. "..frmHub:GetHubName().." ! enjoy.. \r\n"
disp = disp.." - ? - Your IP is: "..user.sIP.."\r\n"
disp = disp.." - ? - Your Share is: "..minshare.."\r\n"
disp = disp.." - ? - Your Status in this Hub is: "..doGetProfile.."\r\n"
disp = disp.." - ? - Actual Share in the Hub is: "..hubshare.." GB\r\n"
disp = disp.." - ? - There are: "..ProfileCounter("Master").." [Masters] - "..ProfileCounter("Netfounder").." [S'ops] - "..ProfileCounter("Operator").." [Op'S] - "..ProfileCounter("Moderator").." [S'Vips] - "..ProfileCounter("Vip").." [Vips] - "..ProfileCounter("reg").." [reg] online\r\n"
disp = disp.." - ? - There are now: "..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online\r\n"
disp = disp.." - ? - Hub description is: "..frmHub:GetHubDescr().."\r\n"
disp = disp.." - ? - Hub MinShare is: - 5 - GB.\r\n"
disp = disp.." - ? - Hub MinSlots is: - 3 - \r\n"
disp = disp.." - ? - Redirect address is : "..frmHub:GetRedirectAddress().."\r\n"
disp = disp.." - ? - Hub Powerd By: Ruri_Ruri?\r\n"..border.."\r\n"
user:SendData(BotName, disp)
end


Best regards,

jiten
Title:
Post by: electronic_Psycho on 31 March, 2005, 02:49:52
tnx jiten !  ;)

But now i have other problem .. ?(  

-------------------------------
.3.3.0.b16.09\scripts\onlinel05.lua:46: unfinished string near `"  ::?::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'

i try 2 find what is this. but i dont.. :(

i'm a  new 1 in scrits

you can help me please with this "string near" ?
Title:
Post by: The_Fox on 31 March, 2005, 03:49:13
QuoteOriginally posted by electronic_Psycho
tnx jiten !  ;)

But now i have other problem .. ?(  

-------------------------------
.3.3.0.b16.09\scripts\onlinel05.lua:46: unfinished string near `"  ::?::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'

i try 2 find what is this. but i dont.. :(

i'm a  new 1 in scrits

you can help me please with this "string near" ?

It's quite easy... look in the code and find these lines:
   border1 = "  ::?::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::?::"
   border2 = "  ::?::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::?::"

  The strings are incorrectly broken into lines - strings need to be closed in double quotes on each line and multi-line strings have to be concatenated using double dot (..) command... look at your old code and use the lines with border1 and border2 from your old version =)

  Btw. it doesn't make much sense to create two same variables (border1 and border2), but to doesn't do no bad neither, so you can just ignore this last sentence :o)
Title:
Post by: electronic_Psycho on 31 March, 2005, 06:36:49
hello..

Tnx The_Fox  :D

now i have other problem..

 :(  :(

Help please..

eror :
----------------------------------------------
\0.3.3.0.b16.09\scripts\onlinel05.lua:61: attempt to concatenate a nil value
Title:
Post by: jiten on 31 March, 2005, 10:17:55
First post updated  :]
Title:
Post by: The_Fox on 31 March, 2005, 14:24:56
electronic_Psycho: I'll try to reinsert the code as it should be, so you won't have any trouble anymore... I've tested it and it works

-----------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
---// Loggin by TiMeTrAVelleR Fixed By Optimus //----------
-- Converted to Lua 5 by jiten
-----------------------------------------------------------------------------------mor status by: ElecTronic??.Psycho!
------------------------------------------------------------------------------------------------------------------------------

BotName = "bot" --// Set here your bot name

kb = 1024
mb = kb*kb
gb = kb*kb*kb

function NewUserConnected(user)
Message(user)
end

function OpConnected(user)
Message(user)
end

--// Profile Counter
function ProfileCounter(profile)
local table, count = GetUsersByProfile(profile), 0
for i, User in table do
if GetItemByName(User) then
count = count + 1
end
end
return count
end

function Message(user)
if user.sMyInfoString then
local disp = ""
doGetProfile = GetProfileName(user.iProfile) or "Not registerd"
hubshare = string.format("%0.2f", frmHub:GetCurrentShareAmount()/(1024)/(1024)/(1024))
local _,_,share = string.find(user.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
if share then
minshare = string.format("%0.2f", tonumber(share)/gb).." GB"
else
minshare = "Corrupt"
end
end

[U]border = "   ::?::::::::::::::::::::::::::::::::::::::::::::::::::?::"[/U]  
disp = "\r\n\r\n"..border.."\r\n"
disp = disp.." - ? - Welcome .. "..user.sName.."\r\n"
disp = disp.." - ? - Welcome To.. "..frmHub:GetHubName().." ! enjoy.. \r\n"
disp = disp.." - ? - Your IP is: "..user.sIP.."\r\n"
disp = disp.." - ? - Your Share is: "..minshare.."\r\n"
disp = disp.." - ? - Your Status in this Hub is: "..doGetProfile.."\r\n"
disp = disp.." - ? - Actual Share in the Hub is: "..hubshare.." GB\r\n"
disp = disp.." - ? - There are: "..ProfileCounter("Master").." [Masters] - "..ProfileCounter("Netfounder").." [S'ops] - "..ProfileCounter("Operator").." [Op'S] - "..ProfileCounter("Moderator").." [S'Vips] - "..ProfileCounter("Vip").." [Vips] - "..ProfileCounter("reg").." [reg] online\r\n"
disp = disp.." - ? - There are now: "..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online\r\n"
disp = disp.." - ? - Hub description is: "..frmHub:GetHubDescr().."\r\n"
disp = disp.." - ? - Hub MinShare is: - 5 - GB.\r\n"
disp = disp.." - ? - Hub MinSlots is: - 3 - \r\n"
disp = disp.." - ? - Redirect address is : "..frmHub:GetRedirectAddress().."\r\n"
disp = disp.." - ? - Hub Powerd By: Ruri_Ruri?\r\n"..border.."\r\n"
user:SendData(BotName, disp)
end

Note: I had to change the string in the line which is underlined, so it wouldn't be broken into lines anymore... this is the original one, you can replace the line:
border = " ::?:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::?::"
Title:
Post by: jiten on 31 March, 2005, 14:40:28
Oops, I forgot that by copying all that line here, he would divide it in others, because it was very big.

Yups, it's just like The_Fox said, the trick is to put those 3 lines together.

Cheers.
Title:
Post by: electronic_Psycho on 01 April, 2005, 00:40:19
tnx ..jiten
& tnx The_Fox  

it work now :D

now i heppy ;)

Tnx ..