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=306423)



argument type mismatch (argument 2) - vincee - 26.12.2011

I'm creating a function that sends a message to people within the taxi job.

I already have Taxijob done and that works but I want to create a radio for them, and the sendtaximessage is needed.

pawn Код:
forward SendTaxiMessage(color, stringz)

public SendTaxiMessage(color, stringz[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(Taxijob[i] == 1)
    {
        SendClientMessage(color, stringz);
    }
}
}
I get

Код:
 C:\Users\machine\Desktop\PCRPbeta\gamemodes\pcrp.pwn(17644) : error 035: argument type mismatch (argument 2)



Re: argument type mismatch (argument 2) - jamiesage123 - 26.12.2011

SendClientMessage(playerid, color, const message[])

pawn Код:
SendClientMessage(color, stringz);
Would become:

pawn Код:
SendClientMessage(i, color, stringz);



Re: argument type mismatch (argument 2) - [Diablo] - 26.12.2011

pawn Код:
SendClientMessage(i, color, stringz);
should do the trick.


Re: argument type mismatch (argument 2) - vincee - 26.12.2011

For all 3 of them? what abput forward will it become playerid?


Re: argument type mismatch (argument 2) - vincee - 26.12.2011

I did that and now get

pawn Код:
C:\Users\machine\Desktop\PCRPbeta\gamemodes\pcrp.pwn(17641) : error 025: function heading differs from prototype



Re: argument type mismatch (argument 2) - =WoR=G4M3Ov3r - 26.12.2011

PHP код:
forward SendTaxiMessage(colorstringz[])
public 
SendTaxiMessage(colorstringz[])
{
for(new 
0MAX_PLAYERSi++)
{
    if(
IsPlayerConnected(i))
    {
        if(
Taxijob[i] == 1) return SendClientMessage(icolorstringz);
    }




Re: argument type mismatch (argument 2) - Las Venturas CNR - 26.12.2011

Quote:
Originally Posted by =WoR=G4M3Ov3r
Посмотреть сообщение
PHP код:
forward SendTaxiMessage(colorstringz[])
public 
SendTaxiMessage(colorstringz[])
{
for(new 
0MAX_PLAYERSi++)
{
    if(
IsPlayerConnected(i))
    {
        if(
Taxijob[i] == 1) return SendClientMessage(icolorstringz);
    }

You forgot to include the semicolon at the end of the forward declaration, so the code will fail to compile.

pawn Код:
forward SendTaxiMessage(color, stringz[]);



Re: argument type mismatch (argument 2) - =WoR=G4M3Ov3r - 26.12.2011

Quote:
Originally Posted by Las Venturas CNR
Посмотреть сообщение
You forgot to include the semicolon at the end of the forward declaration, so the code will fail to compile.

pawn Код:
forward SendTaxiMessage(color, stringz[]);
I didn't see it, I just saw stringz has no brackets next to it.


AW: argument type mismatch (argument 2) - BigETI - 26.12.2011

Worse example:
Quote:
pawn Код:
forward SendTaxiMessage(color, stringz[])

public SendTaxiMessage(color, stringz[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        if(Taxijob[i] == 1) return SendClientMessage(i, color, stringz);
    }
}
This callback will stop working after the first player with Taxijob = 1 and returns an unneeded value.

Probably correct one:
pawn Код:
forward SendTaxiMessage(color, stringz[]);
public SendTaxiMessage(color, stringz[]) for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(Taxijob[i]) SendClientMessage(i, color, stringz);
Another version if you don't use any timers or CallRemoteFunction/CallLocalFunction to call this function:
pawn Код:
stock SendTaxiMessage(color, stringz[]) for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(Taxijob[i]) SendClientMessage(i, color, stringz);