SA-MP Forums Archive
Checkpoint help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Checkpoint help (/showthread.php?tid=394612)



Checkpoint help - jueix - 23.11.2012

Ok, I have a problem When i enter my first checkpoint the code works perfectly but when i go to the second checkpoint it fucks up and dosn't load the next or disable heres the code.

pawn Код:
//top of the script
new Float:RandomTruckSpawn[][3] =
{
    // Positions, (X, Y, Z)
    {1362.2135,-1658.5692,13.4981},
    {2167.5745,-2274.1719,13.4780},
    {2726.4849,-2001.0597,13.5520}
};

//checkpoints
public OnPlayerEnterCheckpoint(playerid)
{
   
    new rand = random(sizeof(RandomTruckSpawn));

    if(IsPlayerInRangeOfPoint(playerid, 2.0, 797.7545,-610.6182,16.4326))
    {
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, RandomTruckSpawn[rand][0], RandomTruckSpawn[rand][1],RandomTruckSpawn[rand][2], 3.0);
    }
    if(IsPlayerInRangeOfPoint(playerid, 2.0, RandomTruckSpawn[rand][0], RandomTruckSpawn[rand][1],RandomTruckSpawn[rand][2]))
    {
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, 2470.6523,-2089.7607,13.6471, 3.0);
        PlayerInfo[playerid][pCheckPoint] = 3;
    }
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 2470.6523,-2089.7607,13.6471))
    {
        new string[128];
        new string1[128];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, 797.7545, -610.6182, 16.4326, 3.0);
        PlayerInfo[playerid][pCheckPoint] = 0;
        PlayerInfo[playerid][pCheck] = PlayerInfo[playerid][pCheck] +500;
        format(string, sizeof(string), "You now have a total of %d in cheques. Go cash them at the bank.", PlayerInfo[playerid][pCheck]);
        SendClientMessage(playerid, COLOR_GREEN, string);
        SendClientMessage(playerid, COLOR_GREEN, "Congratz, Job complete Head to the checkpoint to Redo your Route.");
        format(string1,sizeof(string1),"%s now has a total of %d in cheques.", name, PlayerInfo[playerid][pCheck]);
        SendMessageToHDutyAdmins(COLOR_ORANGE, string1);
    }
    return 1;
}



Re: Checkpoint help - Vince - 23.11.2012

Well duh, every time any player enters any checkpoint that random value is changed.

Let's assume that the player is at the first checkpoint and that the random value is 1. The next checkpoint is set to 1.
Now the player enters the checkpoint that you just put at location 1. The random value is recalculated. Let's assume it is now 2. Naturally, the player now isn't in range of RandomTruckSpawn[2][0] and thus the statement will return false.


Re: Checkpoint help - jueix - 23.11.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Well duh, every time any player enters any checkpoint that random value is changed.

Let's assume that the player is at the first checkpoint and that the random value is 1. The next checkpoint is set to 1.
Now the player enters the checkpoint that you just put at location 1. The random value is recalculated. Let's assume it is now 2. Naturally, the player now isn't in range of RandomTruckSpawn[2][0] and thus the statement will return false.
Ok, I get it now thanks =,)