Raised This Month: $12 Target: $400
 3% 

!needadmin script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
STaTic
New Member
Join Date: May 2006
Old 05-16-2006 , 16:22   !needadmin script
Reply With Quote #1

Hey, searched the forum and found the !needadmin function, that parses the message from HLDS to a Irc chan, but it is something wrong, it wont output the message. It says it too short :/

Code:
//Original code by devicenull //modified to do just one simple thing //Be shure to modify the cvars for your use. The vars set her is an example for use on quakenet. //The !needadmin trigger in chat must contain a message, or the user will get a errorr message telling how to use it. //SteamID of the user using the trigger is also displayed on irc, so that we can ban abusers easily. #include <amxmodx> #include <amxmisc> #include <engine> #include <sockets> #pragma dynamic 8000 #define MAX_USERS 32 new server[64], port, nick[32], username[32], chan[32], idbot[32], feil // Stuff needed to connect new irc_socket //Connection new temp[1024] //Put together messages with this new curmesg //Message counter for sending new pending[256][1024] //Messages Pending to be sent new i //Loop Counter new pings //Keep track of pings public plugin_init() {     register_plugin("Needamin trigger","1.0","Stein_R (ported and modified from IRC <-> HLDS")     register_dictionary("admincmd.txt")     register_dictionary("common.txt")     register_dictionary("pausecfg.txt")     // Cvars for irc and irc identify     register_cvar("irc_server","oslo.no.quakenet.org")     register_cvar("irc_nick","Arctic-NeedAdmin")     register_cvar("irc_username","Arctic-NeedAdmin")     register_cvar("irc_port","6667")     register_cvar("irc_channel","*//*)     register_cvar("irc_joindelay","10")     register_cvar("irc_identify","1")     register_cvar("irc_idbot","Q@Cserve.quakenet.org")     register_cvar("irc_ident","auth username password",FCVAR_PROTECTED&FCVAR_UNLOGGED)     register_cvar("irc_debug","0")         //Various Messages     register_cvar("irc_msg_srvsay","<$name - $steamid> $message")     register_cvar("irc_msg_ircsay","*IRC* $name :  $message")         register_cvar("irc_clientport","0",FCVAR_PROTECTED&FCVAR_UNLOGGED)         // Commands     register_clcmd("say","irc_saytext")     register_clcmd("say_team","irc_saytext")     set_task(1.0,"irc_datacheck",_,_,_,"b")     set_task(2.0,"sendnext",_,_,_,"b")     if (get_cvar_num("irc_clientport") == 0)     {         set_task(get_cvar_float("irc_joindelay"),"irc_connect")     }     else     {         irc_socket = get_cvar_num("irc_clientport")     }     get_cvar_string("irc_server",server,64)     get_cvar_string("irc_nick",nick,32)     get_cvar_string("irc_channel",chan,32)     get_cvar_string("irc_username",username,32)     get_cvar_string("irc_idbot",idbot,32)     port = get_cvar_num("irc_port") } public irc_connect() {     get_cvar_string("irc_server",server,64)     get_cvar_string("irc_nick",nick,32)     get_cvar_string("irc_channel",chan,32)     get_cvar_string("irc_username",username,32)     port = get_cvar_num("irc_port")     irc_socket = socket_open(server,port,SOCKET_TCP,feil)     set_cvar_num("irc_clientport",irc_socket)     switch (feil)     {         case 1:          {             log_amx("[IRC] Error creating socket to %s:%i",server,port)             return -1         }         case 2:          {             log_amx("[IRC] Error resolving hostname %s",server)             return -2         }         case 3:          {             log_amx("[IRC] Couldn't connect to %s:%i",server,port)             return -3         }     }     format(temp,1024,"NICK %s^r^nUSER %s 0 * :csP Bot^r^n",nick,username)     additem(temp)     return irc_socket } public irc_datacheck() {     if (socket_change(irc_socket,1))     {         new rdata[1024] //, data[1024]         socket_recv(irc_socket,rdata,1024)         copyc(rdata,1024,rdata,10)         irc_dataparse(rdata)         copy(temp,1024,rdata[strlen(rdata)+1])         if (containi(temp,"^r"))         {             irc_dataparse(rdata[strlen(rdata)+1])         }     } } public irc_dataparse(rdata[]) {     if(strlen(rdata) > 0)     { //If there is data         new arg1[128],arg1len,arg2[128] ,arg2len, arg3[128]         copyc(arg1,128,rdata,32)         arg1len = strlen(arg1)         copyc(arg2,128,rdata[arg1len+1],32)         arg2len = strlen(arg2)         copyc(arg3,128,rdata[arg1len+arg2len+2],32)         switch (str_to_num(arg2))         { //Numeric Events             case 001:             {                 server_print("[IRC] Connected sucessfully");                 irc_joinchannel()                 set_cvar_num("irc_clientport",irc_socket)                 irc_identify()                      return 0             } //Occurs after successful connection                case 403: { server_print("[IRC] Advarsel: Kanalen er tom, sry, channel %s",chan); return 0; }             case 405: { server_print("[IRC] Feil: Har ikke adgang til server"); return 0; }             case 432: { server_print("[IRC] Feil: Nicket er feil.."); return 0; }             case 433: { server_print("[IRC] Feil: Nickname er i bruk"); return 0; }             case 437: { server_print("[IRC] Feil: Vi er bannet fra servern, sry"); return 0; }             case 471: { server_print("[IRC] Feil: Serveren er full"); return 0; }             case 473: { server_print("[IRC] Feil: Channel er på Invite only"); return 0; }             case 474: { server_print("[IRC] Feil: Vi er bannet"); return 0; }             case 475: { server_print("[IRC] Feil: Mangler passord"); return 0; }             case 482: { server_print("[IRC] Feil: Vi er ikke på sA kan ikke set MOD"); return 0; }             case 513: { server_print("[IRC] Feil: Registration feilte, prøv igjen seinere, takk"); end(); return 0; }         }         if (get_cvar_num("irc_debug") == 1)             server_print("[IRC]-> %s",rdata)         if (equali(arg1,"PING"))         {             format(temp,1024,"PONG %s^r^n",arg2)             additem(temp)             pings++             return 0         }         else if (equali(arg1,"ERROR"))         {             end()             server_print("[IRC] Disconnected, trying to reconnect")             set_task(Float:60,"irc_connect")         }     }     return 0 } public additem(item[]) {     if(curmesg <= 255)     {         copy(pending[curmesg],1024,item)         curmesg++     }     else     {         new quicksend[201]         format(quicksend,200,"PRIVMSG %s :IRC message overflow, clearing stack.^r^n",chan)         socket_send(irc_socket,quicksend,0)         for(new inum=0;inum<256;inum++)         {             copy(pending[inum],1024,"")         }         curmesg = 0     }     return 0    } public sendnext() {     if (curmesg >= 1)     {         remove_quotes(pending[0])         socket_send(irc_socket,pending[0],0)         if (get_cvar_num("irc_debug") == 1)             server_print("[IRC]<- %s",pending[0])         for (i=0;i<=curmesg;i++)         {             copy(pending[i],1024,pending[i+1])         }         curmesg--     } } public end() {     format(temp,1024,"QUIT :Shutting down")     socket_send(irc_socket,temp,0)     set_cvar_num("irc_clientport",0) } public irc_joinchannel() {     get_cvar_string("irc_channel",chan,32)     format(temp,1024,"JOIN %s^r^n",chan)     additem(temp)     return 0 } public irc_identify() {     if (get_cvar_num("irc_identify") != 0)     {            new ident[256]         get_cvar_string("irc_ident",ident,256)         format(ident,256,"PRIVMSG %s :%s^r^n",idbot,ident)         additem(ident)     }     return 0 } public parsemessage(id,input[],output[],amsg[]) {     // Replaces $name $team $message with the right things     new name[32], authid[32]     new mtemp[1024]     get_user_name(id,name,32)     get_user_authid(id,authid,32)     copy(mtemp,512,input)     remove_quotes(amsg)     replace(mtemp,512,"$name",name)     replace(mtemp,512,"$message",amsg)     replace(mtemp,512,"$steamid",authid)     remove_quotes(mtemp)     remove_quotes(mtemp)     copy(output,1024,mtemp) } public irc_saytext(id) {     if (irc_socket > 0)     {         new msg[1024]         read_args(msg,1024)         new trig[10]         new newmsg[1014]         strbreak(msg,trig,10,newmsg,1014)         new tmsg[1024]         if(equali(trig,"!needadmin",10))         {             if(strlen(newmsg) >= 2)             {             get_cvar_string("irc_msg_srvsay",tmsg,1024)             parsemessage(id,tmsg,temp,newmsg)             format(temp,1024,"PRIVMSG %s :%s^r^n",chan,temp)             additem(temp)             client_print(id,print_chat,"[NeedAdmin] Message sent!")             return PLUGIN_HANDLED             }             else             {             client_print(id,print_chat,"[NeedAdmin] Found no message!!")                         return PLUGIN_HANDLED             }         }     }     return 0 }

Some part of the script is translated..

Thx
STaTic is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 05-16-2006 , 17:58  
Reply With Quote #2

What says that what message is too short??? The plugin says that the message is too short or a message shows in IRC saying that a message was trying to be sent but was too short? Also can you post that using [ small ] tags instead of [ code ] because it is easier to read.
SubStream is offline
STaTic
New Member
Join Date: May 2006
Old 05-17-2006 , 03:23  
Reply With Quote #3

Code:
if(strlen(newmsg) >= 2)             {

it says on HLDS/CS that it was to short

"newmsg" isnt longer than 2.. "!needadmin aaaaaaaaaaaaaaa" outputs the same as "!needadmin" does..
STaTic is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 05-18-2006 , 08:31  
Reply With Quote #4

you should do this after using read_args()
Code:
remove_quotes(msg)

also, is there maybe something missing here?
Code:
    register_cvar("irc_channel","*//*)     register_cvar("irc_joindelay","10")
__________________
plop
p3tsin is offline
Rixorster
Senior Member
Join Date: Jul 2005
Old 05-18-2006 , 09:20  
Reply With Quote #5

Hmm, also it seems that the case 3: thingy is not working properly or something, try this:
Code:
        case 3:            {             log_amx("[IRC] Unable to connect %s:%i",server,port)             return -3         }
(you had that:
Couldn't,(the ' is same as " sometimes))
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 05-18-2006 , 10:14  
Reply With Quote #6

Quote:
Originally Posted by Rixorster
(you had that:
Couldn't,(the ' is same as " sometimes))
sometimes sure.. but not in pawn
__________________
plop
p3tsin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode