• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Help with race
#1
Exclamation 
Hello everyone, I have the following question ...



How can I achieve that if a player types /enter and if a race is already in progress that the player is put in spectator mode of some user who is in the current race and if he presses enter, specifies another user and so on until that the current race ends and he enters the race ...



The other thing is that if there is no race in progress and the user types /enter the race start and the user enters the race automatically ...





Thanks
  Reply
#2
make new variable,?new bool:RaceStarted;

if(RaceStarted == true)
{
? ? ? ? ?// Spectate code
}
else if(RaceStarted == false)
{
// enter race code
}
  Reply
#3
Hi, thanks for your response



I understand that, the detail is how to make the code to specify a random player that is already within a race, if I explain myself? and if I press enter, it specifies another player who is already within a race





if(RaceStarted == true)

{

//What would be the code here that is going to show a random player who is in a race in progress?



}

else if(RaceStarted == false)

{

// enter race code

}



And if I press enter to switch me to another random player that is still within a race?
  Reply
#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
#5
if(RaceStarted == true)

{

? ? ? ? ?for(new i = 0 i < MAX_PLAYERS; i )

? ? ? ? ?{

? ? ? ? ? ? ? ? If(IsPlayerConnected(i) && PlayerOnRace[playerid] == true)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ?new rand =?Random(i);

? ? ? ? ? ? ? ? ? ? ? ? ? ?TogglePlayerSpectating(playerid,1);? ?


? ? ? ? ? ? ? ? ? ? ? ? ? ?PlayerSpectatePlayer(playerid,rand);



? ? ? ? ? ? ? ? }

? ? ? ? ?}

}

else if(RaceStarted == false)

{

// enter race code

}
  Reply
#6
(2020-11-06, 11:20 AM)dwp12345 Wrote: if(RaceStarted == true)

{

? ? ? ? ?for(new i = 0 i < MAX_PLAYERS; i )

? ? ? ? ?{

? ? ? ? ? ? ? ? If(IsPlayerConnected(i) && PlayerOnRace[playerid] == true)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ?new rand =?Random(i);

? ? ? ? ? ? ? ? ? ? ? ? ? ?TogglePlayerSpectating(playerid,1);? ?


? ? ? ? ? ? ? ? ? ? ? ? ? ?PlayerSpectatePlayer(playerid,rand);



? ? ? ? ? ? ? ? }

? ? ? ? ?}

}

else if(RaceStarted == false)

{

// enter race code

}

This is just...no...??
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
#7
(2020-11-06, 12:23 PM)Pinch Wrote:
(2020-11-06, 11:20 AM)dwp12345 Wrote: if(RaceStarted == true)

{

? ? ? ? ?for(new i = 0 i < MAX_PLAYERS; i )

? ? ? ? ?{

? ? ? ? ? ? ? ? If(IsPlayerConnected(i) && PlayerOnRace[playerid] == true)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ?new rand =?Random(i);

? ? ? ? ? ? ? ? ? ? ? ? ? ?TogglePlayerSpectating(playerid,1);? ?


? ? ? ? ? ? ? ? ? ? ? ? ? ?PlayerSpectatePlayer(playerid,rand);



? ? ? ? ? ? ? ? }

? ? ? ? ?}

}

else if(RaceStarted == false)

{

// enter race code

}

This is just...no...??







Which one should work?
  Reply
#8
(2020-11-06, 07:38 PM)FeNiixX Wrote:
(2020-11-06, 12:23 PM)Pinch Wrote:
(2020-11-06, 11:20 AM)dwp12345 Wrote: if(RaceStarted == true)

{

? ? ? ? ?for(new i = 0 i < MAX_PLAYERS; i )

? ? ? ? ?{

? ? ? ? ? ? ? ? If(IsPlayerConnected(i) && PlayerOnRace[playerid] == true)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? ? ?new rand =?Random(i);

? ? ? ? ? ? ? ? ? ? ? ? ? ?TogglePlayerSpectating(playerid,1);? ?


? ? ? ? ? ? ? ? ? ? ? ? ? ?PlayerSpectatePlayer(playerid,rand);



? ? ? ? ? ? ? ? }

? ? ? ? ?}

}

else if(RaceStarted == false)

{

// enter race code

}

This is just...no...??







Which one should work?

If you're using mine, it should work if you have YSI included, their solution is terrible and it won't work at al...



Just be smart and cautious while using mine because you need to handle iterators
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
#9
I try, but it does not specify the players who are in the race, that is, if I put the / enter command and if there are already players participating in the race, it does not specify them ... what can it be?
  Reply


Forum Jump: