Raised This Month: $ Target: $400
 0% 

Any reason why my command isn't working?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kar731
Member
Join Date: Mar 2016
Old 04-10-2016 , 20:35   Any reason why my command isn't working?
Reply With Quote #1

I have the root flag, and yet this command shows up as an unknown command.
PHP Code:
#define WHITE "\x01"
#define YELLOW "\x09"
#define GREY "\x08"
#define RED "\x02"
#define PINK "\x03"
#define BLUE "\x0B"
#define LBLUE "\x0A"
#define GREEN "\x04"

public void OnPluginStart()
{
    
RegAdminCmd("sm_adminchat"Command_adminchatADMFLAG_GENERIC);
}

public 
Action Command_adminchat(clientargs) {
    if (
args <= 0) {
        
ReplyToCommand(client"[SM] Usage: sm_adminchat <message>");
        return 
Plugin_Handled;
    }
    
    
char name[32];
    
GetClientName(clientnamesizeof(name));
    
    for (
int i 0<= GetMaxClients(); i++) {
        if (
GetAdminFlag(GetUserAdmin(i), ADMFLAG_GENERIC))
            
PrintToChat(i" %s[%sADMIN%s] %s%s%s: %s "GREENREDGREENBLUEnameWHITEargs);
        
//[ADMIN] Kar: sup dawgs
    
}
    return 
Plugin_Handled;


Last edited by kar731; 04-10-2016 at 20:35.
kar731 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 04-10-2016 , 21:03   Re: Any reason why my command isn't working?
Reply With Quote #2

are you doing sm_adminchat in the console cuz it'll show that
also add IsClientInGame(i) to your loop
__________________
8guawong is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 04-10-2016 , 21:05   Re: Any reason why my command isn't working?
Reply With Quote #3

When looping through clients use:
PHP Code:
for (int i 1<= MaxClientsi++) 
and then check to make sure that the client is in game before doing anything else.
PHP Code:
if(!IsClientInGame(i)) continue; 
Edit: The args parameter is an integer. If you really are just trying to print out the number of arguments in your PrintToChat() then you should format wih %i instead of %s. If that is not what you intended then look into GetCmdArg();

Last edited by Darkness_; 04-10-2016 at 21:08.
Darkness_ is offline
kar731
Member
Join Date: Mar 2016
Old 04-10-2016 , 21:06   Re: Any reason why my command isn't working?
Reply With Quote #4

Code:
 
] sm_adminchat sdfsdfsdf
Unknown command: sm_adminchat
Yes I am....
kar731 is offline
kar731
Member
Join Date: Mar 2016
Old 04-10-2016 , 21:07   Re: Any reason why my command isn't working?
Reply With Quote #5

Quote:
Originally Posted by Darkness_ View Post
When looping through clients use:
PHP Code:
for (int i 1<= MaxClientsi++) 
and then check to make sure that the client is in game before doing anything else.
PHP Code:
if(!IsClientInGame(i)) continue; 
I did that, but it's still not showing as a command. And yes the plugin is loaded.

Last edited by kar731; 04-10-2016 at 21:07.
kar731 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 04-10-2016 , 21:40   Re: Any reason why my command isn't working?
Reply With Quote #6

Quote:
Originally Posted by kar731 View Post
Code:
 
] sm_adminchat sdfsdfsdf
Unknown command: sm_adminchat
Yes I am....
this is normal I THINK
you just need to focus on getting the code inside Command_adminchat to run
__________________

Last edited by 8guawong; 04-10-2016 at 21:41.
8guawong is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 04-11-2016 , 06:20   Re: Any reason why my command isn't working?
Reply With Quote #7

What game are you using ? also you can remove the GetClientName part and use %N for the players name requires client index as param.
xerox8521 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 04-11-2016 , 09:30  
Reply With Quote #8

You need something like this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#define START    "\x01\x0B\x04"
#define WHITE    "\x01"
#define YELLOW    "\x09"
#define GREY    "\x08"
#define RED    "\x02"
#define PINK    "\x03"
#define BLUE    "\x0B"
#define LBLUE    "\x0A"
#define GREEN    "\x04"

bool bIsAdmin[MAXPLAYERS 1];
bool bLateLoad;

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max) {
    
bLateLoad late;
    return 
APLRes_Success
}

public 
void OnPluginStart() {
    
RegAdminCmd("sm_adminchat"Command_adminchatADMFLAG_GENERIC);
    if (
bLateLoad) {
        
LookupClients();
        
bLateLoad false;
    }
}

void LookupClients() {
    for (
int i 1<= MaxClientsi++) {
        if (
IsClientInGame(i)) OnClientPostAdminCheck(i);
    }
}

public 
void OnClientPostAdminCheck(int client) {
    if (
<= client <= MaxClients && !IsFakeClient(client)) bIsAdmin[client] = CheckCommandAccess(client"sm_admin"ADMFLAG_GENERIC);
}

public 
Action Command_adminchat(int clientint args) {
    if (
args <= 0) {
        
ReplyToCommand(client"[SM] Usage: sm_adminchat <message>");
        return 
Plugin_Handled;
    }

    
char cArg[PLATFORM_MAX_PATH];
    
GetCmdArgString(cArgsizeof(cArg));

    for (
int i 1<= MaxClientsi++) {
        if(!
IsClientInGame(i) || !bIsAdmin[i]) continue; 
        
PrintToChat(i"%s[%sADMIN%s] %s%N%s: %s"STARTREDGREENBLUEclientWHITEcArg);    //[ADMIN] Kar: sup dawgs
    
}
    return 
Plugin_Handled;

__________________

Last edited by Grey83; 04-11-2016 at 09:45.
Grey83 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 08:39.


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