SA-MP Forums Archive
Argument type mismatch (argument 2) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Argument type mismatch (argument 2) (/showthread.php?tid=388449)



Argument type mismatch (argument 2) - Ghost252 - 28.10.2012

Hi, I've used this code:

Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}

stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, "_", " ");
    return name;
}
And I'm getting this error:

Код:
C:\Users\Yakir\Desktop\The Best Server\gamemodes\GM.pwn(310) : error 035: argument type mismatch (argument 2)
Help will be appreciated.


Re: Argument type mismatch (argument 2) - HyDrAtIc - 28.10.2012

Show the line?


Re: Argument type mismatch (argument 2) - Ghost252 - 28.10.2012

Which line?


Re: Argument type mismatch (argument 2) - HyDrAtIc - 28.10.2012

Line 310


Re: Argument type mismatch (argument 2) - gtakillerIV - 28.10.2012

The one you get the error on..

EDIT:

@Costel: I know right xD


Re: Argument type mismatch (argument 2) - IstuntmanI - 28.10.2012

Код:
C:\Users\Yakir\Desktop\The Best Server\gamemodes\GM.pwn(310) : error 035: argument type mismatch (argument 2)
Line 310.

EDIT: 3 comments in few seconds, lol. xD


Re: Argument type mismatch (argument 2) - Ghost252 - 28.10.2012

Ok, I'll show ya but first I'll add another code I forgot to show ya, lol.

Ok so that's the original code:

Код:
stock GetName(playerid)
{
    new szName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, szName, sizeof(szName));
    return szName;
}

stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}

stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, "_", " ");
    return name;
}
The two errors:
Код:
C:\Users\Yakir\Desktop\The Best Server\gamemodes\GM.pwn(313) : error 021: symbol already defined: "GetName"
C:\Users\Yakir\Desktop\The Best Server\gamemodes\GM.pwn(317) : error 035: argument type mismatch (argument 2)
And line 313 = "{" which is under: "stock GetName(playerid)"
Line 317 = strreplace(name, "_", " ");


Re: Argument type mismatch (argument 2) - HyDrAtIc - 28.10.2012

Make line 313 to (

and line 317 to

pawn Код:
strreplace(name, _, );

I donno if that work.


Re: Argument type mismatch (argument 2) - PrawkC - 28.10.2012

For one, you can't have two stocks named the exact same thing...

and then for your strreplace stock you have find and replace set as normal variables, they need to be strings.


Re: Argument type mismatch (argument 2) - PrawkC - 28.10.2012

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
For one, you can't have two stocks named the exact same thing...

and then for your strreplace stock you have find and replace set as normal variables, they need to be strings.
This