Checkpoint System
#1

Hey guys!
I just got this ideea!
At each 10 minutes a checkpoint appears! Then player needs 10 minutes to reach the checkpoint to receive the gift!
If they dont reach it in 10 minutes,then a new one apperas on a different place and same story!
Could someone help me get this started?
Reply
#2

I guess you should get the coords for the cp's first
Reply
#3

orly?hehe
no i was wondering should i do sth like new CheckPoints[20][3] =
{
(x,y,z),
...,
...,
...,
...
};

then ermm
on player enter CP
Switch CheckPoints? or wut? help
Reply
#4

I'll make something, wait.
Reply
#5

pawn Код:
new Float:CPX, Float:CPY, Float:CPZ; // Top of script - These will be used to store the checkpoints location

#define CHECKPOINT_RADIUS 10 // The radius of the random checkpoints in units

SetTimer("Checkpoints", 600000, true); // OnGameModeInit - here we set the timer

// Bottom of script:
forward Checkpoints(); // Forward the timer
public Checkpoints()
{
    SetNewRandomCheckpoint(); // A custom stock for this script is called here
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
            GameTextForPlayer(i, "~w~A new ~r~checkpoint ~w~~n~has been set!", 5000, 5);
    }
    return 1;
}


stock SetNewRandomCheckpoint() // Also in the bottom
{

/* When we make this a stock instead of putting it in the timer,
   we can call this more than just when the timer is up.
   For example, you can make a "/newcheckpoint"-command with this stock. */


    new rand = Random(20) // Number of checkpoints that you have - edit 20!
    switch(rand) // We make a switch to set a checkpoint for each random number
    {
   
        /* SetCheckpointForAll is another custom stock - this is to set
           the checkpoint to all players easily, instead of having
           a player loop at every 'case' */

           
        case 0: SetCheckpointForAll(x, y, z); // Replace the X, Y and Z coordinates with the ones of your checkpoints
        case 1: SetCheckpointForAll(x, y, z); // Same here
        case 2: SetCheckpointForAll(x, y, z); // Etc.
        case 3: SetCheckpointForAll(x, y, z);
        case 4: SetCheckpointForAll(x, y, z);
        case 5: SetCheckpointForAll(x, y, z);
        case 6: SetCheckpointForAll(x, y, z);
        case 7: SetCheckpointForAll(x, y, z);
        case 8: SetCheckpointForAll(x, y, z);
        case 9: SetCheckpointForAll(x, y, z);
        case 10: SetCheckpointForAll(x, y, z);
        case 11: SetCheckpointForAll(x, y, z);
        case 12: SetCheckpointForAll(x, y, z);
        case 13: SetCheckpointForAll(x, y, z);
        case 14: SetCheckpointForAll(x, y, z);
        case 15: SetCheckpointForAll(x, y, z);
        case 16: SetCheckpointForAll(x, y, z);
        case 17: SetCheckpointForAll(x, y, z);
        case 18: SetCheckpointForAll(x, y, z);
        case 19: SetCheckpointForAll(x, y, z);
    }
    return 1;
}


stock SetCheckpointForAll(x, y, z) // Also in the bottom of the script
{
    CPX = x;
    CPY = y;
    CPZ = z;
    for(new i = 0; i < MAX_PLAYERS; i++) // Loop through all players and set their checkpoint
    {
   
            /* Here we set the checkpoint for the individual player
               to the designated coordinates from the previous stock.
               We also use the radius defined at the top of the script. */

               
            SetPlayerCheckpoint(i, x, y, z, CHECKPOINT_RADIUS);
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10.0, CPX, CPY, CPZ) // Checks if the player is within the coordinates of the current checkpoint
    {
        /* Here you can put the code of what will happen
           when the player enters the random checkpoint */

    }
    return 1;
}
I can't remember if I made a mistake in the SetCheckpointForAll-stock. I'm not sure if I have to define in the stock that the numbers are indeed floats... oh well, try it, tell me if it fails.

You're welcome.
Reply
#6

Its not working eh...

look here!
http://pastebin.com/ejSauZ8S
Reply
#7

Tell me what lines are what please.

I guess there were some bugs in my script but I obviously expected you to edit it :P
Reply
#8

Yea i tried to edit but ...blah!
Here!

http://pastebin.com/cKC5ZxL1
Reply
#9

He missed the Float tag in SetCheckpointForAll

Here another version based on the good old gPlayerCheckpointStatus -> pastebin.com/HRQLrbwU

(Yes you could replace the array with a PVar)
Reply
#10

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
He missed the Float tag in SetCheckpointForAll

Here another version based on the good old gPlayerCheckpointStatus -> pastebin.com/HRQLrbwU

(Yes you could replace the array with a PVar)
Ah, I knew I forgot something
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)