Jump to content

Need some small help with IRC Echo


DazzaJay

Recommended Posts

ok...

we have a Customised version of IRC Echo....

Now, my Most recent change isnt working.

(Not only is the change not working, its Stopped Players join message from Relaying to the IRC Alltogether)

Ok, this is what i changed:

BEFORE:

function onPlayerJoin() 
    if pIRC then 
        ircMessage( pIRC, szChans[ pIRC ], "3* " .. getClientName( source ) .. " joined the server." ) 
    end 
end 

AFTER:

function delayedjoin() 
    if pIRC then 
        ircMessage( pIRC, szChans[ pIRC ], "3* " .. getClientName( source ) .. " joined the server." ) 
    end 
end 
  
function onPlayerJoin() 
  setTimer ( delayedjoin, 500, 1) 
end 

Which Just results in:

WARNING: IRC Echo.lua: Bad Argument @ 'getClientName' - Line 64

ERROR: IRC Echo.lua:64: attempt to concatenate a boolean value.

Whatever the hell that means.

Ok, what i am Trying to do is Delay the Join message that is Relayed to IRC by 500MS. as When a Player joins with the name "Player" their name is changed by This Script LINK

And i want it to Relay the Name the Server changed it to, not the one they first joined with.

Previously when the Script changed to their mtabeta Username, the IRC Echo worked fine and relayed that name. But the New Auto-Ranamer is a Little Slower. So, IRC is saying their name before Its changed.

And here is the Full script.

--// VRockers MTASA IRC Echo \\-- 
--//--- Created by VRocker ---\\-- 
  
--//------- Functions: -------\\-- 
  
-- ircInit() - Initializes the module with the resource so it can be used 
-- ircOpen( IP, Port, Nick, Channel, [ Password ] ) - Readys a connection to a specified IRC Server. Returns IRCConnection 
-- ircDisconnect( IRCConnection ) - Disconnects from the IRC Server 
-- ircMessage( IRCConnection, text ) - Sends a message to the current IRC channel 
-- ircNotice( IRCConnection, Nick, text ) - Sends a notice to Nick 
-- ircChangeNick( IRCConnection, newNick ) - Changes the bots nickname to newNick 
-- ircJoin( IRCConnection, channel ) - Joins a channel 
-- ircPart( IRCConnection, channel) - Parts a channel 
-- ircRaw( IRCConnection, text ) - Sends raw commands to the IRC Server 
-- ircIsVoice( IRCConnection, szChan, szNick ) - Checks if the nickname is voiced on the channel 
-- ircIsHalfop( IRCConnection, szChan, szNick ) - Checks if the nickname is a half op on the channel 
-- ircIsOp( IRCConnection, szChan, szNick ) - Checks if the nickname is an op on the channel 
-- ircIsSuper( IRCConnection, szChan, szNick ) - Checks if the nickname is a super op on the channel 
-- ircIsOwner( IRCConnection, szChan, szNick ) - Checks if the nickname is an owner on the channel 
-- ircGetStatus( IRCConnection, szChan, szNick ) - Returns the status of the person ( 0 = no status, 5 = owner ) 
  
--//-------- Callbacks: -------\\-- 
-- irc_onConnecting( IP, Port ) - Called when the IRC connection is connecting 
-- irc_onConnected() - Called when the server is connected 
-- irc_onDisconnected() - Called when the server loses connection to the IRC server 
-- irc_onFailedConnection() - Called when the server loses connection to the IRC server 
-- irc_onPrivMsg( nick, text ) - Called when somebody speaks in the current channel or PMs the bot 
-- irc_onNotice( nick, text ) - Called when the bot is sent a notice 
-- irc_onJoin( nick, channel ) - Called when a user enters the channel 
-- irc_onPart( nick, channel ) - Called when a user leaves the channel 
-- irc_onQuit( nick, text ) - Called when a user quits IRC 
-- irc_onNickChange( oldNick, newNick ) - Called when somebody changes their nickname 
-- irc_onRaw( text ) - Called when an unrecognised IRC command is recieved 
  
root = getRootElement() 
szChans = {} 
  
function irc_sendMsg ( msg ) 
  ircMessage( pIRC, szChans[ pIRC ], msg )   
end 
  
function onResourceStart( res ) 
    ircInit( ) 
  
    if ( res == getThisResource () ) then 
        pIRC = ircOpen( "irc.rizon.net", 6667, "[RACE]", "#potholestudios" ) 
        szChans[ pIRC ] = "#potholestudios" 
    end 
     
end 
  
function onResourceStop( res ) 
    if ( res == getThisResource () ) then 
        if pIRC then 
            ircDisconnect( pIRC ) 
            pIRC = nil 
        end 
    end 
     
end 
  
function delayedjoin() 
    if pIRC then 
        ircMessage( pIRC, szChans[ pIRC ], "3* " .. getClientName( source ) .. " joined the server." ) 
    end 
end 
  
function onPlayerJoin() 
  setTimer ( delayedjoin, 500, 1) 
end 
  
function onPlayerQuit( reason ) 
    if pIRC then 
        ircMessage( pIRC, szChans[ pIRC ], "4* " .. getClientName( source ) .. " left the server. (" .. reason .. ")" ) 
    end 
end 
  
function onPlayerChat( text ) 
    if pIRC then 
    if ( not getElementData ( source, "autils.muted" ) ) then 
          ircMessage( pIRC, szChans[ pIRC ], "12 " .. getClientName( source ) .. ":1 " .. text ) 
    end 
    end 
end 
  
--// Callbacks \\-- 
function irc_onConnecting( szIP, usPort ) 
    outputServerLog( "Connecting to IRC (" .. szIP .. ":" .. tostring( usPort ) .. ")" ) 
end 
  
function irc_onConnected() 
    outputServerLog( "IRC Connected!" ) 
end 
  
function irc_onDisconnected() 
    outputServerLog( "IRC Disconnected :(" ) 
end 
  
function irc_onPrivMsg( szChannel, szNick, szText ) 
    outputServerLog( "IRC <> " .. szNick .. ": " .. szText ) 
     
outputChatBox(szNick .. " [iRC]: " .. szText ) 
    if string.find( szText, "!players" ) == 1 then 
        ircMessage( pIRC, szChannel, "7There are currently " .. getPlayerCount() .. " players connected" ) 
    end 
end 
  
function irc_onNotice( szFrom, szTo, szText ) 
    outputServerLog( "IRC Notice <> " .. szFrom .. ": " .. szText ) 
     
    if szFrom == "NickServ" then 
        if string.find( szText, "This nickname is registered" ) then 
            ircMessage( pIRC, "nickserv", "identify yourpasshere" ) 
        end 
    end 
end 
  
function irc_onJoin( szChan, szNick ) 
    outputServerLog( "IRC <> " .. szNick .. " joined " .. szChan ) 
  --outputChatBox ( "IRC: "..szNick .. " joined " .. szChan, getRootElement(), 150, 0, 240  ) 
end 
  
function irc_onPart( szChan, szNick ) 
    outputServerLog( "IRC <> " .. szNick .. " left " .. szChan ) 
  --outputChatBox ( "IRC: "..szNick .. " left " .. szChan, getRootElement(), 150, 0, 240  ) 
end 
  
function irc_onQuit( szNick ) 
    outputServerLog( "IRC <> " .. szNick .. " quit IRC." ) 
  --outputChatBox ( "IRC: "..szNick .. " quit IRC", getRootElement(), 150, 0, 240  ) 
end 
  
function irc_onRaw( text ) 
    --outputServerLog( text ) 
end 
  
function irc_onNickChange( oldNick, newNick ) 
    outputServerLog( "IRC <> " .. newNick .. " changed their nick to " .. oldNick ) 
  --outputChatBox ( "IRC: "..oldNick .. " changed his nick to " .. newNick, getRootElement(), 150, 0, 240  ) 
end 
  
  
addEventHandler( "onResourceStart", root, onResourceStart ) 
addEventHandler( "onResourceStop", root, onResourceStop ) 
addEventHandler( "onPlayerJoin", root, onPlayerJoin ) 
addEventHandler( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler( "onPlayerChat", root, onPlayerChat ) 
addEventHandler( "onPlayerWasted", root, onPlayerWasted ) 

Any ideas?

Link to comment
function delayedjoin(player) 
    if pIRC then 
        ircMessage( pIRC, szChans[ pIRC ], "3* " .. getClientName( player ) .. " joined the server." ) 
    end 
end 
  
function onPlayerJoin() 
  setTimer ( delayedjoin, 500, 1, source) 
end 

Just an explanation:

delayedjoin was triggered by setTimer, thus doesn't have a "source". (or well it does, but it isn't really usable) So that's why the warning comes and returns a bool.

Bool concatenation isn't possible. On a page I posted recently, (this one) you could see it's only really used for numbers to convert them to strings. It also works for strings since it's already a string. But it doesn't work for bool and userdata, since it just doesn't seem to be designed for them. That's why the error appeared. Remove the warning, and you'll remove the error! ;)

Link to comment

Thanks. will try it out in a sec.

+++++++++++++++++++++++++

:::EDIT:::

Thanks, Works Well.

+++++++++++++++++++++++++

:::EDIT:::

I auctually have a Question for another script.

Is it Possible for a Script to Load another seperate resource (NOT by the meta.xml) But on a Timer.

So like....

On resource load (this script) (No, not the IRC one, a different one)

Set timer 15 Seconds.

Like, does this look like it will work?

function delayedload2() 
    startResource ( racerank ) 
end 
  
function delayedload1() 
  setTimer ( delayedload2, 15000, 1 ) 
end 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),delayedload1) 

Timer Loads resource "racerank"

The main reason i am asking this is our Race Records system for DM has gotten to the Stage where the SQL Database is so big, that the Resource, if Loaded By the server on startup, Just causes the server to crash, because the SQL system is still loading. Instead having to not load the resource with the server, but manually later.

Thus why i want a script that will wait 15 seconds, then load racerank resource.

----------------------------------------

:::EDIT:::

Well, i cloned my server so i didnt have to take it offline to test, and the script seems to work all for one thing.

WARNING: racerankloader.lua: bad argument @ startResource - Line: 2

No clue what i did wrong....

Concidering i worked from this: http://development.mtasa.com/index.php? ... rtResource

function delayedload2() 
    startResource ( racerank ) 
end 
  
function delayedload1() 
  setTimer ( delayedload2, 15000, 1 ) 
end 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),delayedload1) 

Link to comment

Im not sure if im seeing the link between that and the script not being able to start a resource. (yes im blind)

like, i can start it with /start racerank

but that script above cant do it for some reason (yes, i added it in the ACL)

:::EDIT:::

All good, Winky showed what i was doing wrong.

function delayedload2() 
    startResource ( getResourceFromName("racerank") ) 
end 
  
function delayedload1() 
  setTimer ( delayedload2, 10000, 1 ) 
end 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),delayedload1) 

it works.

Link to comment

Yeah, it causes Server Crashes.

But only if you /stop or /start it, or restart it.

If it loads with the server, and i leave it alone, it does its job and dosent stuff around.

any idea on if anyone is bringing out a Better IRC Module? like, ive tried other scripts, which none work with Rizon. but they all use the same Module.

Link to comment

Oh, i thaught it was to do with the module, mainly because of what it does when a person Joins the IRC Channel, (or is it quits the IRC channel)

i think its Quits.

When somone joins the IRC, it shows in the server window

[PS]DazzaJay[AU] has Joins #PotholeStudios IRC (or somthing like that)

But on quit of the IRC Channel....

IT(^#$P&T#@$&)Ptudos IRC (quit)

or somthing like that.

is that bug the Module, or is it also DP2?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...