28.01.2012, 17:27
(
Последний раз редактировалось Niko_boy; 29.01.2012 в 15:05.
)
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);
Код:
IRC_Say(nBotID,IRC_Channel,string);
so the function i made will help you to use it like that^^
PART1:
Код HTML:
forward MessageToIRC(const chan[],level,const string[]);
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;
}
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;
}
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;
}
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 |