Spawn a vehicle in front of the player
#1

Hey
I want to spawn a vehicle in front of a player how wrote a command
I got that:
Код:
	if(strcmp(cmdtext, "/mycar", true)==0)
	{
  	switch(GetPlayerRank(playerid))
  	{
	    case 0:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Sorry,no car for you");
	    }
	    case 1:
	    {
             //Create vehicle
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Perenniel"); //404
	    }
	    case 2:
  	  {
             //..
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Sentinel"); //405
  	  }
	    case 3:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Previon"); //436
	    }
	    case 4:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Stallion"); //439
  	  }
	    case 5:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Saber"); //475
  	  }
  	  case 6:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your ZR-350"); //477
  	  }
  	  case 7:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Hotknife"); //434
  	  }
  	  case 8:
	    {
	      SendClientMessage(playerid, 0xFFFFFFFF, "Hope you'll enjoy your Turismo"); //451
  	  }
		}
I tought to CreateVehicle,but I don't think it will work,and I don't know how to set the position of the vehicle in function of the player's position
TIA
PS:Sorry for my english,i'm french
Reply
#2

pawn Код:
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
GetPlayerFacingAngle(playerid, Float:Angle);
CreateVehicle(411, X, Y, Z + 2.0, Angle + 90.0, -1, -1, 5000);
The best thing is to add the player into the vehicle.
Reply
#3

Quote:
Originally Posted by hanzen
pawn Код:
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
GetPlayerFacingAngle(playerid, Float:Angle);
CreateVehicle(411, X, Y, Z + 2.0, Angle + 90.0, -1, -1, 5000);
The best thing is to add the player into the vehicle.
erm you just copied my last post lol.

And You Also Need This
pawn Код:
new Float:X, Float:Y, Float:Z;
For the above to work.
Reply
#4

Yeah that script would spawn a vehicle over you (potential for crushing).

I think the thing you need is GetXYInfrontOfPlayer... not 100% where on forums this is but a quick search should find it...

It basically get's the co-ordinates for the spot just in front of your player, so wherever you use the command the vehicle will always appear in front of you.
Reply
#5

With that i'm really..in the car I can't move
But i found that for GetXYInFrontOfPlayer , i'll try
Thx to all of you

Edit:It doesn't work, i got:
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\mikefunc.inc(6) : warning 201: redefinition of constant/macro (symbol "MAX_INVALID_NOS_VEHICLES")
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\mikefunc.inc(1716) : error 021: symbol already defined: "IsPlayerInInvalidNosVehicle"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(79) : error 021: symbol already defined: "ValidEmail"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(132) : error 021: symbol already defined: "HexToInt"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(149) : error 021: symbol already defined: "IntToHex"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(172) : error 021: symbol already defined: "StrToInt"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(180) : error 021: symbol already defined: "IntToStr"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(210) : error 021: symbol already defined: "fcopy"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(254) : error 021: symbol already defined: "frename"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(268) : error 021: symbol already defined: "StripNewLine"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(355) : error 021: symbol already defined: "equal"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(366) : error 025: function heading differs from prototype
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(367) : error 021: symbol already defined: "strtok"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(448) : error 021: symbol already defined: "strlower"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\pawno\include\dutils.inc(464) : error 021: symbol already defined: "strupper"
C:\Program Files\Rockstar Games\GTA San Andreas\samp02Xserver.win32\gamemodes\pen1_freedoom.pwn(429) : error 017: undefined symbol "GetXYInfrontOfPlayer"
Anybody got another idea?
If I put Z + 3.0 or 4.0?
Re-Edit: Z + 60.0 works perfectly
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)