SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/03/2013, 05:30 PM   #1
edzis84
Big Clucker
 
edzis84's Avatar
 
Join Date: Jan 2013
Location: Latvia
Posts: 152
Reputation: 26
Default Vehicle despawn

Hello, today i started to make vehicle ownership.

I made that when you buy your car it automaticly spawns next to dealership, then you can type buypark and it changes parking place, it all works good but when i despawn it i cant get it anymore.

I use this for despawning

Code:
new currentveh;
          currentveh = GetPlayerVehicleID(playerid);
          DestroyVehicle(currentveh);
Maybe its wrong?
edzis84 is offline   Reply With Quote
Old 07/03/2013, 06:23 PM   #2
zxc1
Huge Clucker
 
zxc1's Avatar
 
Join Date: Apr 2010
Posts: 225
Reputation: 15
Default Re: Vehicle despawn

Despawn?
zxc1 is offline   Reply With Quote
Old 07/03/2013, 06:35 PM   #3
edzis84
Big Clucker
 
edzis84's Avatar
 
Join Date: Jan 2013
Location: Latvia
Posts: 152
Reputation: 26
Default AW: Vehicle despawn

Can you link me code?
edzis84 is offline   Reply With Quote
Old 07/03/2013, 06:45 PM   #4
zxc1
Huge Clucker
 
zxc1's Avatar
 
Join Date: Apr 2010
Posts: 225
Reputation: 15
Default Re: Vehicle despawn

I didn't get you, explain further details please.
zxc1 is offline   Reply With Quote
Old 07/03/2013, 07:18 PM   #5
edzis84
Big Clucker
 
edzis84's Avatar
 
Join Date: Jan 2013
Location: Latvia
Posts: 152
Reputation: 26
Default AW: Vehicle despawn

Okay.

When i type command /buypark It saves coordinates X,Y,Z

And when i type command /getcar It creates vehicle to saved X,Y,Z

But i want to despawn it driving to my point where i bought BUYPARK and i type /park

my /park commands code is this

Code:
new currentveh;
          currentveh = GetPlayerVehicleID(playerid);
          DestroyVehicle(currentveh);
But when i park it, it doesnt spawns back using command /getcar.

Maybe i dont have to Destroy it but despawn in other way?
edzis84 is offline   Reply With Quote
Old 08/03/2013, 07:32 AM   #6
edzis84
Big Clucker
 
edzis84's Avatar
 
Join Date: Jan 2013
Location: Latvia
Posts: 152
Reputation: 26
Default AW: Vehicle despawn

anyone?
edzis84 is offline   Reply With Quote
Old 08/03/2013, 07:47 AM   #7
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,122
Reputation: 529
Default Re: Vehicle despawn

I think you may be looking to respawn the vehicle??

If that is the case, try http://wiki.sa-mp.com/wiki/SetVehicleToRespawn .
Then under OnVehicleSpawn, check if it is a car spawned by a player, then set it to the X, Y and Z coordinates.
__________________


Kar's Cops and Robbers 2020
Threshold is offline   Reply With Quote
Old 08/03/2013, 07:48 AM   #8
L.Hudson
Huge Clucker
 
L.Hudson's Avatar
 
Join Date: Jul 2012
Location: Fairy Tail, Fiore
Posts: 226
Reputation: 16
Default Re: Vehicle despawn

it's simple when u do that /buypark cmd the vehicle completely gets destroyed and in order to get it back u need a server restart if it's imported in the script! The solution is a way that everyone uses

change from

pawn Code:
new currentveh;
          currentveh = GetPlayerVehicleID(playerid);
          DestroyVehicle(currentveh);

to
pawn Code:
new currentveh = GetPlayerVehicleID(playerid), Float:x, Float:y, Float:z, Float:Za;
          GetVehiclePos(currentveh, x, y,z);
          GetVehicleZAngle(currentveh, Za);
          DestroyVehicle(currentveh);
          CreateVehicle(411, x, y, z, Za, 0, 0, -1) // The model 411 is just an example change it with your ways to the model that got destroyed
L.Hudson is offline   Reply With Quote
Old 08/03/2013, 08:08 AM   #9
edzis84
Big Clucker
 
edzis84's Avatar
 
Join Date: Jan 2013
Location: Latvia
Posts: 152
Reputation: 26
Default AW: Vehicle despawn

Nope guys, thats not what im looking for. Maybe im explaining it very incomprehensible.

You all know rp servers where you can park car its not like you set it to spawn place but car just disappears.

And when its parked (disappeared) you can spawn another of your cars (because spawned car limit is 1)

Basicly i have 3 commands

/getcar - this spawns your car.

Code:
CreateVehicle(PlayerInfo[playerid][pCar],CarInfo[vehid][cLocationx],CarInfo[vehid][cLocationy],CarInfo[vehid][cLocationz],1,1,1,0);
SCM(playerid,-1,"Folow the red marker to find your car");
SetPlayerCheckpoint(playerid, CarInfo[vehid][cLocationx], CarInfo[vehid][cLocationy],CarInfo[vehid][cLocationz], 3.0);
/buypark

Code:
CMD:buypark(playerid,params[])
{
new Float:x;
new Float:y;
new Float:z;

new vehid;
vehid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehid, x, y, z);
CarInfo[vehid][cLocationx] = x;
CarInfo[vehid][cLocationy] = y;
CarInfo[vehid][cLocationz] = z;
SCM(playerid,red,"Your parking place changed");
}
/cpark


Code:
CMD:cpark(playerid,params[])
{
new currentveh;
currentveh = GetPlayerVehicleID(playerid);
CarInfo[playerid][cSpawned] = 0;
DestroyVehicle(currentveh);
return 1;
}

I havent set spawning limit yet so i can do /buypark and then /getcar wihout destroying my current car, wihout destroying it spawns where i did /buypark but when i destroy it, when i do /getcar it spawns somewhere in blueberry i have no ideas why.

And when car is destroyed(like i smash it into tree and it explodes) i want that it disappears too and i have to do /getcar to spawn it back.
edzis84 is offline   Reply With Quote
Old 08/03/2013, 09:04 AM   #10
edzis84
Big Clucker
 
edzis84's Avatar
 
Join Date: Jan 2013
Location: Latvia
Posts: 152
Reputation: 26
Default AW: Vehicle despawn

Problem solved, thanks enyone who tried to help!

Last edited by edzis84; 08/03/2013 at 02:41 PM.
edzis84 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerDisconnect vehicle despawn dthompson Scripting Help 3 30/01/2013 12:48 PM
Car won't despawn Makaveli93 Scripting Help 11 26/06/2012 09:51 PM
Despawn all unused vehicles Garc1a Scripting Help 2 06/06/2012 03:45 PM
Help me Car wont despawn with command AMEENAMEEN Scripting Help 2 21/05/2012 07:23 PM


All times are GMT. The time now is 05:05 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.