Removing a vehicle -
Snowman12 - 02.08.2011
Hey,
Im making a car spawner dialog and i was thinking wait hat heppens to the other car it turns out if theplayer spwn a car from within a car the car fals on top the car he was driving
With out changing the way the player canexit the car and leave it parked up for 5 - 10 - mins until it respawns hw can i move his old car out of the way and delete it
If possible if the player is a passenger i want to let him becal to spawn a car still like he can now as he spawns in a car over the other side of the road
Re: Removing a vehicle -
iPLEOMAX - 02.08.2011
Hard to understand.. but..
pawn Код:
//Use this to delete the current car:
DestroyVehicle( GetPlayerVehicleID(playerid) );
//Use this protection if player is already in a car:
if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(pllayerid, 0xFF0000FF, "You already have a vehicle!");
Re: Removing a vehicle -
TheArcher - 02.08.2011
Quote:
Originally Posted by iPLEOMAX
Hard to understand.. but..
pawn Код:
//Use this to delete the current car: DestroyVehicle( GetPlayerVehicleID(playerid) );
//Use this protection if player is already in a car: if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(pllayerid, 0xFF0000FF, "You already have a vehicle!");
|
If someone use a command with that code the car can be destroyed.
Re: Removing a vehicle -
Snowman12 - 02.08.2011
Sorry about it bing unclear and yeah thats what i was looking for thanks
Re: Removing a vehicle -
shaikh007 - 02.08.2011
Quote:
Originally Posted by Snowman12
Hey,
Im making a car spawner dialog and i was thinking wait hat heppens to the other car it turns out if theplayer spwn a car from within a car the car fals on top the car he was driving
With out changing the way the player canexit the car and leave it parked up for 5 - 10 - mins until it respawns hw can i move his old car out of the way and delete it
If possible if the player is a passenger i want to let him becal to spawn a car still like he can now as he spawns in a car over the other side of the road
|
will you make it little more clear it is hard to understand what you want
Re: Removing a vehicle -
iPLEOMAX - 02.08.2011
Quote:
Originally Posted by Anthony_prince
If someone use a command with that code the car can be destroyed.
|
Yeah, I know. To avoid this, he needs to create a var which stores the player's car and all..
Anyway:
Update:
pawn Код:
// On top of your script.
new PlayerVehicle[MAX_PLAYERS]; //Global variable where the player's vehicle id is stored.
//When you spawn a car (like using the command or dialog):
new vehicleid = CreateVehicle(......); //remember to put modelid, x, y, z etc.
PlayerVehicle[playerid] = vehicleid; //Now, the player's created vehicle id is saved in a variable.
//When you want to destroy the car (similar to the code i gave you before)
SetVehicleToRespawn( GetPlayerVehicleID(playerid) ); //If it's a server vehicle, it will be respawned.
DestroyVehicle( PlayerVehicle[playerid] ); // and it destroys the vehicle created by this player before.
Now, vehicleid = CreateVehicle(....); again.....
//To Make sure it gets deleted when player disconnects:
public OnPlayerDisconnect( playerid )
{
DestroyVehicle( PlayerVehicle[playerid] );
return 1;
}
Goodluck making it.
Re: Removing a vehicle -
Snowman12 - 02.08.2011
ok so this is what i have
pawn Код:
oldcar = GetPlayerVehicleID(playerid);
RemovePlayerFromVehicle(playerid);
DestroyVehicle(oldcar);
and when the player spawns another car the old car remains
EDIT let me read the post above it didnt load at first
oh i see dont worry imma try to edit the post above thanks
Re: Removing a vehicle -
Snowman12 - 02.08.2011
pawn Код:
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SetVehicleToRespawn( GetPlayerVehicleID(playerid) );
RemovePlayerFromVehicle(playerid);
DestroyVehicle( PlayerVehicle[playerid] );
spawncar = CreateVehicle(411, x, y, z, a, -1, -1, 60000);
PutPlayerInVehicle(playerid, spawncar, 0);
PlayerVehicle[playerid] = spawncar;
}
Ok so heres the code ive made so far and the old car doesnt get destroyed it just stays there?
Re: Removing a vehicle -
iPLEOMAX - 02.08.2011
Are you sure that vehicle isn't a gamemode vehicle? (The one created in OnGameModeInit )
Try this:
Stand somewhere, Spawn a car, maybe a turismo?
Then Spawn another car, you should see that the old vehicle disappeared.
And:
Take a server vehicle (which you didn't spawn)
Drive little further, then spawn another car, you should see that the old vehicle will return to it's original position.
Re: Removing a vehicle -
iPLEOMAX - 02.08.2011
I can't figure out why it doesn't work.
Use my inc if you want:
pvehicle.inc
Re: Removing a vehicle -
Snowman12 - 02.08.2011
ok your include seems simple enough ill give it a try