Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Help with race

 
  • 0 Vote(s) - 0 Average
Pawn Help with race
FeNiixX
Offline

Burgershot Member
Posts: 10
Threads: 4
Joined: Apr 2019
Reputation: 0
#1
2020-11-05, 07:30 AM
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
dwp12345
Offline

Burgershot Member
Posts: 8
Threads: 4
Joined: Nov 2020
Reputation: 0
Location: SG
#2
2020-11-06, 05:08 AM (This post was last modified: 2020-11-06, 05:10 AM by dwp12345.)
make new variable, new bool:RaceStarted;

if(RaceStarted == true)
{
         // Spectate code
}
else if(RaceStarted == false)
{
// enter race code
}
FeNiixX
Offline

Burgershot Member
Posts: 10
Threads: 4
Joined: Apr 2019
Reputation: 0
#3
2020-11-06, 06:37 AM
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?
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#4
2020-11-06, 11:04 AM
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.
dwp12345
Offline

Burgershot Member
Posts: 8
Threads: 4
Joined: Nov 2020
Reputation: 0
Location: SG
#5
2020-11-06, 11:20 AM
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
}
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#6
2020-11-06, 12:23 PM
(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.
FeNiixX
Offline

Burgershot Member
Posts: 10
Threads: 4
Joined: Apr 2019
Reputation: 0
#7
2020-11-06, 07:38 PM
(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?
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#8
2020-11-06, 07:48 PM
(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.
FeNiixX
Offline

Burgershot Member
Posts: 10
Threads: 4
Joined: Apr 2019
Reputation: 0
#9
2020-11-06, 08:32 PM
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?
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode