SA-MP Forums Archive
Vehicle selling - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle selling (/showthread.php?tid=520910)



Vehicle selling - Bek_Loking - 20.06.2014

Hello everyone! I coded a script to sell rare found vehicle - tampa which will be found around the map. Now my problem is, the vehicle doesn't destroy. I made the respawn time to be 5,000s but yet, it won't destroy. The code is:


Код:
CMD:selltampa(playerid, params[])
{   
	new vehmodel = GetVehicleModel(GetPlayerVehicleID(playerid));
	if (vehmodel == 549)
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You found tampa! Congratulations! You earn 2000$!");
	DestroyVehicle(vehmodel);
	GivePlayerMoney(playerid, 2000);
	}
	else if(!vehmodel) return SendClientMessage(playerid, COLOR_RED, "You're not in tampa!");
    return 1;
}
If someone knows, I'll be more than glad to rep-up in a hour. That's when I can rep up.


Re: Vehicle selling - Konstantinos - 20.06.2014

You need the vehicleid not the modelid in order to destroy a vehicle.

pawn Код:
CMD:selltampa(playerid, params[])
{
    if (GetVehicleModel(GetPlayerVehicleID(playerid)) != 549)  return SendClientMessage(playerid, COLOR_RED, "You're not in tampa!");
    DestroyVehicle(GetPlayerVehicleID(playerid));
    GivePlayerMoney(playerid, 2000);
    SendClientMessage(playerid, COLOR_YELLOW, "You found tampa! Congratulations! You earn 2000$!");
    return 1;
}



Re : Vehicle selling - Clad - 20.06.2014

try this.
Quote:

new carid = GetPlayerVehicleID(playerid);
DestroyVehicle(carid);