AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [HELP] ERROR: function prototypes do not match (https://forums.alliedmods.net/showthread.php?t=317386)

einsfuhrer 07-10-2019 11:46

[HELP] ERROR: function prototypes do not match
 
Hay, got another error on the plugin I'm making and help is appreciated.

So I get this error when I compile:
Code:

(34) : error 100: function prototypes do not match
This is my RegAdminCmd part:
PHP Code:

RegAdminCmd("sm_hidetag"Command_hidetagADMFLAG_KICK); 

And here is my callback function:
PHP Code:

public Action Command_hidetag(const char[] sCommandint iClientint sArgs)
{
    if (
StrEqual(sCommand"say"))
    {
        
int iTeam GetClientTeam(iClient);
        
        if (
iTeam 0)
        {
            if (
IsClientInGame(iClient))
            {
                if(
IsPlayerAlive(iClient)) 
                {   
                    if (
CheckCommandAccess(iClient"chattag"ADMFLAG_ROOT))
                    {
                        if (
GetClientTeam(iClient) == 3)
                            
PrintToChatAll(" \x0AHIDEROLE \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                                
                        if (
GetClientTeam(iClient) == 2)
                            
PrintToChatAll(" \x0AHIDEROLE \x01| \x09%N \x08» \x01%s"iClientsArgs);

                        else if (
GetClientTeam(iClient) == 1)
                            
PrintToChatAll(" \x0AHIDEROLE \x01| \x03%N \x08» \x01%s"iClientsArgs);
                    }
                    else if (
CheckCommandAccess(iClient"chattag"ADMFLAG_RCON))
                    {
                        if (
GetClientTeam(iClient) == 3)
                            
PrintToChatAll(" \x04MANAGER \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                                
                        if (
GetClientTeam(iClient) == 2)
                            
PrintToChatAll(" \x04MANAGER \x01| \x09%N \x08» \x01%s"iClientsArgs);

                        else if (
GetClientTeam(iClient) == 1)
                            
PrintToChatAll(" \x04MANAGER \x01| \x03%N \x08» \x01%s"iClientsArgs);
                    }
                    else
                    {
                        if (
GetClientTeam(iClient) == 3)
                            
PrintToChatAll(" \x08\x01\x0B%N \x08» \x01%s"iClientsArgs);
                                
                        if (
GetClientTeam(iClient) == 2)
                            
PrintToChatAll(" \x08\x01\x09%N \x08» \x01%s"iClientsArgs);

                        else if (
GetClientTeam(iClient) == 1)
                            
PrintToChatAll(" \x08\x01\x03%N \x08» \x01%s"iClientsArgs);
                    }
                }
                else
                {
                    if (
CheckCommandAccess(iClient"chattag"ADMFLAG_ROOT))
                {
                    if (
GetClientTeam(iClient) == 3)
                        
PrintToChatAll(" \x0FDEAD \x01| \x0AHIDEROLE \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                            
                    if (
GetClientTeam(iClient) == 2)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x0AHIDEROLE \x01| \x09%N \x08» \x01%s"iClientsArgs);

                    else if (
GetClientTeam(iClient) == 1)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x0AHIDEROLE \x01| \x03%N \x08» \x01%s"iClientsArgs);
                }
                else if (
CheckCommandAccess(iClient"chattag"ADMFLAG_RCON))
                {
                    if (
GetClientTeam(iClient) == 3)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x04MANAGER \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                            
                    if (
GetClientTeam(iClient) == 2)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x04MANAGER \x01| \x09%N \x08» \x01%s"iClientsArgs);

                    else if (
GetClientTeam(iClient) == 1)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x04MANAGER \x01| \x03%N \x08» \x01%s"iClientsArgs);
                }
                else
                {
                    if (
GetClientTeam(iClient) == 3)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x08\x01\x0B%N \x08» \x01%s"iClientsArgs);
                            
                    if (
GetClientTeam(iClient) == 2)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x08\x01\x09%N \x08» \x01%s"iClientsArgs);

                    else if (
GetClientTeam(iClient) == 1)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x08\x01\x03%N \x08» \x01%s"iClientsArgs);
                }
                }
            }
        }
    }



Whai 07-10-2019 12:29

Re: [HELP] ERROR: function prototypes do not match
 
From console.inc :

PHP Code:

/**
 * Called when a generic console command is invoked.
 *
 * @param client        Index of the client, or 0 from the server.
 * @param args            Number of arguments that were in the argument string.
 * @return                An Action value.  Not handling the command
 *                        means that Source will report it as "not found."
 */
typedef ConCmd = function Action (int clientint args); 

so your
PHP Code:

public Action Command_hidetag(const char[] sCommandint iClientint sArgs

does not match.

einsfuhrer 07-10-2019 13:01

Re: [HELP] ERROR: function prototypes do not match
 
Quote:

Originally Posted by Whai (Post 2658629)
From console.inc :

PHP Code:

/**
 * Called when a generic console command is invoked.
 *
 * @param client        Index of the client, or 0 from the server.
 * @param args            Number of arguments that were in the argument string.
 * @return                An Action value.  Not handling the command
 *                        means that Source will report it as "not found."
 */
typedef ConCmd = function Action (int clientint args); 

so your
PHP Code:

public Action Command_hidetag(const char[] sCommandint iClientint sArgs

does not match.

It fixed that problem but made another one:

Code:

(393) : error 017: undefined symbol "sCommand"
Part of code:
PHP Code:

public Action Command_hidetag(int iClientint sArgs)
{
    if (
StrEqual(sCommand"say"))
    {
        
int iTeam GetClientTeam(iClient);
        
        if (
iTeam 0)
        {
            if (
IsClientInGame(iClient))
            {
                if(
IsPlayerAlive(iClient)) 
                {   
                    if (
CheckCommandAccess(iClient"chattag"ADMFLAG_ROOT))
                    {
                        if (
GetClientTeam(iClient) == 3)
                            
PrintToChatAll(" \x0AHIDEROLE \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                                
                        if (
GetClientTeam(iClient) == 2)
                            
PrintToChatAll(" \x0AHIDEROLE \x01| \x09%N \x08» \x01%s"iClientsArgs);

                        else if (
GetClientTeam(iClient) == 1)
                            
PrintToChatAll(" \x0AHIDEROLE \x01| \x03%N \x08» \x01%s"iClientsArgs);
                    }
                    else if (
CheckCommandAccess(iClient"chattag"ADMFLAG_RCON))
                    {
                        if (
GetClientTeam(iClient) == 3)
                            
PrintToChatAll(" \x04MANAGER \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                                
                        if (
GetClientTeam(iClient) == 2)
                            
PrintToChatAll(" \x04MANAGER \x01| \x09%N \x08» \x01%s"iClientsArgs);

                        else if (
GetClientTeam(iClient) == 1)
                            
PrintToChatAll(" \x04MANAGER \x01| \x03%N \x08» \x01%s"iClientsArgs);
                    }
                    else
                    {
                        if (
GetClientTeam(iClient) == 3)
                            
PrintToChatAll(" \x08\x01\x0B%N \x08» \x01%s"iClientsArgs);
                                
                        if (
GetClientTeam(iClient) == 2)
                            
PrintToChatAll(" \x08\x01\x09%N \x08» \x01%s"iClientsArgs);

                        else if (
GetClientTeam(iClient) == 1)
                            
PrintToChatAll(" \x08\x01\x03%N \x08» \x01%s"iClientsArgs);
                    }
                }
                else
                {
                    if (
CheckCommandAccess(iClient"chattag"ADMFLAG_ROOT))
                {
                    if (
GetClientTeam(iClient) == 3)
                        
PrintToChatAll(" \x0FDEAD \x01| \x0AHIDEROLE \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                            
                    if (
GetClientTeam(iClient) == 2)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x0AHIDEROLE \x01| \x09%N \x08» \x01%s"iClientsArgs);

                    else if (
GetClientTeam(iClient) == 1)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x0AHIDEROLE \x01| \x03%N \x08» \x01%s"iClientsArgs);
                }
                else if (
CheckCommandAccess(iClient"chattag"ADMFLAG_RCON))
                {
                    if (
GetClientTeam(iClient) == 3)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x04MANAGER \x01| \x0B%N \x08» \x01%s"iClientsArgs);
                            
                    if (
GetClientTeam(iClient) == 2)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x04MANAGER \x01| \x09%N \x08» \x01%s"iClientsArgs);

                    else if (
GetClientTeam(iClient) == 1)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x04MANAGER \x01| \x03%N \x08» \x01%s"iClientsArgs);
                }
                else
                {
                    if (
GetClientTeam(iClient) == 3)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x08\x01\x0B%N \x08» \x01%s"iClientsArgs);
                            
                    if (
GetClientTeam(iClient) == 2)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x08\x01\x09%N \x08» \x01%s"iClientsArgs);

                    else if (
GetClientTeam(iClient) == 1)
                        
PrintToChatAll(" \x0FDEAD \x01|  \x08\x01\x03%N \x08» \x01%s"iClientsArgs);
                }
                }
            }
        }
    }


This is another function in the code that works, there is sCommand in the function parentheses but when I put sCommand in the RegAdminCmd it will give the recent error:

PHP Code:

public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)
{
    
int iTimeiYeariMonthiDayiHouriMinuteiSecond;
    
    
iTime GetTime();
    
    
UnixToTime(iTimeiYeariMonthiDayiHouriMinuteiSecondiTimezone);
    
    if (
StrEqual(sCommand"say"))
    {
        
int iTeam GetClientTeam(iClient);
        
        if (
iTeam 0)
        {
            if (
IsClientInGame(iClient))
            { 

What should I do to get the sCommand to get defined?

Whai 07-10-2019 13:07

Re: [HELP] ERROR: function prototypes do not match
 
Why do you need
Code:

if (StrEqual(sCommand, "say"))
on Command_hidetag callback and OnClientSayCommand forward ?

that is useless, just remove it because :
_ OnClientSayCommand is triggered when a player wrote in chat
_ Command_hidetag is the callback of
Code:

RegAdminCmd("sm_hidetag", Command_hidetag, ADMFLAG_KICK);
that creates the command sm_hidetag for the console and !hidetag, /hidetag, !sm_hidetag and /sm_hidetag for the chat.

einsfuhrer 07-10-2019 13:14

Re: [HELP] ERROR: function prototypes do not match
 
Because when I send the !hidetag I want the OWNER tag to disappear (right now I'm just having "Hiderole" to see if it works). But when I removed the "if (StrEqual(sCommand, "say"))" it just sends a empty message: https://gyazo.com/42b8c815272ad6c5c1d8d04f06338ebc

I want to send the command and all messages after that should be with no tag and if i type !hidetag again it will take the tag back.

Whai 07-10-2019 13:36

Re: [HELP] ERROR: function prototypes do not match
 
Ok, now I understand what you're looking for, but you still don't need "if (StrEqual(sCommand, "say"))" for the same reason I said above.

Use instead :
Code:

if (StrEqual(sArgs, "!hidetag") || StrEqual(sArgs, "/hidetag"))
after that, at the end of the block code : write "return Plugin_Handled" to block the message you did "/hidetag" or "!hidetag"

einsfuhrer 07-10-2019 13:47

Re: [HELP] ERROR: function prototypes do not match
 
Quote:

Originally Posted by Whai (Post 2658640)
Ok, now I understand what you're looking for, but you still don't need "if (StrEqual(sCommand, "say"))" for the same reason I said above.

Use instead :
Code:

if (StrEqual(sArgs, "!hidetag") || StrEqual(sArgs, "/hidetag"))
after that, at the end of the block code : write "return Plugin_Handled" to block the message you did "/hidetag" or "!hidetag"

Thanks but that gives a error on the line where "if (StrEqual(...":
Code:

error 035: argument type mismatch (argument 1)
Code:
PHP Code:

public Action Command_hidetag(int iClientint sArgs)
{
    if (
StrEqual(sArgs"!hidetag") || StrEqual(sArgs"/hidetag"))
    { 

This is the code where I put the return "Plugin_Handled;":
PHP Code:

                }
            }
        }
    }
    return 
Plugin_Handled;



Whai 07-10-2019 14:34

Re: [HELP] ERROR: function prototypes do not match
 
You do not need to put in
Code:

public Action Command_hidetag(int iClient, int sArgs)
just put in
Code:

public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)
it will do the work, don't forget the return Plugin_Handled

einsfuhrer 07-10-2019 15:21

Re: [HELP] ERROR: function prototypes do not match
 
Quote:

Originally Posted by Whai (Post 2658655)
You do not need to put in
Code:

public Action Command_hidetag(int iClient, int sArgs)
just put in
Code:

public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)
it will do the work, don't forget the return Plugin_Handled

I want to toggle that my tag isnt showing. Like this:

You are Admin on a server and then you want to sneak on players and see if they are breaking rules or something so you want to hide your chattag. Then you type /hidetag and then all messages you write will not show your tag, and when you want your tag again you just type /hidetag again and it will come back.

Right now it just changes the tag only on the message when I type !hidetag.

Whai 07-10-2019 16:01

Re: [HELP] ERROR: function prototypes do not match
 
Ok, now I know what you want,
  • Create a global array bool variable (name whatever you want like for exemple : "g_bTagHid") with the sizeof MAXPLAYERS + 1
  • On "public Action Command_hidetag(int iClient, int sArgs)" remove all and write :
    Spoiler
  • On "public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)", just check if g_bTagHidden[iClient] is true to block the message that would display then do the "PrintToChatAll" thing


All times are GMT -4. The time now is 14:07.

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