My First script
 

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

My First script

Started by htb222, 31 May, 2005, 07:27:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

htb222

Hy all!
I finished my first script. Is not a very difficult script but i'm glad that this happened.
The script shows time as a user and have functions for users to set an alarm at a specified time.
I hope u enjoy this and i'm listening to all opions.
This is the script:
-- My first script
-- Thanks to all

hours = os.date("%H")
minutes = os.date("%M")
seconds = os.date("%S")
current =hours.."."..minutes.."."..seconds
sec = 1000 
AlarmUsers={}
RemindUsers={}
sMsg=""
-------------------------------------------------------- 
function Main() 
frmHub:RegBot("-=" ..current .."=-") 
SetTimer(sec) 
StartTimer() 
end 
----------
function ChatArrival(user, data)
		data = string.sub(data,1,string.len(data)-1)
		s,e,cmd = string.find(data, "%b<>%s+(%S+)")
	if string.lower(cmd) == "!alarm" then
		local s,e,time,Reminder =  string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
		if time ~= nil and Reminder ~= nil then
		 AlarmUsers[user.sName] = time
		 RemindUsers[user.sName] = Reminder
		 user:SendPM ("Alarm-Bot","You set the alarm at : "..time.." with the reminder: "..Reminder)
		 return 1
		else
		 user:SendData("Sintaxa: !alarm  . Note: Hour format is hour.minutes.seconds. Ex: 07.00.00 for activate the alarm at 7 o'clock in the morning.")
		 return 1
		end
	end
	if string.lower(cmd) == "!delalarm" then
	  if AlarmUsers[user.sName] ~= nil then
		user:SendPM ("Alarm-Bot","The alarm: "..AlarmUsers[user.sName].." with the remider: "..RemindUsers[user.sName]..", was deleted!")
	  else user:SendPM("Alarm-Bot","There is no activated alarm!") 
	  end
	return 1
	end
	if (string.lower(cmd) == "!showalarm") and (user.bOperator) then
	 sMsg = sMsg.."\r\n------------------------------- ALL ALARMS -------------------------------\r\n"
         for i,v in AlarmUsers do
	  sMsg = sMsg.."\t"..i.." has the alarm activated at : "..AlarmUsers[user.sName].." with de reminder: "..RemindUsers[i]
         end
	 sMsg = sMsg.."\r\n-------------------------------------- END --------------------------------------\r\n"
         user:SendPM("Alarm-Bot", sMsg)
	 return 1
	end
end
-------------------------------------------------------- 
function OnTimer() 
frmHub:UnregBot("-=" ..current .."=-") 
hours = os.date("%H")
minutes = os.date("%M")
seconds = os.date("%S")
current =hours.."."..minutes.."."..seconds
for i,v in AlarmUsers do 
 if AlarmUsers[i] == current then 
  TheUser = GetItemByName(i)
  TheUser:SendPM ("Alarm-Bot",RemindUsers[i])
  TheUser:SendData ("Alarma",RemindUsers[i])
  AlarmUsers[TheUser] = nil
  RemindUsers[TheUser] = nil
 end
end
frmHub:RegBot("-=" ..current .."=-") 
end
P.S. Sorry for my english.

TTB

Nice one... keep it up m8!
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

htb222

Thx all. I hope you enjoied! I still wait for others opinios.
Cheers

Skippy84

Hello thats a nice Script :D

i translatet it into german language it can found here

http://skippy.dyndns.ws/Forum/viewtopic.php?p=54#54
 
i found a little mistake


      user:SendPM ("Alarm-Bot","The alarm: "..AlarmUsers[user.sName].." with the reminder: "..RemindUsers[user.sName]..", was deleted!")

and here

  TheUser:SendPM ("Alarm-Bot",RemindUsers)

  TheUser:SendData ("Alarma",RemindUsers)
is Alarma right or is it Alarm-Bot to?

htb222

Yes Skippy84 there was 2 mistakes

1. After user:SendPM ("Alarm-Bot","The alarm: "..AlarmUsers[user.sName].." with the reminder: "..RemindUsers[user.sName]..", was deleted!")
 u will write this:

   AlarmUsers[user.sName] = nil
   RemindUsers[user.sName] = nil

2. Replace string "Alarma" with "Alarm-Bot". The first version was in romanian and when i translated i forgot to translate this.

Thx for translate my script in german.
Thx for show me those 2 errors.
Cheers

SMF spam blocked by CleanTalk