SA-MP Forums Archive
Respawn veh after buying it? - 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: Respawn veh after buying it? (/showthread.php?tid=512214)



Respawn veh after buying it? - Pepino960 - 09.05.2014

Hello Guys, yes ist me againD
now after ive got that that all vehicles having about 10000 health, i want that every car ive (or someoneelse..) bought also got bout 10000 health. (coz as you know, if you buy a veh ist not a callback..)
i have tried a few Things like SetVehicleToRespawn(freeid); etc but nothing helped and ive also tryd over a settimer :/

The Script is a part of the Advanced Vehicle System's Filterscript
/EDIT This is when ur about to buy a vehicle and it spawns right to u:

Код:
	GivePlayerMoney(playerid, -VehicleValue[id]);
	new dealerid = strval(VehicleOwner[id]);
	VehicleCreated[freeid] = VEHICLE_PLAYER;
	VehicleModel[freeid] = VehicleModel[id];
	VehiclePos[freeid] = DealershipPos[dealerid];
	VehicleColor[freeid] = VehicleColor[id];
	VehicleInterior[freeid] = VehicleInterior[id];
	VehicleWorld[freeid] = VehicleWorld[id];
	VehicleValue[freeid] = VehicleValue[id];
	GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
	VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
	for(new d=0; d < sizeof(VehicleTrunk[]); d++)
	{
		VehicleTrunk[freeid][d][0] = 0;
		VehicleTrunk[freeid][d][1] = 0;
	}
	for(new d=0; d < sizeof(VehicleMods[]); d++)
	{
		VehicleMods[freeid][d] = 0;
	}
	VehiclePaintjob[freeid] = 255;
	VehicleLock[freeid] = 0;
	VehicleAlarm[freeid] = 0;
	UpdateVehicle(freeid, 0);
	SaveVehicle(freeid);
	new msg[128];
	format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
	SendClientMessage(playerid, COLOR_WHITE, msg);
	RemovePlayerFromVehicle(playerid);



AW: Respawn veh after buying it? - Pepino960 - 09.05.2014

Bump :/


AW: Respawn veh after buying it? - Pepino960 - 09.05.2014

Help Pleaseee


Re: Respawn veh after buying it? - Beckett - 09.05.2014

From what I understood that player must be in a vehicle to buy it, then before you RemovePlayerFromVehicle, set a variable and save the vehicleid in it after you remove the player from the vehicle respawn it.

pawn Код:
new vehicle_id = GetPlayerVehicleID(playerid);
    GivePlayerMoney(playerid, -VehicleValue[id]);
    new dealerid = strval(VehicleOwner[id]);
    VehicleCreated[freeid] = VEHICLE_PLAYER;
    VehicleModel[freeid] = VehicleModel[id];
    VehiclePos[freeid] = DealershipPos[dealerid];
    VehicleColor[freeid] = VehicleColor[id];
    VehicleInterior[freeid] = VehicleInterior[id];
    VehicleWorld[freeid] = VehicleWorld[id];
    VehicleValue[freeid] = VehicleValue[id];
    GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
    VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
    for(new d=0; d < sizeof(VehicleTrunk[]); d++)
    {
        VehicleTrunk[freeid][d][0] = 0;
        VehicleTrunk[freeid][d][1] = 0;
    }
    for(new d=0; d < sizeof(VehicleMods[]); d++)
    {
        VehicleMods[freeid][d] = 0;
    }
    VehiclePaintjob[freeid] = 255;
    VehicleLock[freeid] = 0;
    VehicleAlarm[freeid] = 0;
    UpdateVehicle(freeid, 0);
    SaveVehicle(freeid);
    new msg[128];
    format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
    SendClientMessage(playerid, COLOR_WHITE, msg);
    SetVehicleToRespawn(vehicle_id);
    RemovePlayerFromVehicle(playerid);
This should work.


Re: Respawn veh after buying it? - Pepino960 - 10.05.2014

That is correct, but my ask is how is the veh called that has been created? Im pretty sure its freeid but noghing happens:/


AW: Respawn veh after buying it? - Pepino960 - 10.05.2014

... NothingD

/close