• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Help with race
#4
Code:
// Change 20 to max race entries or MAX_PLAYERS if it's not limited

// Also, this works if you can have only one race started at the time, otherwise add [x] to the iterator,ex:

//new Iterator:RaceMembers[5]<20>;

new Iterator: RaceMembers<20>;



CMD:enter(playerid, params[])

{

    if(Iter_Contains(RaceMembers, playerid))

        return SendClientMessage(playerid, -1, "You're already in the race!");

        

    if(RaceStarted == true)

    {

        TogglePlayerSpectating(playerid, 1);

        PlayerSpectatePlayer(playerid, Iter_Random(RaceMembers));

    }

    else if(RaceStarted == false)

    {

        // Add player to the RaceMembers iterator, don't forget to remove them via Iter_Remove(RaceMembers, playerid); once the race is over/they exit/disconnect or they'll still be treated as the race member

        new success = Iter_Add(RaceMembers, playerid);

        if(!success)

            return SendClientMessage(playerid, -1, "Ths race is already full!");



        // Enter race code...

    }

}



Also, don't forget to add PlayerSpectatePlayer(playerid, Iter_Random(RaceMembers)); to the OnPlayerKeyStateChange
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply


Messages In This Thread
Help with race - by FeNiixX - 2020-11-05, 07:30 AM
RE: Help with race - by dwp12345 - 2020-11-06, 05:08 AM
RE: Help with race - by FeNiixX - 2020-11-06, 06:37 AM
RE: Help with race - by Pinch - 2020-11-06, 11:04 AM
RE: Help with race - by dwp12345 - 2020-11-06, 11:20 AM
RE: Help with race - by Pinch - 2020-11-06, 12:23 PM
RE: Help with race - by FeNiixX - 2020-11-06, 07:38 PM
RE: Help with race - by Pinch - 2020-11-06, 07:48 PM
RE: Help with race - by FeNiixX - 2020-11-06, 08:32 PM

Forum Jump: