Spawn inside a vehicle
#1

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;
 	}
Reply
#2

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
Reply
#3

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 ?
Reply
#4

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
Reply
#5

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
Reply
#6

it did not change anything in the script :S
Reply
#7

Under "OnVehicleDeath" add "DestroyVehicle(vehicleid);"
Reply
#8

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
Under "OnVehicleDeath" add "DestroyVehicle(vehicleid);"
that just destroys all vehicles ?
Reply
#9

Quote:
Originally Posted by Madsen
Посмотреть сообщение
that just destroys all vehicles ?
No, that destroys the vehicle that died.
Reply
#10

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;
 	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)