AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   error 035: argument type mismatch (argument 2) (https://forums.alliedmods.net/showthread.php?t=214229)

client21 04-24-2013 13:28

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

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

public OnPluginStart()
{
    
RegConsoleCmd("test"test);
}

public 
Action:test(clientargs)
{
    if (!(
client <= MaxClients))
        return 
Plugin_Handled;

    
decl player_list[MaxClients]; new players 0;
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i)) player_list[players++] = i;
    }
    
Shake_(player_listplayers);

    return 
Plugin_Handled;
}

Shake_(const player_list[], const players)
{
    if (
players 1)
        return;

    new 
Handle:Message StartMessage("Shake"player_listplayers); // error 035: argument type mismatch (argument 2)
    
if (Message != INVALID_HANDLE)
    {
        
// blabla (not important)
    
}


To avoid this error, I must to do this:

PHP Code:

Shake_(const player_list[], const players)
{
    if (
players 1)
        return;

    
decl list[players];
    for (new 
0playersi++)
        list[
i] = player_list[i];

    new 
Handle:Message StartMessage("Shake", list, players);


I do not understand what is wrong in the first variant.
I understand I can do without the function "Shake_"

NinjaSK 04-24-2013 14:20

Re: error 035: argument type mismatch (argument 2)
 
At what line do you get the error?

Basically, "argument type mismatch" means that you're inserting 1 type of argument into
a function which needs to receive an argument of different type.

For example: you will get this error if you input a integer into a function that requires a string.

client21 04-24-2013 14:40

Re: error 035: argument type mismatch (argument 2)
 
Quote:

Originally Posted by NinjaSK (Post 1939101)
At what line do you get the error?

Basically, "argument type mismatch" means that you're inserting 1 type of argument into
a function which needs to receive an argument of different type.

For example: you will get this error if you input a integer into a function that requires a string.

Be attentive. I pointed to the line with the error:

PHP Code:

new Handle:Message StartMessage("Shake"player_listplayers); // error 035: argument type mismatch (argument 2) 

And here are the same types of arguments.

MasterOfTheXP 04-24-2013 15:14

Re: error 035: argument type mismatch (argument 2)
 
My only guess would be that you're trying to use a constant (const player_list) in the first one; list isn't a constant, so it works with StartMessage. Pretty picky.

client21 04-24-2013 15:25

Re: error 035: argument type mismatch (argument 2)
 
Yeah, right, if do this: Shake_(player_list[], players) - error disappears (thx).

NinjaSK 04-24-2013 16:54

Re: error 035: argument type mismatch (argument 2)
 
Sorry, was doing a lot of other stuff at the same time...


All times are GMT -4. The time now is 21:47.

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