Respawn veh after buying it?
#1

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

Bump :/
Reply
#3

Help Pleaseee
Reply
#4

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

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

... NothingD

/close
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)