Author Topic: Scripting Help  (Read 12988 times)

0 Members and 1 Guest are viewing this topic.

Offline Naithif

  • Triple Ace
  • **
  • Posts: 199
  • Karma: +32/-13
Re: Scripting Help
« Reply #25 on: 05 May, 2007, 14:47:50 »
This is not exactly true.
NewUserConnected handles all users with a profile with bIsOP = 0 , and unregistered users.
Subtle, yet important difference if you use custom profile permissions  ::)

By default, me refers to default profile setting (;D)
Anyway, in 99% this is the case, also if robocop, or leviathan profiles are in use

PtokaX forum

Re: Scripting Help
« Reply #25 on: 05 May, 2007, 14:47:50 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Scripting Help
« Reply #26 on: 05 May, 2007, 16:20:47 »
Should I install the 'spoiler tag' plugin for howto's? ;D
Everything could have been anything else and it would have just as much meaning.

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #27 on: 17 May, 2007, 17:25:03 »
if i want to display the date in the following format
Thursday, May 17, 2007 19:47
what should be my code
"BoRN FIGhTEr"

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Re: Scripting Help
« Reply #28 on: 17 May, 2007, 18:42:40 »
Code: Lua
  1. os.date("%A, %b %d, %Y %H:%M")

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #29 on: 17 May, 2007, 19:49:20 »
thanks for the code i will test it later
can any 1 tell me wat is wrong with the following code
Code: [Select]
sBot = frmHub:GetHubBotName()

ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p   Date: %A, %b %d, %Y "))
end
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y   Time: %I:%M:%S %p "))
end
end,
}

if tCmds[cmd] then
return tCmds[cmd](User, data)
end
end

end
ToArrival = ChatArrival
i am getting the following error
zztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'
"BoRN FIGhTEr"

Offline Naithif

  • Triple Ace
  • **
  • Posts: 199
  • Karma: +32/-13
Re: Scripting Help
« Reply #30 on: 17 May, 2007, 21:17:01 »
thanks for the code i will test it later
can any 1 tell me wat is wrong with the following code
Code: [Select]
sBot = frmHub:GetHubBotName()

ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p   Date: %A, %b %d, %Y "))
end
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y   Time: %I:%M:%S %p "))
end
end,
}

if tCmds[cmd] then
return tCmds[cmd](User, data)
end
end

end
ToArrival = ChatArrival
i am getting the following error
zztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'

Hint:
You're trying to close too many times ;)

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #31 on: 18 May, 2007, 07:00:35 »
still not getting. can u tell me my mistake
"BoRN FIGhTEr"

Offline Naithif

  • Triple Ace
  • **
  • Posts: 199
  • Karma: +32/-13
Re: Scripting Help
« Reply #32 on: 18 May, 2007, 10:44:30 »
@ B?stya -> Hints are just not working

(And next time if someone got a problem, then paste the script you got the error with, as line 15 is 'end,' no '{'-s there
Quote
zztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'

Your problem is:

Spoiler warning!


'end' used too many times

« Last Edit: 18 May, 2007, 10:51:23 by Naithif »

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #33 on: 18 May, 2007, 11:06:48 »
thanks sir i got the problem
but now i am getting a new error
zztime bot.lua:17: attempt to index global 'user' (a nil value)
zztime bot.lua:20: attempt to index global 'user' (a nil value)
can any1 giv me hint
the edited script looks like this
Code: [Select]
sBot = frmHub:GetHubBotName()

ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p   Date: %A, %b %d, %Y "))
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y   Time: %I:%M:%S %p "))
end,
}

if tCmds[cmd] then
return tCmds[cmd](User, data)
         end
        end
end
ToArrival = ChatArrival
"BoRN FIGhTEr"

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #34 on: 18 May, 2007, 13:21:23 »
sorry sir i didnt get u can u tell a little more in brief and the full script
"BoRN FIGhTEr"

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: Scripting Help
« Reply #35 on: 18 May, 2007, 13:27:19 »
as American Idiot has said already LUA is Case Sensitive

so change
Code: [Select]
return tCmds[cmd](User, data)to
Code: [Select]
return tCmds[cmd](user, data)
because User is NOT = user

Code: [Select]
sBot = frmHub:GetHubBotName()

ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p   Date: %A, %b %d, %Y "))
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y   Time: %I:%M:%S %p "))
end,
}

if tCmds[cmd] then
return tCmds[cmd](user, data)
         end
        end
end
ToArrival = ChatArrival

results in
Code: [Select]
[13:15:16] <Psycho_Chihuahua> time
[13:15:19] <Time> Time: 01:15:19 PM   Date: Friday, May 18, 2007
[13:15:19] <Psycho_Chihuahua> !time
[13:15:23] <Time> Date: Friday, May 18, 2007   Time: 01:15:23 PM
[13:15:23] <Psycho_Chihuahua> !date
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Scripting Help
« Reply #36 on: 18 May, 2007, 15:04:36 »
thanks for all the help
"BoRN FIGhTEr"

Offline speedX

  • Lord
  • ***
  • Posts: 437
  • Karma: +59/-19
Re: Scripting Help
« Reply #37 on: 19 May, 2007, 06:44:05 »
Could someone plzz explain me this.
Code: [Select]
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
Thanking You,

speedX

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #38 on: 19 May, 2007, 09:23:19 »
Code: [Select]
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
the second line is the capture pattern of strings

math.modf function is used, i think for geting the fraction and integer differently (its acually used to spilt the 2 parts if m not wrong)

os.date() this fuction returns the date and time

this all i can guess but,
Code: [Select]
local sBot,h,m = "Time",math.modf(([b]os.time()-os.time(os.date"!*t"[/b]))/ 3600)
what this ((os.time()-os.time(os.date"!*t"))/ 3600) is even i would like to understand

thks,
thks,
achiever.

Offline achiever

  • Lord
  • ***
  • Posts: 260
  • Karma: +25/-22
Re: Scripting Help
« Reply #39 on: 19 May, 2007, 09:56:30 »
now thats some explaination!!!

thks American Idiot
thks,
achiever.

PtokaX forum

Re: Scripting Help
« Reply #39 on: 19 May, 2007, 09:56:30 »