SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/12/2011, 06:47 PM   #1
vincee
Big Clucker
 
vincee's Avatar
 
Join Date: Sep 2011
Posts: 87
Reputation: 3
Angry argument type mismatch (argument 2)

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 Code:
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

Code:
 C:\Users\machine\Desktop\PCRPbeta\gamemodes\pcrp.pwn(17644) : error 035: argument type mismatch (argument 2)
__________________
vincee is offline   Reply With Quote
Old 26/12/2011, 06:53 PM   #2
jamiesage123
Little Clucker
 
jamiesage123's Avatar
 
Join Date: May 2010
Location: United Kingdom
Posts: 42
Reputation: 32
Default Re: argument type mismatch (argument 2)

SendClientMessage(playerid, color, const message[])

pawn Code:
SendClientMessage(color, stringz);

Would become:

pawn Code:
SendClientMessage(i, color, stringz);
__________________


JUNE SALES - 50% OFF SA-MP SERVERS

jamiesage123 is offline   Reply With Quote
Old 26/12/2011, 06:53 PM   #3
[Diablo]
Huge Clucker
 
Join Date: Aug 2011
Location: Slovenia
Posts: 219
Reputation: 65
Default Re: argument type mismatch (argument 2)

pawn Code:
SendClientMessage(i, color, stringz);

should do the trick.
[Diablo] is offline   Reply With Quote
Old 26/12/2011, 07:25 PM   #4
vincee
Big Clucker
 
vincee's Avatar
 
Join Date: Sep 2011
Posts: 87
Reputation: 3
Default Re: argument type mismatch (argument 2)

For all 3 of them? what abput forward will it become playerid?
__________________
vincee is offline   Reply With Quote
Old 26/12/2011, 07:28 PM   #5
vincee
Big Clucker
 
vincee's Avatar
 
Join Date: Sep 2011
Posts: 87
Reputation: 3
Default Re: argument type mismatch (argument 2)

I did that and now get

pawn Code:
C:\Users\machine\Desktop\PCRPbeta\gamemodes\pcrp.pwn(17641) : error 025: function heading differs from prototype
__________________
vincee is offline   Reply With Quote
Old 26/12/2011, 07:39 PM   #6
=WoR=G4M3Ov3r
High-roller
 
Join Date: Nov 2010
Location: www.Ambrosia-Servers.com
Posts: 1,858
Reputation: 326
Default Re: argument type mismatch (argument 2)

PHP Code:
forward SendTaxiMessage(colorstringz[])

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

=WoR=G4M3Ov3r is offline   Reply With Quote
Old 26/12/2011, 08:37 PM   #7
Las Venturas CNR
Gangsta
 
Join Date: Feb 2010
Posts: 593
Reputation: 42
Default Re: argument type mismatch (argument 2)

Quote:
Originally Posted by =WoR=G4M3Ov3r View Post
PHP Code:
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 Code:
forward SendTaxiMessage(color, stringz[]);
Las Venturas CNR is offline   Reply With Quote
Old 26/12/2011, 09:18 PM   #8
=WoR=G4M3Ov3r
High-roller
 
Join Date: Nov 2010
Location: www.Ambrosia-Servers.com
Posts: 1,858
Reputation: 326
Default Re: argument type mismatch (argument 2)

Quote:
Originally Posted by Las Venturas CNR View Post
You forgot to include the semicolon at the end of the forward declaration, so the code will fail to compile.

pawn Code:
forward SendTaxiMessage(color, stringz[]);
I didn't see it, I just saw stringz has no brackets next to it.
=WoR=G4M3Ov3r is offline   Reply With Quote
Old 26/12/2011, 09:30 PM   #9
BigETI
Gangsta
 
BigETI's Avatar
 
Join Date: Mar 2010
Location: Germany
Posts: 863
Reputation: 160
Default AW: argument type mismatch (argument 2)

Worse example:
Quote:
pawn Code:
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 Code:
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 Code:
stock SendTaxiMessage(color, stringz[]) for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(Taxijob[i]) SendClientMessage(i, color, stringz);
BigETI is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
(1500)error 035: argument type mismatch (argument 2) eеe Scripting Help 2 17/12/2011 02:26 PM
command error 035: argument type mismatch (argument 2) Silent_Rainstorm Help Archive 5 07/06/2011 11:13 AM
[SOLVED]error 035: argument type mismatch (argument 1) KoczkaHUN Help Archive 0 28/04/2011 12:49 PM
error 035: argument type mismatch (argument 2) (ALOT) Master_Gangster Help Archive 5 13/02/2011 05:28 AM
SSCANF error 035: argument type mismatch (argument 2) DeltaAirlines12 Help Archive 6 11/02/2011 02:36 PM


All times are GMT. The time now is 11:45 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.