Race, Save player Position?
#1

I need to create a system that allow players to join the race, and remembers their place, so when the first player will join, his position will be [0] XYZ, the second will be [1] XYZ and etc.. I want to prevent players to spawn at the same point when they join the race.

Or at least, can someone tell me how to do that ? (i would love examples)

Thanks a lot!
Reply
#2

Whats the maximum number of players allowed in one race?
How do they enter the race?
Whats the XYZs that you want?
Reply
#3

Quote:
Originally Posted by Deal-or-die
Посмотреть сообщение
Whats the maximum number of players allowed in one race?
How do they enter the race?
Whats the XYZs that you want?
They enter the race with a command, /race. (not made yet, because i am unsure about some things).

The maximum will be 12 players, since there are 12 Spawns i currently added to my /save (savedpositions.txt).

The positions,

Код:
127.8469,5048.5444,94.8164,334.6952
123.4951,5051.3970,94.8160,327.0882
120.8506,5053.4937,94.8184,322.1022
117.7976,5056.6133,94.8181,309.9429
109.8828,5086.7397,94.8160,260.4043
110.7475,5090.4019,94.8162,254.2125
112.5187,5095.0850,94.8163,245.4224
170.7929,5057.2334,94.8160,50.0390
173.2888,5060.6724,94.8160,55.8434
175.8288,5065.4033,94.8162,65.1961
177.1729,5069.1895,94.8163,72.2535
178.2369,5072.7007,94.8230,80.0921
I can provide more if needed.
Reply
#4

make a global variable. on top of the script:
pawn Код:
#define MAX_RACING_PLAYERS 12
new bool:PlayerInRace[MAX_RACING_PLAYERS];
save the starting positions:
pawn Код:
new Float:SpawnPos[MAX_RACING_PLAYERS][3]=
{
    {xpos,ypos,zpos},
    {xpos,ypos,zpos},...
}
pawn Код:
public OnGameModeInit()
{
    for(new i=0;i<MAX_RACING_PLAYERS;i++)PlayerInRace=false;// there is no racing players on server start
    //...
}
When they type /race.
pawn Код:
for(new i=0;i<MAX_RACING_PLAYERS;i++)if(PlayerInRance== false)
{
    //put him in vehicle.
    SetVehiclePos(VehicleidFromAbove,SpawnPos[i][0],SpawnPos[i][1],SpawnPos[i][2]);
    //...
    break;
}
Reply
#5

Thankyou!

+rep


Can i use a facing angle script code, to set the players car facing angle?
Reply
#6

Not really. But you can SetVehicleZAngle(GetPlayerVehicleID(playerid),ANGL E);
Reply
#7

pawn Код:
for(new i=0;i<MAX_RACING_PLAYERS;i++)PlayerInRace=false;
That was the error line to:

Код:
\SAMP Server files\samp03dsvr_R2_win32\gamemodes\ogs.pwn(196) : error 033: array must be indexed (variable "PlayerInRace")
What could possibly be wrong here? I defined the MAX_RACING_PLAYERS and added the bool as he told me to in the above post.
Reply
#8

Quote:
Originally Posted by airplanesimen
Посмотреть сообщение
pawn Код:
for(new i=0;i<MAX_RACING_PLAYERS;i++)PlayerInRace=false;
That was the error line to:

Код:
\SAMP Server files\samp03dsvr_R2_win32\gamemodes\ogs.pwn(196) : error 033: array must be indexed (variable "PlayerInRace")
What could possibly be wrong here? I defined the MAX_RACING_PLAYERS and added the bool as he told me to in the above post.
The original poster forgot the index
pawn Код:
for(new i=0; i<MAX_RACING_PLAYERS-1; i++) PlayerInRace[i] = false;
Now to check if the race is full you could use a check like this
pawn Код:
if(AmountOfRacers == sizeof(SpawnPos))
{
//It's full
}
You will obviously have to add that variable by yourself and add one when a player joins and remove one when a player leaves the race (Don't forget cases like OnPlayerDisconnect, using a teleport, ..)
Reply
#9

Just a reminder, don't use "PlayerInRace[playerid]". any playerid above 11 is out of bounds.
Reply
#10

So, what would be the best thing to do ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)