/respawnallvehicles - Trying to ensure the vehicle is created in the exact same ID
#1

pawn Код:
CMD:respawnallvehicles(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    new string[128], vehid;
    for(new v = 1; v  < GetVehiclePoolSize()+1; v++)
    {
        if(GetVehicleModel(v) != 510 && !IsATrailer(v) && !IsVehicleInUse(v))
            {
            vehid = v;
                        DestroyVehicle(v);
                        CreateVehicle(VehModel[vehid], VehSpawnX[vehid], VehSpawnY[vehid], VehSpawnZ[vehid],             VehSpawnAngle[vehid], VehColour1[vehid], VehColour2[vehid], 0, VehSiren[vehid]);
            SetVehicleNumberPlate(vehid, VehPlate[vehid]);
            new vehicleid = vehid;
            if(VehOwner[vehicleid] > 0 || VehicleFaction[vehicleid] > 0)
            {
                SetVehicleParamsEx(vehicleid, 0, 0, 0, 1, 0, 0, 0);
                SetVehicleParamsCarDoors(vehicleid, 0,0,0,0);
                SetVehicleParamsCarWindows(vehicleid, 1,1, 1, 1);
            }
            if(VehJob[vehicleid] > 0 || VehDealership[vehicleid] > 0 || RentVeh[vehicleid] == 1)
            {
                SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
                SetVehicleParamsCarDoors(vehicleid, 0,0,0,0);
                SetVehicleParamsCarWindows(vehicleid, 1,1, 1, 1);
            }
        }
    }
    format(string, sizeof(string), ""COL_GREEN"All Vehicles Respawned.");
    SendClientMessage(playerid, COLOUR_WHITE, string);
    SendClientMessageToAll(COLOUR_WHITE, "All vehicles have been respawned.");
    return 1;
}
I think this may be slightly bugged due to ID's being messed up and this command below duplicates vehicles.
pawn Код:
CMD:frespawnall(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    new string[128], id;
    if(FRank[playerid] < 5 && AdminLevel[playerid] < 1)return SendClientMessage(playerid, COLOUR_GREY, "You must be at least rank 5 to use this.");
    for(new v = 1; v < GetVehiclePoolSize()+1; v++)
    {
        if(VehicleFaction[v] == Faction[playerid])
        {
            id = v;
            DestroyVehicle(v);
            CreateVehicle(VehModel[id], VehSpawnX[id], VehSpawnY[id], VehSpawnZ[id], VehSpawnAngle[id], VehColour1[id], VehColour2[id], 0, VehSiren[id]);
            format(string, sizeof(string), "Vehicle: "COL_WHITE"%d Respawned.", id);
            SetVehicleNumberPlate(id, VehPlate[id]);
            new vehicleid = id;
            if(VehOwner[vehicleid] > 0 || VehicleFaction[vehicleid] > 0)
            {
                SetVehicleParamsEx(vehicleid, 0, 0, 0, 1, 0, 0, 0);
                SetVehicleParamsCarDoors(vehicleid, 0,0,0,0);
                SetVehicleParamsCarWindows(vehicleid, 1,1, 1, 1);
            }
            if(VehJob[vehicleid] > 0 || VehDealership[vehicleid] > 0 || RentVeh[vehicleid] == 1)
            {
                SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
                SetVehicleParamsCarDoors(vehicleid, 0,0,0,0);
                SetVehicleParamsCarWindows(vehicleid, 1,1, 1, 1);
            }
        }
    }
    format(string, sizeof(string), "ALL FACTION VEHICLES RESPAWNED.");
    SendClientMessage(playerid, COLOUR_ORANGE, string);
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)