Jump to content
  • 0

Problema DespawnVehicle


Question

Posted

Salut, masinile personale nefolosite nu primesc despawn. 

Cod vechi:

function DespawnVehicle(carid) {
    new dbid = FindSpawnID(carid);
    if(CarInfo[dbid][Spawned] != 0) DestroyPlayerCar(dbid);
    printf("Vehicle %d despawned. [db: %d]", carid, dbid);
    return 1;
}

 

Am modificat cum am gasit intr-un topic dar nu functioneaza:

function DespawnVehicle(carid) {
    new dbid = FindSpawnID(carid);
    if(VehicleHaveDriver(dbid)) {
    VehicleTimer[dbid] = SetTimerEx("DespawnVehicle", 60000*20, 0, "d", dbid);// aici se reseteaza timer-ul pentru a nu ramane masina pe server
    return 1;
    }
    if(CarInfo[dbid][Spawned] != 0) DestroyPlayerCar(dbid);
    printf("Vehicle %d despawned. [db: %d]", carid, dbid);
    return 1;
}

 

2 answers to this question

Recommended Posts

  • 0
Posted (edited)
Acum 13 ore, SherKan a spus:

arata functia DestroyPlayerCar

 

stock DestroyPlayerCar(dbid) {
    if(CarInfo[dbid][Spawned] == 0) return 1;

    VehicleOwned[CarInfo[dbid][Spawned]] = 0;
    VehicleSQL[CarInfo[dbid][Spawned]] = 0;
        
    new Float: Pos[3];
    GetVehiclePos(CarInfo[dbid][Spawned], Pos[0], Pos[1], Pos[2]);
    if(CarInfo[dbid][cNeon] > 0) {
        DestroyDynamicObject(neon[0][CarInfo[dbid][Spawned]]);
        DestroyDynamicObject(neon[1][CarInfo[dbid][Spawned]]);
        neon[0][CarInfo[dbid][Spawned]] = 0;
        neon[1][CarInfo[dbid][Spawned]] = 0;    
    }
    if(strlen(CarInfo[dbid][cText]) >= 3) DestroyDynamicObject(nameobject[CarInfo[dbid][Spawned]]);
    CarInfo[dbid][cFuel] = Gas[CarInfo[dbid][Spawned]];
    new query[256];
    format(query, sizeof(query), "UPDATE `cars` SET `Fuel`='%d' WHERE `ID`='%d'", CarInfo[dbid][cFuel], dbid);
    mysql_query(SQL, query);
    
    CarInfo[dbid][cLastPos][0] = Pos[0];
    CarInfo[dbid][cLastPos][1] = Pos[1];
    CarInfo[dbid][cLastPos][2] = Pos[2];    
        
    DestroyVehicle(CarInfo[dbid][Spawned]);
    CarInfo[dbid][Spawned] = 0;
    new string[180];
    mysql_format(SQL, string, sizeof(string), "UPDATE cars SET Spawned='%d' WHERE ID=%d", CarInfo[dbid][Spawned], dbid);
    mysql_tquery(SQL, string, "", "");
    return 1;
}

Edited by Gabby

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.