SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/02/2016, 11:54 PM   #1
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,684
Reputation: 362
Default Argument!

PHP Code:
stock IsPlayerInRobberyCheckpoint(playerid)
{
    for(new 
i=0sizeof(RobberyCPS); i++)
    {
        if(
IsPlayerInDynamicCP(playeridRobberyCPS[i]))
        {
            return 
1;
        }
    }
    return 
0;

Error:[code]
mysql.pwn(1434) : error 035: argument type mismatch (argument 2)[code]

PHP Code:
new Float:RobberyCPS[14][3] = //ROBBERY LEVEL 1
    
{
        {
312.1780,-165.7560,999.6010}, 
        {
162.6582,-83.7168,1001.8047}, 
        {-
22.0830,-55.0324,1003.5469}, 
        {
206.1702,-100.3265,1005.2578},
        {
374.6855,-119.1805,1001.4995},
        {
412.1748,-17.7801,1001.8047}, 
        {-
202.8483,-40.6346,1002.2734}, 
        {
202.9123,-43.7781,1001.8047}, 
        {
369.3495,-6.0167,1001.8516}, 
        {
376.3930,-67.6462,1001.5151}, 
        {
410.8336,-52.6126,1001.8984}, 
        {
206.3587,-129.1778,1003.5078}, 
        {
204.1029,-159.6707,1000.5234}, 
        {
206.6491,-8.2347,1001.2109
    }; 
vassilis is offline   Reply With Quote
Old 29/02/2016, 12:07 AM   #2
EiresJason
Gangsta
 
Join Date: Mar 2013
Location: Dublin.
Posts: 685
Reputation: 76
Default Re: Argument!

The IsPlayerInDynamicCP function is looking for a checkpointid value, not the location of the checkpoint.

pawn Code:
IsPlayerInDynamicCP(playerid, checkpointid)  { /* code */ }

Somewhere within your script, you must have created dynamic checkpoints using something like:



pawn Code:
new RobberyCheckpoints[14];

for(...) // for loop
{
   RobberyCheckpoints[i] = CreateDynamicCheckpoint(RobberyCPs[i][0], RobberyCPs[i][1], RobberyCPs[i][2]...);
}

You need to use this variable:
pawn Code:
RobberyCheckpoints[...]

So your code should look like this:
pawn Code:
stock IsPlayerInRobberyCheckpoint(playerid)
{
    for(new i=0; i < sizeof(RobberyCPS); i++)
    {
        if(IsPlayerInDynamicCP(playerid, RobberyCheckpoints[i]))
        {
            return 1;
        }
    }
    return 0;
}
EiresJason is offline   Reply With Quote
Old 29/02/2016, 12:11 AM   #3
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,684
Reputation: 362
Default Re: Argument!

Quote:
Originally Posted by EiresJason View Post
The IsPlayerInDynamicCP function is looking for a checkpointid value, not the location of the checkpoint.

pawn Code:
IsPlayerInDynamicCP(playerid, checkpointid)  { /* code */ }

Somewhere within your script, you must have created dynamic checkpoints using something like:



pawn Code:
new RobberyCheckpoints[14];

for(...) // for loop
{
   RobberyCheckpoints[i] = CreateDynamicCheckpoint(RobberyCPs[i][0], RobberyCPs[i][1], RobberyCPs[i][2]...);
}

You need to use this variable:
pawn Code:
RobberyCheckpoints[...]

So your code should look like this:
pawn Code:
stock IsPlayerInRobberyCheckpoint(playerid)
{
    for(new i=0; i < sizeof(RobberyCPS); i++)
    {
        if(IsPlayerInDynamicCP(playerid, RobberyCheckpoints[i]))
        {
            return 1;
        }
    }
    return 0;
}
Ι changed it and did this
PHP Code:
stock IsPlayerInRobberyCheckpoint(playerid)
{
    
        if(
IsPlayerInDynamicCP(playeridsizeof(RobberyCPS)))
        {
            return 
1;
        }

    return 
0;

Is it wrong though ?
vassilis is offline   Reply With Quote
Old 29/02/2016, 12:15 AM   #4
EiresJason
Gangsta
 
Join Date: Mar 2013
Location: Dublin.
Posts: 685
Reputation: 76
Default Re: Argument!

Yeah that's not correct.

Where do you actually create the dynamic checkpoints?

You must have code similar to this:
pawn Code:
RobberyCheckpoints[i] = CreateDynamicCheckpoint(RobberyCPs[i][0], RobberyCPs[i][1], RobberyCPs[i][2]...);
Unless you haven't created the dynamic checkpoints at all?

Just in case it looks confusing, RobberyCheckpoints does not refer to the array of floats you have (RobberyCPs).
EiresJason is offline   Reply With Quote
Old 29/02/2016, 12:21 AM   #5
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,684
Reputation: 362
Default Re: Argument!

Quote:
Originally Posted by EiresJason View Post
Yeah that's not correct.

Where do you actually create the dynamic checkpoints?

You must have code similar to this:
pawn Code:
RobberyCheckpoints[i] = CreateDynamicCheckpoint(RobberyCPs[i][0], RobberyCPs[i][1], RobberyCPs[i][2]...);
Unless you haven't created the dynamic checkpoints at all?

Just in case it looks confusing, RobberyCheckpoints does not refer to the array of floats you have (RobberyCPs).
Ok i understood now how it works thank you EiresJason !
vassilis is offline   Reply With Quote
Old 29/02/2016, 01:42 AM   #6
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,772
Reputation: 754
Default Re: Argument!

That's not an efficient way of doing this.

What you can do is set a variable to hold the id of the robbery checkpoint a player has entered. And when they leave the checkpoint, set the variable to -1.

And use the variable for reference. There's no need for a loop and it avoids using extra conditions. It's optimal for a hotkey such as LEFT ALT as well.
SickAttack 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
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 19) : error 035: argument type mismatch (argument 1) Lirbo Scripting Help 2 12/12/2014 03:51 PM
error 35: Argument Type Mismatch (argument 2) Forbidden Name System Stoyanov Scripting Help 2 01/11/2014 09:50 PM
argument type mismatch (argument 1)(argument 3) Cerealguy Scripting Help 5 22/07/2014 08:00 PM
Argument type mismatch (argument 1) when getting info from MySQL database kamiliuxliuxliux Scripting Help 3 05/06/2014 03:08 PM
error 035: argument type mismatch (argument 2) [Using MySQL R7/R8 With Cache] viveka27 Scripting Help 1 21/05/2013 04:31 PM


All times are GMT. The time now is 03:45 PM.


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