CP-s in Event
#1

Hello, I made a new event for my server but every time player passes 6th CP something goes wrong, sometimes it spawns CP on wrong place that I never made cp on, somethimes when player pickup that 6th or 7th Cp othing happens like he did not picked it up. And I have not used OnPlayerEnterRaceCP bcz idk...

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(EventID == 3) //event stunt
    {
		if(PlayerInfo[playerid][pEventCPID] == 0) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 959.36432, -1854.05444, 12.02527, 7.0); PlayerInfo[playerid][pEventCPID] = 1; }
		else if(PlayerInfo[playerid][pEventCPID] == 1) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 801.66388, -1850.07349, 12.02527, 7.0); PlayerInfo[playerid][pEventCPID] = 2; }
		else if(PlayerInfo[playerid][pEventCPID] == 2) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 678.62463, -1832.78308, 12.02527, 7.0); PlayerInfo[playerid][pEventCPID] = 3; }
		else if(PlayerInfo[playerid][pEventCPID] == 3) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 694.63666, -1804.13293, 12.84717, 7.0); PlayerInfo[playerid][pEventCPID] = 4; }
		else if(PlayerInfo[playerid][pEventCPID] == 4) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 729.37726, -1804.07556, 0.05944, 7.0); PlayerInfo[playerid][pEventCPID] = 5; }
		else if(PlayerInfo[playerid][pEventCPID] == 5) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 726.25867, -1749.68750, 31.61955, 7.0); PlayerInfo[playerid][pEventCPID] = 6; }
		else if(PlayerInfo[playerid][pEventCPID] == 6) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 688.04242, -1785.26147, 58.55573, 7.0); PlayerInfo[playerid][pEventCPID] = 7; }
		else if(PlayerInfo[playerid][pEventCPID] == 7) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 639.02423, -1767.14063, 22.80568, 7.0); PlayerInfo[playerid][pEventCPID] = 8; }
		else if(PlayerInfo[playerid][pEventCPID] == 8) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 610.37122, -1745.54443, 31.65541, 7.0); PlayerInfo[playerid][pEventCPID] = 9; }
		else if(PlayerInfo[playerid][pEventCPID] == 9) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 545.67950, -1714.56372, 53.36265, 7.0); PlayerInfo[playerid][pEventCPID] = 10; }
		else if(PlayerInfo[playerid][pEventCPID] == 10) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 442.36975, -1693.63794, 91.53526, 7.0); PlayerInfo[playerid][pEventCPID] = 11; }
		else if(PlayerInfo[playerid][pEventCPID] == 11) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 353.11389, -1676.56555, 83.79629, 7.0); PlayerInfo[playerid][pEventCPID] = 12; }
		else if(PlayerInfo[playerid][pEventCPID] == 12) { DisablePlayerCheckpoint(playerid); SetPlayerCheckpoint(playerid, 262.00821, -1711.21289, 52.94380, 7.0); PlayerInfo[playerid][pEventCPID] = 13; }
		else if(PlayerInfo[playerid][pEventCPID] == 13) { DisablePlayerCheckpoint(playerid); PassedEvent(playerid); PlayerInfo[playerid][pEventCPID] = -1; }
   }
return 1;
}
And this first CP is not really first because when I type "/startevent EventID" i automatically creats first CP
Reply
#2

Why not using IsPlayerInRangeOfPoint in OnPlayerEnterCheckpoint callback instead?

Edit:
Also why don't you use switch statement instead of doing if and else if?
pawn Код:
switch(PlayerInfo[playerid][pEventCPID])
{
     case...
}
Show the startevent command, you should start setting player's checkpoint from there and it'll continue in OnPlayerEnterCheckpoint callback.
Reply
#3

Are pEventCPID or EventID modified in any way during the event?

Since it is a static event, you can do it in a better way.
pawn Код:
new const Float: EventStunt_Checkpoints[][] =
{
    {959.36432, -1854.05444, 12.02527}, // 0
    {801.66388, -1850.07349, 12.02527}, // 1
    {678.62463, -1832.78308, 12.02527}, // 2
    {694.63666, -1804.13293, 12.84717}, // 3
    {729.37726, -1804.07556, 0.05944},  // 4
    {726.25867, -1749.68750, 31.61955}, // 5
    {688.04242, -1785.26147, 58.55573}, // 6
    {639.02423, -1767.14063, 22.80568}, // 7
    {610.37122, -1745.54443, 31.65541}, // 8
    {545.67950, -1714.56372, 53.36265}, // 9
    {442.36975, -1693.63794, 91.53526}, // 10
    {353.11389, -1676.56555, 83.79629}, // 11
    {262.00821, -1711.21289, 52.94380}  // 12
};

public OnPlayerEnterCheckpoint(playerid)
{
    if (EventID == 3) //event stunt
    {
        if (0 <= PlayerInfo[playerid][pEventCPID] < sizeof(EventStunt_Checkpoints))
        {
            SetPlayerCheckpoint(playerid, EventStunt_Checkpoints[0], EventStunt_Checkpoints[1], EventStunt_Checkpoints[2], 7.0);
            PlayerInfo[playerid][pEventCPID]++;
        }
        else if (PlayerInfo[playerid][pEventCPID] == 13)
        {
            DisablePlayerCheckpoint(playerid);
            PassedEvent(playerid);
            PlayerInfo[playerid][pEventCPID] = -1;
        }
    }
    return 1;
}
Reply
#4

Thank you for your help, yeah that ways would be smarter but somehow I think I fixed it. I changed all CP-s size (some of them was 3.0) to 7.0 , and now it is normal (unless it was just this time)

[ rep+ to both ]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)