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

error 035: argument type mismatch (argument 1)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 12-02-2014 , 21:37   error 035: argument type mismatch (argument 1)
Reply With Quote #1

Hi.


Can not beat that error
PHP Code:
error 035argument type mismatch (argument 1
I've searched a lot but all i find in posts is easy errors (like adding 'id' when it don't need to be added or words mispell), but i can not find any mistakes in my code..

Guide me please what's wrong...

PHP Code:
#include <amxmodx>
#define MAX_ARG_LEN    128
#define MAX_ARGS_NUM 50

static command[MAX_ARGS_NUM][MAX_ARG_LEN]
new 
len

public client_command(id)
{
    new 
args read_argc()-// get number of client command arguments
    
    
for(new i;i<=args;i++)
        
read_argv(icommand[i], MAX_ARG_LEN// read all arguments to array "command"

    
if(equal(command[0],"amx_internalbancommand",22)) // if it is internal ban command
    
{
        
// command syntax "amx_internalbancommand" "#playerindex" *others not important*
        
for(new i;i<=31;i++) // loop until we find player index (if any), 31 is the last player index 
        
{
            
len strlen(i) + 1; <<<<<<<<<<< error 035argument type mismatch (argument 1)     // here we define a length of int "i" (i am using strlen, because there are no native function intlen and i have no idea how to convert int to string) plus one
            
if( equal(command[1],"#" i,len) ) <<<<<<<<<<< error 033: array must be indexed (variable "-unknown-")   // and here we check is our command argument matches the string, e.g. "#1"
            
{
                ...
                break
            }
        }
    }

Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-02-2014 , 21:43   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #2

You are checking strlen of an integer, it expects a string (array). And "#" + i just makes no sense.
__________________

Last edited by Bugsy; 12-02-2014 at 21:43.
Bugsy is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 12-02-2014 , 21:46   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
You are checking strlen of an integer, it expects a string (array). And "#" + i just makes no sense.
Ok, but how to convert integer to string?
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-02-2014 , 21:48   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #4

What exactly is this code supposed to do? Give me what is inputted and what you expect it to do.
__________________
Bugsy is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 12-02-2014 , 22:11   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
What exactly is this code supposed to do? Give me what is inputted and what you expect it to do.
It listen to commands and if it finds a command "amx_internalbancommand" it make some actions (well, it just logs it, but not important here).

Example command: amx_internalbancommand #31

Where #31 is an index of a player in game.


Found how to convert, but does not work...ooh.

PHP Code:
new len;
num_to_str(ilen3); <<<<<<<< error 035argument type mismatch (argument 2)
len strlen(len) + 1;
len str_to_num(len); 
Why "len" errors here? It's just a buffer, so a string. As it's not defined what type is it, it should be automatically become a string, is it?
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-02-2014 , 22:14   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #6

A string is an array. Len is not an array
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-02-2014 , 22:20   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #7

I don't see what your loop is even doing. It's looping from 0 to 31 (when it should be 1 to 32 if its an actual player id, and #1-#XXX if it's a userid) and stopping when the arg matches the loop index value. Why don't you just skip this part? Maybe use cmd_target() instead to validate it hit a valid, and acceptable, player index.
__________________

Last edited by Bugsy; 12-02-2014 at 22:31.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-02-2014 , 22:26   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #8

Quote:
Originally Posted by Mofforg View Post
Why "len" errors here? It's just a buffer, so a string. As it's not defined what type is it, it should be automatically become a string, is it?
No, this isn't Visual Basic.

Why don't you try something like this. It accepts all or part of the users name, or the userid number (#12).
- amx_internalbancommand bugs
- amx_internalbancommand #12

PHP Code:
public plugin_init() 
{
    
register_clcmd"amx_internalbancommand" "BanCmd" );
}

public 
BanCmdid )
{
    new 
szArg33 ] , idTarget szName33 ];
    
    
read_argvszArg charsmaxszArg ) );
    
idTarget cmd_targetid szArg ); //3rd param has flags to control who can be selected, see below

    
if ( idTarget )
    {
        
get_user_nameidTarget szName charsmaxszName ) );
        
client_printid print_chat "You used ban cmd on '%s'" szName );
    }
    
    return 
PLUGIN_HANDLED;

Flags for cmd_target (already defined by default), just use flag(s)
#define CMDTARGET_OBEY_IMMUNITY (1<<0)
#define CMDTARGET_ALLOW_SELF (1<<1)
#define CMDTARGET_ONLY_ALIVE (1<<2)
#define CMDTARGET_NO_BOTS (1<<3)

To use multiple, use bit-wise OR
CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY
__________________

Last edited by Bugsy; 12-02-2014 at 23:17.
Bugsy is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 12-02-2014 , 23:38   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
Why don't you try something like this. It accepts all or part of the users name, or the userid number (#12).
- amx_internalbancommand bugs
- amx_internalbancommand #12

PHP Code:
public plugin_init() 
{
    
register_clcmd"amx_internalbancommand" "BanCmd" );
}

public 
BanCmdid )
{
    new 
szArg33 ] , idTarget szName33 ];
    
    
read_argvszArg charsmaxszArg ) );
    
idTarget cmd_targetid szArg ); //3rd param has flags to control who can be selected, see below

    
if ( idTarget )
    {
        
get_user_nameidTarget szName charsmaxszName ) );
        
client_printid print_chat "You used ban cmd on '%s'" szName );
    }
    
    return 
PLUGIN_HANDLED;

Flags for cmd_target (already defined by default), just use flag(s)
#define CMDTARGET_OBEY_IMMUNITY (1<<0)
#define CMDTARGET_ALLOW_SELF (1<<1)
#define CMDTARGET_ONLY_ALIVE (1<<2)
#define CMDTARGET_NO_BOTS (1<<3)

To use multiple, use bit-wise OR
CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY
Thanks, that's an ideal of accepting both userid and username. I made your way, now works! I can use only client_command through (can not BanCmd) because bansystem is closed-source and i can not edit it. And bansystem have no forward functions.

I did not consider to use cmd_target because i can not find full documentation on it (i even did not know that function before you told me about it). I am not sure what exactly does it do, what for does here the first argument and what does it mean.

PHP Code:
    if(equal(command[0],"amx_internalbancommand",22))
    {
        new 
idTarget;
        
idTarget cmd_targetid command[1] , CMDTARGET_ALLOW_SELF );
        
        if ( 
idTarget )
        {
            ...
        }
    } 
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2014 , 09:06   Re: error 035: argument type mismatch (argument 1)
Reply With Quote #10

Ok, I wasn't sure what you were doing but it looks like you figured it out. The first arg (id) is the player who used the command.
__________________

Last edited by Bugsy; 12-03-2014 at 09:06.
Bugsy 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 06:10.


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