Scripting Help
 

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.

Yahoo

i had join this forum long back for requesting script and now i want to try scripting which can be possible only with the help of all members and scripters of this forum.So i will like to have support of all the members of this forum and this can also help new scripter who have started there scripting recently or want to start with it and it can also reduce the pressure on most of the scripter
I WILL LIKE TO KNOW
1)how can i learn LUA language, which stuff to read or refer to learn this language.
2)i would also like to know the difference between lua 4, 5, 5.1


P.S  i dont know anything about programing or scripting

thanks in advance
"BoRN FIGhTEr"

bastya_elvtars

So, you'd like to start programming in Lua. Your holy bible should be:
- Lua book
- 5.1 reference manual
- PtokaX Wiki
Everything could have been anything else and it would have just as much meaning.

6Marilyn6Manson6

www.lua.org

You find all answers to your questions :D

achiever

if i may suggest its also good to look into others script and modify things and c how they work.
still i m no one to even suggest u this, but can be helpful ;)
thks,
achiever.

Yahoo

thanks all members for u reply on my post
Quoteif i may suggest its also good to look into others script and modify things and c how they work.
still i m no one to even suggest u this, but can be helpful Wink
i have tried modifying and i can do it upto a extent by then also i am not able to write a script . i just dont qwanna modify scripts i want to create scripts
"BoRN FIGhTEr"

achiever

Quote from: Yahoo on 01 May, 2007, 16:54:51
i just dont qwanna modify scripts i want to create scripts
u r not alone in this.
thks,
achiever.

bastya_elvtars

And also we encourage lua-related discussion here, it's kinda boring to code 'can I have this in PM' issues all the time.
Everything could have been anything else and it would have just as much meaning.

Yahoo

thanks you all the member for your support. the site and the reference manual suggested by the scripter and members are very helpful but the prob is tht they are to big and vast (boaring also) to read with my speed i will require atleast 2 months to read tht whole thing i cant manage tht much time. so can u suggest me any other way through which i can learn the language in small,simple and easy way


thanks in advance
"BoRN FIGhTEr"

bastya_elvtars

I started with creating a simple bot. You should create one too:

  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye
Everything could have been anything else and it would have just as much meaning.

speedX

Quote from: bastya_elvtars on 02 May, 2007, 14:29:04
I started with creating a simple bot. You should create one too:

  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye

Done :D
Thanking You,

speedX

achiever

Quote from: bastya_elvtars on 02 May, 2007, 14:29:04
I started with creating a simple bot. You should create one too:

  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye

here is my try
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
function NewUserConnected(user)
		user:SendData(sBot, mesg)
end
OpConnected = NewUserConnected

function UserDisconnected(user)
	SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected


how is it, i will like to here all suggestions but plzz be abit explainatory ;)
how do u register a bot?

i even tried to do this profile specific
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
mesg2 ="welcome home"
function NewUserConnected(user)
	if user.iProfile ==0 or user.iProfile ==1 then
		user:SendData(sBot, mesg2)
	else 
		user:SendData(sBot, mesg)
	end
end

function UserDisconnected(user)
	SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected


it doesnt work :( what is the change needed.

thks,
thks,
achiever.

bastya_elvtars

If you check whether a user is registered, bRegistered would be a better choice. Registering a bot: hmm, documented.
http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:ptokaxapi#the_frmhub_object
Everything could have been anything else and it would have just as much meaning.

Naithif

#12
Quote from: achiever on 03 May, 2007, 18:50:10
function NewUserConnected(user)
	if user.iProfile ==0 or user.iProfile ==1 then



Hint (SPOILER WARNING!!!)  :)
This'll never be true in itself, you need to do is similarly to disconnection

Quote from: achiever on 03 May, 2007, 18:50:10
OpDisconnected = UserDisconnected



CrazyGuy

Quote from: achiever on 03 May, 2007, 18:50:10
here is my try
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
function NewUserConnected(user)
		user:SendData(sBot, mesg)
end
OpConnected = NewUserConnected

function UserDisconnected(user)
	SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected


This code is actually quite close. It doesn't work because the bot isn't registered, and most clients ignore messages from offline users.

To register your bot:

Main = function()
      frmHub:RegBot(sBot)
end


that should do it :)

bastya_elvtars

I think they don't benefit from directly telling them the solution, we should rather give them hnts.
Everything could have been anything else and it would have just as much meaning.

6Marilyn6Manson6

Quote from: CrazyGuy on 03 May, 2007, 22:43:40
This code is actually quite close. It doesn't work because the bot isn't registered, and most clients ignore messages from offline users.

To register your bot:

Main = function()
      frmHub:RegBot(sBot)
end


that should do it :)

For speedX example:

function Main()
      frmHub:RegBot(sBot)
end


This version is most good :p

Naithif

If only the second version is the one that's not working (as I've suspected), then see my post. The second version misses a line...

6Marilyn6Manson6

Quote from: Mutor on 03 May, 2007, 23:31:22There is no functional difference here.

Sure? but speedX has been only used  mode  funtion name()   only for this my version would be more homogenous ^^

speedX

Bot = frmHub:GetHubBotName()


function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
  if user.bOperator then
    user:SendData(Bot, "Welcome home "..user.sName)
  else
    user:SendData(Bot, "Welcome "..user.sName.." to "..frmHub:GetHubName())
  end
end
OpConnected = NewUserConnected

function UserDisconnected(user)
  SendToAll(Bot, "Goodbye "..user.sName)
end
OpDisconnected = UserDisconnected
Thanking You,

speedX

achiever

Quote from: Naithif on 03 May, 2007, 19:28:46
Hint (SPOILER WARNING!!!)  :)
This'll never be true in itself, you need to do is similarly to disconnection

naithif i did not understand this plzz explain it.

Quote from: bastya_elvtars on 03 May, 2007, 19:28:01
Registering a bot: hmm, documented.
http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:ptokaxapi#the_frmhub_object
thks bastya this was really a good 1 :)
thks,
achiever.

speedX

Quote from: bastya_elvtars on 02 May, 2007, 14:29:04
I started with creating a simple bot. You should create one too:

  • register at startup
  • when a new user connects, greet her
  • when a user disconnects, say goodbye

Next ??
Thanking You,

speedX

achiever

well i m trying to add some more messages and it should send random message
thks,
achiever.

Naithif

#22
Quote from: achiever on 03 May, 2007, 18:50:10

i even tried to do this profile specific
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
mesg2 ="welcome home"
function NewUserConnected(user)
	if user.iProfile ==0 or user.iProfile ==1 then
		user:SendData(sBot, mesg2)
	else 
		user:SendData(sBot, mesg)
	end
end

function UserDisconnected(user)
	SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected


Here's your post.
You got a NewUserConnected function that's targets are users. (user, reg, vip)
You got a profile check that's targets are masters, and ops

Hint 1
NewUserConnected takes all users, regs, and vips, and the if statement filters everyone of them except ops and masters.  ::)


Hint 2
You are missing a line that was present in version 1...


achiever

well yes got it
i had missed OpConnected = NewUserConnected

thks
thks,
achiever.

CrazyGuy

Quote from: Naithif on 05 May, 2007, 01:16:03

Hint 1
NewUserConnected takes all users, regs, and vips, and the if statement filters everyone of them except ops and masters.  ::)


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  ::)

SMF spam blocked by CleanTalk