SA-MP Forums Archive
Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help (/showthread.php?tid=184406)



Help - ColdXX - 19.10.2010

How to make some players spawn in a car in a certain positio just like in races?
Like when the first player types /race he is placed first,the second one ,next to him ,3rd one behind the first,and so on!


Re: Help - TouR - 19.10.2010

Well you can use global variables for this like

new EnteredRace;

when first player do /race it turns to 1 so you can work withcases

like

Код:
switch(EnteredRace)
{
case 1: { SetPlayerPos(playerid, 1stX, 1stY, 1stZ); EnteredRace++; }
case 2: { SetPlayerPos(playerid, 2ndX, 2ndY, 2ndZ); EnteredRace++; }
case 3: { SetPlayerPos(playerid, 3rdX, 3rdY, 3rdZ); EnteredRace++; }
case 4: { SetPlayerPos(playerid, 4thX, 4thY, 4thZ); EnteredRace++; }
// add as many positions as you wish
}



Re: Help - ColdXX - 19.10.2010

Код:
	case 1:
		{
		SetPlayerPos(playerid, 1527.1901,-1712.9625,13.0891);
		EnteredRace++;
        new vehicle;		vehicle = GetPlayerVehicleID(playerid);		DestroyVehicle(vehicle);
		new Float:Pos[3]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
	  	new veh = CreateVehicle(522, 1527.1901,-1712.9625,13.0891,179.3196, -1, -1,10000);
        SetVehicleVirtualWorld(veh, 3);//GetPlayerVehicleID(playerid)
  		PutPlayerInVehicle(playerid, veh, 0);
		}
Is this code good?


Re: Help - TouR - 19.10.2010

Quote:
Originally Posted by ColdXX
Посмотреть сообщение
Код:
	case 1:
		{
		SetPlayerPos(playerid, 1527.1901,-1712.9625,13.0891);
		EnteredRace++;
        new vehicle;		vehicle = GetPlayerVehicleID(playerid);		DestroyVehicle(vehicle);
		new Float:Pos[3]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
	  	new veh = CreateVehicle(522, 1527.1901,-1712.9625,13.0891,179.3196, -1, -1,10000);
        SetVehicleVirtualWorld(veh, 3);//GetPlayerVehicleID(playerid)
  		PutPlayerInVehicle(playerid, veh, 0);
		}
Is this code good?
It seems correct do you have any errors?


Re: Help - ColdXX - 19.10.2010

Works just fine!
Now what about a /go command that sets the players in the race Controllable = 1?
InRace..


Re: Help - TouR - 19.10.2010

well you need an array for every player that joins the race so

Код:
new Joined[MAX_PLAYERS]; // at the top of the script

Joined[playerid] = 1; // under /race command

if(strcmp(cmd, "/go", true) == 0)
{
     for(new i=0; i<MAX_PLAYERS; i++)
     {
          if(Joined[i] == 1)
         {
             TogglePlayerControllable(i, true);
         }
     }
     return 1;
 }