PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: electronic_Psycho on 24 July, 2006, 16:02:39

Title: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 24 July, 2006, 16:02:39
Hello ppl ?;D

i need help plz to convert the script to lua 5.1 ..

****
its work with 5.1 but the problem its all the time give me other mistake.. [sorry on my bad english!]
i hope that someon can helo me with that.. ?::)
tnx! ?:-*
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 24 July, 2006, 16:12:50
hi again,,? ;D

sorry to distub? ????

i have 1 mor script that i need help with convert to lua 5.1 . is some on can help.. tnx a loot!? ;)
***
------------------------------------------------------------------------------------------------
----//? ?Loggin by TiMeTrAVelleR Fixed By Optimus //-----------------
----------------------------- Converted to Lua 5 by jiten------------------------
----//? Mor status & edit by: ElecTronic??.Psycho! //----------------
------------------------------------------------------------------------------------------------
----// Set here your bot name

sBotName = ".???iN-System???."

kb = 1024
mb = kb*kb
gb = kb*kb*kb
tb = kb*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)/(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

border1 = "1"
border2 = "2"
disp = "\r\n\r\n"..border1.."\r\n"

disp = disp.." 02\r\n"

disp = disp.." 03\r\n"

disp = disp.." 04\r\n"

disp = disp.." 05\r\n"

disp = disp.." 06\r\n"

disp = disp.." 07\r\n"

disp = disp.." 08\r\n"
disp = disp.." 09"\r\n"

disp = disp.." 10 "..doGetProfile .."\r\n"

disp = disp.." 11 "..user.sIP.."\r\n"
disp = disp.." 12 "..minshare.."\r\n"
disp = disp.." 13\r\n"
disp = disp.." 14\r\n"

disp = disp.." 15 ".. hubshare.." TiB\r\n"

disp = disp.." 16 "..frmHub: GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online. .\r\n"
disp = disp.." 17 "..ProfileCounter("Netfounder").." [Hub-oWner] - "..ProfileCounter("Master").." [Master's] - "..ProfileCounter ("Operator").." [oP's] - "..ProfileCounter("Moderator").." [-S-Vip's] - "..ProfileCounter("Vip").." [Vip's] - "..ProfileCounter("reg").." [reg's] \r\n"

disp = disp.." 18 "..frmHub: GetHubDescr().."\r\n"

disp = disp.." 19 \r\n"..border2.."\r\n"

user:SendData(sBotName, disp)

end
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: jiten on 24 July, 2006, 17:27:52
Quote from: electronic_Psycho on 24 July, 2006, 16:02:39
Hello ppl ?;D

i need help plz to convert the script to lua 5.1 ..

****
its work with 5.1 but the problem its all the time give me other mistake.. [sorry on my bad english!]
i hope that someon can helo me with that.. ?::)
tnx! ?:-*

What about using the latest bastya_elvtars' FreshStuff?

If not, try Mutor's '50to51' converter.
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 24 July, 2006, 17:42:01
hi jiten .. good evening!  :)

tnx u for replay!!

i try to use with "50to51"

but not work for me :(  [some eror i get]

& i see new version of this script & the true.. i dont like the look of them.. :(

i want this script.. i try myself do it before i post it in the forum.. but.. nit succses on my side.

plz help with script...  :'(

the eror i get is "Release Bot.lua:520: attempt to call a table value"

& the other script "login in"

dont work at all... plz some on help me...

tnx!!  :-X

electric_sycho ;)
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: jiten on 24 July, 2006, 18:12:26
If that's so, in lines 520 and 536, replace:

for i,v in _table do

with:

for i,v in pairs(_table) do

The same goes for line 457.
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 24 July, 2006, 18:36:36
tnx you very much jiten!!!  :-*

my release bot work.. tnx u!!

i try to do the same in my "login in" script .. lol

but now i got this eror "Online-C.lua:26: bad argument #1 to 'pairs' (table expected, got nil)"

***
--// 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
***
i think that is be the same but like u see dont work... plz help  :-[

tnx allot
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: Markitos on 24 July, 2006, 19:08:05
Quote from: electronic_Psycho on 24 July, 2006, 18:36:36
i think that is be the same
It's the same way. Use your head otherwise someone will help you
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: jiten on 24 July, 2006, 19:19:30
Quote from: electronic_Psycho on 24 July, 2006, 18:36:36
but now i got this eror "Online-C.lua:26: bad argument #1 to 'pairs' (table expected, got nil)"
i think that is be the same but like u see dont work... plz help? :-[

Well, the profile names in your code aren't correct:

disp = disp.." 17 "..ProfileCounter("Netfounder").." [Hub-oWner] - "..ProfileCounter("Master").." [Master's] - "..ProfileCounter ("Operator").." [oP's] - "..ProfileCounter("Moderator").." [-S-Vip's] - "..ProfileCounter("Vip").." [Vip's] - "..ProfileCounter("reg").." [reg's] \r\n"

They are case-sensitive.
For more details, have a look at Profiles.xml under your \cfg folder.

Therefore, you must change the existing [and incorrect] entries to NetFounder, VIP and Reg.
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 25 July, 2006, 02:30:13
tnx u jiten & tnx you Markitos !   :)

i try do all.. but all the time i got the eror..

i try reflace to original names like in Profiles.xml .. but the same..

"scripts\Online-C.lua:26: bad argument #1 to 'pairs' (table expected, got nil)"

  :-\

u can help plz ? i dunnu how ::)
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: Markitos on 25 July, 2006, 08:25:52
Another great way to use the lenght operator. [How i'm stupid, damit!]
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 25 July, 2006, 13:18:44
 ;D
Tnx You Very Much.. Mutor Jiten Markitos  :-*
work good !!
i try to do what u say jiten but.. i dunno .. the same eror..
when i removed the line
**
disp = disp.." 17 "..ProfileCounter("Netfounder").." [Hub-oWner] - "..ProfileCounter("Master").." [Master's] - "..ProfileCounter ("Operator").." [oP's] - "..ProfileCounter("Moderator").." [-S-Vip's] - "..ProfileCounter("Vip").." [Vip's] - "..ProfileCounter("reg").." [reg's] \r\n"

**
the script work all is good..

"Netfounder" "reg"  "Vip"

itry change them to like in profiles.xml
but nothing..
the same eror..

now tnx to mutor.. i can use it :D

tnx allot!  :D
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 26 July, 2006, 19:10:04
hi ..  ;D

i need help with that plz

"for key, value in tTable do"   
line 457

some on can tall me what to do plz..

i try byself but.. i dunno how.. ???

plz help.. tnx ;)
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: 6Marilyn6Manson6 on 26 July, 2006, 19:25:08
Change:

for key, value in tTable do

whit:

for key, value in pairs(tTable) do
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 26 July, 2006, 22:45:19
hi Mutor.. :)

i do read i reflace the line with the new' that u give me..

but then i gor eror so i think that not like this its need be..? :-[

i got this eror**

Release Bot.lua:457: bad argument #1 to 'pairs' (table expected, got nil)

**
-----------
function Serialize(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" );
for i,v in pairs(_table) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write(sTab.."\t"..sKey.." = "..sValue);
end
hFile:write(",\n");
end
hFile:write(sTab.."}");
end

--------------------

i do it wrong ?? ???

tnx? :)
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 26 July, 2006, 22:53:29
 ;D ..
i dont see what 6Marilyn6Manson6 write before..

tnx u 6Marilyn6Manson6 tnx u mutor.. tnx all  :-*

its w o r k..

tnx
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 27 July, 2006, 00:14:54
hi again  ;D

sorry to disrtub u all..

what line shuld be if i have this line "for _,Nick in frmHub:GetOnlineUsers() do"

its a clon bot . i got this eror.. "Clone Alert.lua:39: attempt to call a table value"

if someon can help tnx allot  :)
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 27 July, 2006, 05:03:20
Morning ppl..  :o

i want ask mutor something,, i dont c it before  ???

"There are : 1 [Hub-oWner] - 5 [Master's] - 18 [oP's] - 67 [-S-Vip's] - 74 [Vip's] - 126 [reg's] online .  . . "

its can be that the script show all the reg users by profile ' but not who is realy online ?

***
--// Profile Counter
function ProfileCounter(profile)
   local count = 0
   if GetUsersByProfile(profile)then
      count = #GetUsersByProfile(profile)
   end
   return count
end
***
this the problem line i think..

u can help me plz to fix that the script show who is online & not show all the reg users by profile?

i sorry.. i dont good scripter  ::)

tnx
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: Markitos on 27 July, 2006, 08:58:45
Quote from: electronic_Psycho on 27 July, 2006, 00:14:54
Quote from: Mutor on 26 July, 2006, 19:54:40
Dont be afraid to read  :P
what line shuld be if i have this line "for _,Nick in frmHub:GetOnlineUsers() do"


Quote from: electronic_Psycho on 27 July, 2006, 05:03:20
its can be that the script show all the reg users by profile ' but not who is realy online ?
It's true maybe this does the trick
--// Profile Counter by Mutor
function cProfile(what)
local disp = ""
local table,online,offline,count = GetUsersByProfile(what),0,0,0
for i, User in pairs(table) do
count = #GetUsersByProfile(what)
if GetItemByName(User) then
online = online + 1
else
offline = offline + 1
end
end
disp = disp.."Total: "..count.."\tOnline: "..online.."\tOffline: "..offline
return disp
end
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: electronic_Psycho on 27 July, 2006, 10:52:53
Hi Markitos  ;)

tnx u very Much!!  :D

i found it  ;D

***
--// Profile Counter     
function ProfileCounter(profile)   
      local table, count = GetUsersByProfile(profile),0
      for i,User in pairs(table) d
      if GetItemByName(User) then
       count = count + 1
       end
     end
     return count
end
***
:) tnx
Title: Re: Help me plz to convert the script to lua 5.1 :)
Post by: Markitos on 27 July, 2006, 10:54:56
Indeed, another way.