Race, Save player Position? -
denNorske - 04.09.2012
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!
Re: Race, Save player Position? -
Deal-or-die - 04.09.2012
Whats the maximum number of players allowed in one race?
How do they enter the race?
Whats the XYZs that you want?
Re: Race, Save player Position? -
denNorske - 04.09.2012
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.
Re: Race, Save player Position? -
Roko_foko - 04.09.2012
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;
}
Re: Race, Save player Position? -
denNorske - 04.09.2012
Thankyou!
+rep
Can i use a facing angle script code, to set the players car facing angle?
Re: Race, Save player Position? -
Roko_foko - 04.09.2012
Not really. But you can SetVehicleZAngle(GetPlayerVehicleID(playerid),ANGL E);
Re: Race, Save player Position? -
denNorske - 05.09.2012
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.
Re: Race, Save player Position? -
FUNExtreme - 05.09.2012
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, ..)
Re: Race, Save player Position? -
leonardo1434 - 05.09.2012
Just a reminder, don't use "PlayerInRace[playerid]". any playerid above 11 is out of bounds.
Re: Race, Save player Position? -
denNorske - 05.09.2012
So, what would be the best thing to do ?