Spawn inside a vehicle -
Madsen - 19.02.2011
hey
I have made this single command for spawning a vehicle, but i want to spawn inside the vehicle.
here is what i got so far
Код:
new Float:x, Float:y, Float:z, Float:ang;
new VehicleID = GetPlayerVehicleID(playerid);
new cmd[128];
if(strcmp(cmd, "/Infernus", true) == 0)
{
if (!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, 0xFFFF00FF, "You are already inside a vehicle.");
return 1;
}
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, ang);
CreateVehicle(411, x+1, y+1, z+1, 0, 0, 0, 600);
SetVehicleZAngle(VehicleID, ang);
return 1;
}
Re: Spawn inside a vehicle - rjjj - 19.02.2011
Just put this line in your command:
pawn Код:
PutPlayerInVehicle(playerid, CreateVehicle(411, x+1, y+1, z+1, 0, 0, 0, 600), 0);
I hope that i have helped
Re: Spawn inside a vehicle -
Madsen - 19.02.2011
thx it worked with a little editing
another question i want to ask about
:
When the cars explode they respawn the place i wrote /infernus. how can i get them removed when they explode
?
Re: Spawn inside a vehicle - rjjj - 19.02.2011
Quote:
Originally Posted by Madsen
thx it worked with a little editing
another question i want to ask about :
When the cars explode they respawn the place i wrote /infernus. how can i get them removed when they explode ?
|
You can do like that
.
pawn Код:
//Put In The Top of your GameMode:
new CreatedVehicleVar[MAX_PLAYERS];
//In your command, change this line:
CreateVehicle(411, x+1, y+1, z+1, 0, 0, 0, 600);
//for:
CreatedVehicleVar[playerid] = CreateVehicle(411, x+1, y+1, z+1, 0, 0, 0, 600);
//And at least, put it in OnVehicleDeath callback:
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(CreatedVehicleVar[x] == vehicleid)
{
DestroyVehicle(vehicleid);
}
}
I hope that i have helped
Re: Spawn inside a vehicle -
Madsen - 28.02.2011
i think i understand it xD, but i will try look into it, now i atleast got a clue how to avoid the vehicles that are everywhere in my server
Re: Spawn inside a vehicle -
Madsen - 28.02.2011
it did not change anything in the script :S
Re: Spawn inside a vehicle - Max_Coldheart - 28.02.2011
Under "OnVehicleDeath" add "DestroyVehicle(vehicleid);"
Re: Spawn inside a vehicle -
Madsen - 28.02.2011
Quote:
Originally Posted by Max_Coldheart
Under "OnVehicleDeath" add "DestroyVehicle(vehicleid);"
|
that just destroys all vehicles
?
Re: Spawn inside a vehicle -
MrDeath537 - 28.02.2011
Quote:
Originally Posted by Madsen
that just destroys all vehicles ?
|
No, that destroys the vehicle that died.
Re: Spawn inside a vehicle -
Madsen - 28.02.2011
Quote:
Originally Posted by MrDeath537
No, that destroys the vehicle that died.
|
that is also what i mean xD, i only want the spawned vehicle to be deleted
this is how it looks now
Код:
new Float:x, Float:y, Float:z, Float:ang;
new VehicleID = GetPlayerVehicleID(playerid);
if (strcmp("/infernus", cmdtext, true, 10) == 0)
{
if (IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, 0xAA3333AA, "( ! ) You are already inside a vehicle.");
return 1;
}
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, ang);
SetVehicleZAngle(VehicleID, ang);
PutPlayerInVehicle(playerid, CreateVehicle(411, x+1, y+1, z+1, 0, 123, 123, 600), 0);
return 1;
}