argument type mismatch (argument 2)
#1

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)
Reply
#2

SendClientMessage(playerid, color, const message[])

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

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

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

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

I did that and now get

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

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

Reply
#7

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[]);
Reply
#8

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.
Reply
#9

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)