random check points
#1

Hello,

Im getting this error:
pawn Код:
(1662) : warning 202: number of arguments does not match definition
// this is the setplayercheckpoint line
with this code:
pawn Код:
forward RandomCheckPoint();

new Float:RandomCP[][5] =
{
    { 2798.1702,-1576.2926,10.9272, 10.0 },
    { 2060.4375,-2091.2126,13.5469, 10.0 },
    { 070.8125,-2384.6160,13.5469, 10.0 },
    { 900.7358,-1204.0779,16.9832, 10.0 },
    { 800.1103,-1542.8258,13.5526, 10.0 }
};

SetTimer("RandomCP",20000,true);

public RandomCheckPoint()
{
    foreach(Player, i)
    {
        new rand = random(sizeof(RandomCP));
           
        SetPlayerCheckpoint(i,RandomCP[rand][0],RandomCP[rand][1],RandomCP[rand][2],RandomCP[rand][3],RandomCP[rand][4]); //ERROR LINE <===
    }
    return 1;
}
I want a random checkpoint to appear every 20 seconds
Reply
#2

pawn Код:
SetPlayerCheckpoint(i, RandomCP[rand][0], RandomCP[rand][1], RandomCP[rand][2], RandomCP[rand][3]);
Edit: Also, your timer is wrong.
pawn Код:
SetTimer("RandomCheckPoint", 20000, true);
Reply
#3

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
pawn Код:
SetPlayerCheckpoint(i, RandomCP[rand][0], RandomCP[rand][1], RandomCP[rand][2], RandomCP[rand][3]);
Edit: Also, your timer is wrong.
pawn Код:
SetTimer("RandomCheckPoint", 20000, true);
Thank you, but i dont understand... i have 5 random check point coords but you removed one of them? and when i put it back it gives me that error. why?
Reply
#4

pawn Код:
#include <a_samp>
#include <YSI\y_iterate>

public OnGameModeInit( )
{
    SetTimer( "RandomCheckPoint" , 20000, true );
    return true;
}

forward RandomCheckPoint( );

new Float:RandomCP[  ][ 4 ] = // change this to 4, number starts from 0 not 1
{
    { 2798.1702,-1576.2926,10.9272, 10.0 },
    { 2060.4375,-2091.2126,13.5469, 10.0 },
    { 070.8125,-2384.6160,13.5469, 10.0 },
    { 900.7358,-1204.0779,16.9832, 10.0 },
    { 800.1103,-1542.8258,13.5526, 10.0 }
};


public RandomCheckPoint()
{
    foreach(Player, i)
    {
        if(!IsPlayerConnected(i)) continue;
       
        new rand = random( sizeof( RandomCP ) );
        SetPlayerCheckpoint( i, RandomCP[rand][0], RandomCP[rand][1], RandomCP[rand][2], RandomCP[rand][3] ); // this aswell
    }
    return 1;
}
The code above explains

Remember this, everyone you create an array it always STARTS at Null = 0
Reply
#5

pawn Код:
new Float:RandomCP[][5] =
The first [] is the amount of checkpoints (If without number, the script calculates the checkpoints itself), whereas the second [] is the amount of params for each checkpoint.
Also just remove the number 5, it works without it too, as it will auto count the params.
Reply
#6

Ah ok thanks guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)