Raised This Month: $ Target: $400
 0% 

concmd problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pRED*
Join Date: Dec 2006
Old 02-14-2007 , 18:29   concmd problems
Reply With Quote #1

Hey I'm having a problem with a say command.

Ive got this in my plugin_init()

PHP Code:
register_clcmd("say /whois""cmd_whois"0"<target> "
and then later on in the code...

PHP Code:
public cmd_whois(idlevelcid)
{
         if (!
cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED
 
        
new Arg1[24]
    new 
Arg2[24]

    
         
read_argv(2Arg223)
 
         
        new 
player cmd_target(idArg21)
        
    if (!
player)
        {
  
            
console_print(id"Sorry, player %s could not be found or targetted!"Arg1)
            return 
PLUGIN_HANDLED
        
}
    else
    {
        new 
name[18];
            
get_user_name(player,name,17);

        new 
motd[2048],tempstring[2048];

        
add(motd,2048,"<html><strong><b>");
        
format(tempstring,2048,"Rank and Badge Stats for Player %s </strong></b>"name)
        
add(motd,2048,tempstring);
        
add(motd,2048,"<br><br>");
        
format(tempstring,2048,"Players Rank: %s",RANKS[g_PlayerRank[player]])
        
add(motd,2048,tempstring);
        
add(motd,2048,"<br>");
        
add(motd,2048,"Current Badges Owned: <br>");

        for (new 
counter=0counter<MAX_BADGEScounter++)
        {
            if(
g_PlayerBadges[player][counter]!=0)
            {
                
format(tempstring,2048,"&nbsp;-%s<br>",BADGES[counter][g_PlayerBadges[player][counter]])
                
add(motd,2048,tempstring);
            }
        }
        
        
add(motd,2048,"</html>");

        
show_motd(id,motd,"Player Info")
        
        }
        
         return 
PLUGIN_HANDLED

It works fine if I type "say /whois name" directly into the console but if I try do it as normal say "/whois name" it just prints to the screen and doesn't execute the function at all.

Any help would be appreciated.

Thanks
pRED* is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 02-14-2007 , 18:46   Re: concmd problems
Reply With Quote #2

Try the code below. The code looks like it can be heavily optimized. I don't think you need two arrays with 2048 characters...

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Something", "1.0", "pred/stupok")     register_clcmd("say", "cmd_whois", 0, "<target> ") } public cmd_whois(id/*, level, cid*/) {     /*     Why check access if you set flags to 0 in the register?         if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     */     new Arg1[7]     read_args(Arg1, 6)     remove_quotes(Arg1)         if(!equal(Arg1, "/whois") return PLUGIN_HANDLED         new Arg2[32]         read_argv(2, Arg2, 31)     new player = cmd_target(id, Arg2, 1) //1 means it obeys immunity         if (!player)     {                 console_print(id, "Sorry, player %s could not be found or targetted!", Arg2)         return PLUGIN_HANDLED     }     else     {         new name[32];         get_user_name(player,name,31);                 new motd[2048],tempstring[2048]; //are you sure you need such large arrays?                 add(motd,2048,"<html><strong><b>");         format(tempstring,2048,"Rank and Badge Stats for Player %s </strong></b>", name)         add(motd,2048,tempstring);         add(motd,2048,"<br><br>");         format(tempstring,2048,"Players Rank: %s",RANKS[g_PlayerRank[player]])         add(motd,2048,tempstring);         add(motd,2048,"<br>");         add(motd,2048,"Current Badges Owned: <br>");                 for (new counter=0; counter<MAX_BADGES; counter++)         {             if(g_PlayerBadges[player][counter]!=0)             {                 format(tempstring,2048,"&nbsp;-%s<br>",BADGES[counter][g_PlayerBadges[player][counter]])                 add(motd,2048,tempstring);             }         }                 add(motd,2048,"</html>");                 show_motd(id,motd,"Player Info")             }         return PLUGIN_HANDLED }
stupok is offline
pRED*
Join Date: Dec 2006
Old 02-14-2007 , 20:06   Re: concmd problems
Reply With Quote #3

I had to change one of the PLUGIN_HANDLED to PLUGIN_CONTINUE to make text work at all.
But still same issue.

Typing it into console works, typing it into say just says it..

Im thinking that its all one argument. eg "/whois name". Would that be possible?
So once we've checked that it starts with /whois then continue to read the same arg to see if the player name is in there?

-e- yup just tested that. I extended the arg1 string and printed it to screen (with quotes removed). It comes up as /whois name.

So im guess parse or strbreak would be needed to get just the name? I can't figure out how to use them tho.
Arg1="/whois name" and I need to get just name into a separate string.

Last edited by pRED*; 02-14-2007 at 20:27.
pRED* is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 02-14-2007 , 20:28   Re: concmd problems
Reply With Quote #4

I oopsed. Try below:

Code:
new text[64] read_args(text, 63) remove_quotes(text) if(!equal(text, "/whois", 6) return PLUGIN_CONTINUE new player = cmd_target(id, text[7], 1)
stupok is offline
pRED*
Join Date: Dec 2006
Old 02-14-2007 , 20:37   Re: concmd problems
Reply With Quote #5

Yay that works.
Thanks heaps for the help. I've added you to the credits. Look out for it, will be releasing it soonish. First real mod ive done.

Oh and I fixed the massive strings thing. Theres prob heaps more stuff that needs to be done tho
pRED* is offline
Reply



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 00:41.


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