[FIXED]Question about CreateVehicle -
5002 - 08.07.2013
i want make spawn code
i use CreateVehicle
but i want know what must do for spawn car front of player

?
any help?
Re: Question about CreateVehicle -
Red_Dragon. - 08.07.2013
This code will spawn the player IN the car (in this example, an Infernus)
pawn Код:
new Float:X, Float:Y, Float:Z;
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);
That's just an example to help you out.
Re: Question about CreateVehicle -
5002 - 08.07.2013
errors
i add
new Float:X, Float:Y, Float:Z;
under defines
Код:
#define FILTERSCRIPT
#include <a_samp>
#define LSPDDMenu 1
#define RED "{FF0000}"
#define YELLOW "{FFFF00}"
#define WHITE "{FFFFFF}"
#define BLUE "{1E90FF}"
#define GREEN "{2E8B57}"
#if defined FILTERSCRIPT
new LSPD;
new LSFD1;
new LSFD2;
new LSFD3;
new LSFD;
new Float:X, Float:Y, Float:Z;
public OnFilterScriptInit()
{
...
and add your code under my code
Код:
if (!strcmp(cmdtext,"/heli,true,5))
{
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);
}
and now have errors
Код:
F:\GTA San Andreas\111\0.3x\filterscripts\1.pwn(425) : error 037: invalid string (possibly non-terminated string)
F:\GTA San Andreas\111\0.3x\filterscripts\1.pwn(428) : error 017: undefined symbol "Angle"
F:\GTA San Andreas\111\0.3x\filterscripts\1.pwn(429) : error 017: undefined symbol "Angle"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
Re: Question about CreateVehicle -
SantoN - 08.07.2013
pawn Код:
if(!strcmp(cmdtext, "/heli", true, 5))
{
new Float:X, Float:Y, Float:Z, Float:Angle;
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);
return 1;
}
Re: Question about CreateVehicle -
SuperViper - 08.07.2013
Remove all the code anyone else told you to add.
Add the following callback somewhere in your script outside of any other function or callback:
pawn Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
GetPlayerPos(playerid, x, y, Angle);
GetPlayerFacingAngle(playerid, Angle);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
}
x += (distance * floatsin(-Angle, degrees));
y += (distance * floatcos(-Angle, degrees));
}
Then add the following command:
pawn Код:
if(!strcmp(cmdtext, "/heli", true, 5))
{
new Float: playersPosition[3];
GetPlayerPos(playerid, playersPosition[0], playersPosition[1], playersPosition[2]);
GetXYInFrontOfPlayer(playerid, playersPosition[0], playersPosition[1], 5);
CreateVehicle(411, playersPosition[0], playersPosition[1], playersPosition[2], 0, -1, -1, 5000);
}
Re: Question about CreateVehicle -
5002 - 08.07.2013
worked
tank
rep for you and dragon
Re: Question about CreateVehicle -
xganyx - 08.07.2013
use this. this is more simple.
add this to top of your script.
pawn Код:
new SpawnedVehicle[MAX_PLAYERS];
and put this every where you want
pawn Код:
stock SpawnCar(playerid,vehicleid)
{
if(SpawnedVehicle[playerid] != 0)
{
DestroyVehicle(SpawnedVehicle[playerid]);
}
new Float:X, Float:Y, Float:Z, Float:Angle;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
GetPlayerFacingAngle(playerid, Float:Angle);
SpawnedVehicle[playerid] = CreateVehicle(vehicleid, X, Y, Z + 2.0, Angle + 90.0, -1, -1, 600);
SetVehicleVirtualWorld(SpawnedVehicle[playerid], GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(SpawnedVehicle[playerid], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, SpawnedVehicle[playerid], 0);
}
Command like this:
if you use zcmd:
pawn Код:
CMD:heli(playerid,params[])
{
SpawnCar(playerid,411);
return 1;
}
if use normal command
pawn Код:
if(!strcmp(cmdtext, "/heli", true, 5))
{
SpawnCar(playerid,411);
}