PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: [NL]trucker on 05 March, 2004, 11:25:38

Title: help please explanation needed.
Post by: [NL]trucker on 05 March, 2004, 11:25:38
hello folks  

i tried to make this script to work  but ervrytime i start it up
it gives me the error [eof] expected in the lat line.

can someone explain why?

======================================

--test by [NL]trucker.


--// 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 NewUserConnected(user)
   Message(user)
end

function OpConnected(user)
   Message(user)
end

function Message(user)
       local disp = ""
       doGetProfile =  GetProfileName(user.iProfile) or "Not registerd"
       return 1
end

        disp = disp.."   ==================================================================="
        disp = disp.."   ?There are:    "..ProfileCounter("Master").." [MASTER] -\r\n"
        disp = disp.."   ?There are:     "..ProfileCounter("Operator").." [OPERATOR] -\r\n"
        disp = disp.."   ?There are:     "..ProfileCounter("Vip").." [VIP]- \r\n"
        disp = disp.."   ?There are:     "..profilecounter("Reg").." [Registerd users]- online \r\n"
   disp = disp.."   \r\n\r\n"
        disp = disp.."   ?There are now:   "..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online\r\n"
        disp = disp.."   ==================================================================="
     
        user:SendData(BotName, disp)
    end
========================================

i want a bit of explanation cause it is driving me crazy.
Title:
Post by: VERMiN on 05 March, 2004, 13:00:00
All your disp = disp lines are not within a function.

Your last "end" doesn't end anything then ;)
Title:
Post by: [NL]trucker on 05 March, 2004, 17:19:37
so what you are saying is that i should replace
disp = disp

with something like this

SendToUser SendToAll(BotName,)

and then it should work?
Title:
Post by: [NL]trucker on 05 March, 2004, 17:57:31
oke i have come this far :

xxxxxxxxxxxxxxxxxxxxxxxxxxxxx


--test by [NL]trucker.

function Main()
botname = "=[INFO]="

--// 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 NewUserConnected(user)
   Message(user)
end

function OpConnected(user)
   Message(user)
end

function Message(user)
       local disp = ""
       doGetProfile =  GetProfileName(user.iProfile) or "Not registerd"
       return 1
end

        SendToAll(BotName,"===================================================================")
        SendToAll(BotName,"   ?There are:    "..ProfileCounter("Master").." [MASTER] -\r\n")
        SendToAll(BotName,"   ?There are:     "..ProfileCounter("Operator").." [OPERATOR] -\r\n")
        SendToAll(BotName,"   ?There are:     "..ProfileCounter("Vip").." [VIP]- \r\n")
        SendToAll(BotName,"   ?There are:     "..profilecounter("Reg").." [Registerd users]- online \r\n")
   SendToAll(BotName,"   \r\n\r\n")
        SendToAll(BotName,"   ?There are now:   "..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online\r\n")
        SendToAll(BotName,"===================================================================")
     
        user:SendData(BotName, disp)
    end



xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Syntax error: attempt to call global `profilecounter' (a nil value)
stack traceback:
   1:  function `Main' at line 36 [file `D:\==PTOTAX==\trucker\scripts\usercount.lua']

there is no main in line 36
Title:
Post by: Optimus on 05 March, 2004, 17:58:45
Here ya go ...

--test by [NL]trucker.

BotName = "-Info-"

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)
local disp = ""
doGetProfile =  GetProfileName(user.iProfile) or "Not registerd"
disp = disp.." \r\n===================================================================\r\n"
disp = disp.." ?There are: "..ProfileCounter("Master").." [MASTER] online\r\n"
disp = disp.." ?There are: "..ProfileCounter("Operator").." [OPERATOR] online\r\n"
disp = disp.." ?There are: "..ProfileCounter("Vip").." [VIP] online\r\n"
disp = disp.." ?There are: "..ProfileCounter("Reg").." [Registerd users] online \r\n"
disp = disp.." \r\n"
disp = disp.." ?There are now: "..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." users Online\r\n"
disp = disp.." ==================================================================="
user:SendData(BotName, disp)
end



Title:
Post by: [NL]trucker on 05 March, 2004, 18:49:16
Optimus

your my lifesaver [ugh ugh] :-))


works perfect

thnx a lot.
Title:
Post by: pHaTTy on 05 March, 2004, 18:56:31
yah gekko uses same method :)