Problems With Random Messages
 

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

Problems With Random Messages

Started by DorianG, 17 February, 2004, 02:01:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DorianG

i don't undertand because the random message doesn't start.

BotName = "???[Bot]M?GAPLATZ???"

nummsgop = 9

dofile("files/msgop.lua")

function Main()
	frmHub:RegBot(BotName)
end

function Opconnected(user)
	reply = Random(user)
	SendToAll(BotName,reply)
end

function Flood(user)
	s,e,cmd,str,num,msg = strfind(data, "%b<>%s(%S+)%s(%S+)%s(%S+)%s(%S+)")
		if cmd ~= nil and str ~= nil and num ~= nil and msg ~= nil then
			SendToNick(user.sName, BotName, "Hai floodato "..str.." per "..num.." volte con il messaggio  "..msg)
			count = tonumber(num)
			for z = 1, count do
			SendPmToNick(str, BotName, msg)
			end
		elseif str == user.sName then
			SendToNick(user.sName, "Non puoi auto floodarti")
		end
	return 1
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		local s,e,cmd = nil
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
	end
end

in files/msgop there is this code:
function RandomOpMsg(user)
	test = random(nummsgop)
		x1 = user.sName.." appare dalle tenebre"
		x2 = user.sName.." esce fuori da una nube proprio come fanno i ninja"
		x3 = "La sua fama lo precede, ? tra noi "..user.sName
		x4 = "Tutti lo conoscono tutti ci hanno parlato, ma nessuno in realt? sa chi si cela dientro "..user.sName
		x5 = user.sName.." ? entrato, state attenti faker"
		x6 = user.sName.." ? qui tra noi, non so voi ma io scappo :D"
		x7 = user.sName.." ? arrivato miticooooooooooooo"
		x8 = user.sName.." spalanca le porte di "..frmHub:GetHubName().." e con il suo scettro da operatore si prepara a distruggere i faker"
		x9 = user.sName.." arriva col suo elicottero e atterra su " ..frmHub:GetHubName()
		dostring("ret=x"..test)
	return ret
end

Stravides

QuoteOriginally posted by DorianG
i don't undertand because the random message doesn't start.

function Opconnected(user)
	reply = Random(user)
	SendToAll(BotName,reply)
end

in files/msgop there is this code:
function RandomOpMsg(user)
	test = random(nummsgop)
		x1 = user.sName.." appare dalle tenebre"

If we just look at the snippet of code here...

     function Opconnected(user)

This should be
     function OpConnected(user)

also in that function you assign a variable the result of a called function that doesnt exist.
     reply = Random(user)

should be
  reply = RandomOpMsg(user)

try that :)

Regards
Stravides
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

DorianG

thanks Stravides, but there is an other error.
i have try that:
BotName = "???[Bot]M?GAPLATZ???"

nummsgop = 9

dofile("files\msgop.lua")

function Main()
	frmHub:RegBot(BotName)
end

function OpConnected(user)
	reply = RandomOpMsg(user)	--//line12
	SendToAll(BotName,reply)
end

function Flood(user)
	s,e,cmd,str,num,msg = strfind(data, "%b<>%s(%S+)%s(%S+)%s(%S+)%s(%S+)")
		if cmd ~= nil and str ~= nil and num ~= nil and msg ~= nil then
			SendToNick(user.sName, BotName, "Hai floodato "..str.." per "..num.." volte con il messaggio  "..msg)
			count = tonumber(num)
			for z = 1, count do
			SendPmToNick(str, BotName, msg)
			end
		elseif str == user.sName then
			SendToNick(user.sName, "Non puoi auto floodarti")
		end
	return 1
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		local s,e,cmd = nil
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
	end
end
But Ptokax tell me: Syntax error: attempt to call global `RandomOpMsg' (a nil value)
stack traceback:
   1:  function `OpConnected' at line 12

nErBoS

#3
Hi,

the problem is in this line...
dofile("files\msgop.lua")

it should be...
dofile("files/msgop.lua")

Best regards, nErBoS
--## nErBoS Spot ##--

DorianG

ok, thank nerbos ;)

SMF spam blocked by CleanTalk