[Useful Function]IRC 1-2 New Functions by Jagat -
Niko_boy - 28.01.2012
AKA Jagat
So What it is all about!
I was making a irc echo filterscript i.e. a bot for a server.Yesterday I finished it off, but i soon realised code was full with some spam lines! or whatever you will call it !
So I made a function for sending ingame strings to IRC easily even you can use it in samp functions!
e.g.
We cant use
Код:
Irc_Say(botid,channel,string);
we have to use it like
Код:
IRC_Say(nBotID,IRC_Channel,string);
which are defined above and we cant make messages vary with different levels , i mean hidden from differnt irc Levels!
so the function i made will help you to use it like that^^
PART1:
Код HTML:
forward MessageToIRC(const chan[],level,const string[]);
i made it with several practicals! if you dont want to put channel in every line you can use it like
PART2:
Код:
forward MessageToIRCAdmins(level,const string[])
+++++++++++++++++++
- Cases :
- 0=normal irc user , no level
- 1=voice (+v)with + as prefix in name
- 2=halfop(+h)with % as prefix in name
- 3=Op(+o)with @ as prefix in name
- 4=Admin(+a)with & as prefix in name
- 5=Owner (+q)with ~ as prefix in name
+++++++++++++++++++
i posted different examples for each part
down there:-
Part1 practical with defining channel in each line!
PHP код:
ICMD(teststring)
{
new string[128],levels,chans[64];
if(sscanf(params, "s[80]is[128]",chans,levels,string)) return MessageToIRCAdmins("#gs_samp.echo",2,"IRC command Error: !teststring <levels> <string>");
MessageToIRCAdmins(chans,levels,string);
return 1;
}
Part2 practical without defining channel in each line!
PHP код:
ICMD(teststring)
{
new string[128],levels;
if(sscanf(params, "is[128]",levels,string)) return MessageToIRCAdmins(2,"IRC command Error: !teststring <levels> <string>");
MessageToIRCAdmins(levels,string);
return 1;
}
So thats it! I hope i am clear to you with its functioning!
HERE IS THE CODE:
For PART1:-
PHP код:
forward MessageToIRCAdmins(const chan[],level,const string[]);
public MessageToIRCAdmins(const chan[],level,const string[])
{
new levelbeen[32];
switch(level){
case 1:{levelbeen="+";}
case 2:{levelbeen="%";}
case 3:{levelbeen="@";}
case 4:{levelbeen="&";}
case 5:{levelbeen="~";}
}
new levelstring[80];
format(levelstring,sizeof(levelstring),"%s%s",levelbeen,chan);
IRC_Say(nBotID[0],levelstring,string);
print(levelstring);
print(string);
printf("Level:%i or %d",level,level);
return 1;
}
For PART2:-
PHP код:
#define channel_echo "#channel.echo"// On top of script below #include <a_samp>
forward MessageToIRCAdmins(level,const string[]);
public MessageToIRCAdmins(level,const string[])
{
new levelbeen[32];
switch(level){
case 1:{levelbeen="+";}
case 2:{levelbeen="%";}
case 3:{levelbeen="@";}
case 4:{levelbeen="&";}
case 5:{levelbeen="~";}
}
new levelstring[80];
format(levelstring,sizeof(levelstring),"%s%s",levelbeen,channel_echo);
IRC_Say(nBotID[0],levelstring,string);
return 1;
}
Note 2:- if you using part 2, you have to change
Quote:
#define channel_echo "#channel.echo"
|
where
#channel.echo where you want your bot to send message!
THATS ALL!
Thanks to SAMP !,and thanks to Incognito for his
IRC PLUGIN, and thanks to SAFC/Outbreak for telling me another use of IRC_Say
[ i was using IRC_sendraw earlier for it which was tougher though]
Install Steps:
Copy The Code paste
forwards at top
and
public thing some where in between
publics or at
end of script!
Usage:-
Part1: MessageToIRCAdmins(const chan[],level,const string[]) const chan[] , the channel where message u want to send , this is defined at top of ur script with #define channel_echo "#CHANNEL"++ Instruction of Part2: | |Part2: MessageToIRCAdmins(level,const string[]) where level is from 0-5 there is no limit for it u can use above 5 too , but that not gonna work!const string, the string you want to be send as message to a level on IRC |
Re: [Useful Function]IRC 1-2 New Functions by Jagat -
thimo - 28.01.2012
Nice work!
Re: [Useful Function]IRC 1-2 New Functions by Jagat -
SpiderWalk - 28.01.2012
Great work!
Re: [Useful Function]IRC 1-2 New Functions by Jagat -
Niko_boy - 29.01.2012
thanks!

)
Note:- You might see the messages for ~#chan in the IRC query window idk for me it appear like that,
I have talked to some people ! they said it can happen cause of BNC if u using one!
__________________________
Re: [Useful Function]IRC 1-2 New Functions by Jagat -
Ballu Miaa - 30.01.2012
Arree this is nice! Good job Hindustaani bhai xD