Scripting Help - Page 2
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Scripting Help

Started by Yahoo, 01 May, 2007, 14:07:38

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Naithif

Quote from: CrazyGuy on 05 May, 2007, 13:12:59
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

bastya_elvtars

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.

Yahoo

if i want to display the date in the following format
Thursday, May 17, 2007 19:47
what should be my code
"BoRN FIGhTEr"

Thor

Code: lua
os.date("%A, %b %d, %Y %H:%M")

Yahoo

thanks for the code i will test it later
can any 1 tell me wat is wrong with the following code
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"

Naithif

Quote from: Yahoo 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
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 ;)

Yahoo

still not getting. can u tell me my mistake
"BoRN FIGhTEr"

Naithif

#32
@ 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
Quotezztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'

Your problem is:


Spoiler warning!



'end' used too many times


Yahoo

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
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"

Yahoo

sorry sir i didnt get u can u tell a little more in brief and the full script
"BoRN FIGhTEr"

Psycho_Chihuahua

as Mutor has said already LUA is Case Sensitive

so change
return tCmds[cmd](User, data)

to
return tCmds[cmd](user, data)


because User is NOT = user

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
[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

Yahoo

thanks for all the help
"BoRN FIGhTEr"

speedX

Could someone plzz explain me this.
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

achiever

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,
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.

achiever

now thats some explaination!!!

thks mutor
thks,
achiever.

SMF spam blocked by CleanTalk