Jump to content
  • 0

Bug /park


TheGodfather

Question

Salut, cand dau /park, parcheaza masina corect dar daca ma uit in /v imi spune ca este "occupied" chiar daca eu nu mai sunt in ea. Ma scoate cand dau /park.

YCMD:park(playerid, params[], help) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
    new car = GetPlayerVehicleID(playerid);
    if(!IsPlayerInAnyVehicle(playerid)) 
        return SCM(playerid, COLOR_ERROR, "Error: {FFFFFF}You are not in your vehicle.");
    
    if(Iter_Count(MyVehicle[playerid]) == 0) 
        return SCM(playerid, COLOR_ERROR, "Error: {FFFFFF}You do not have a personal vehicle!");
    
    if(PersonalCar(playerid) == -1) 
        return SCM(playerid, COLOR_ERROR, "Error: {FFFFFF}You are not in one of your vehicles!");
    
    if(GetPlayerState(playerid) != 2) 
        return SCM(playerid, COLOR_GREEN, "* You need to drive the car in order to use this command!");
    new idd = PersonalCar(playerid);
    new Float: vhp;
    GetVehicleHealth(car, vhp);
    if(vhp < 800) return SCM(playerid, COLOR_GREY, "You can not park the car because it has less than 800 'health'!");
    if(PlayerToPoint(150, playerid, 564.1226, -1270.0704, 17.2477)) return SCM(playerid, COLOR_ERROR, "INFO: {FFFFFF}You can not park the car near the spawn.");
    new Float:x, Float:y, Float:z, Float:a;
    saveTuning(playerid, CarInfo[idd][Spawned]);
    GetVehiclePos(car, x, y, z);
    GetVehicleZAngle(car, a);
    CarInfo[idd][cLocationx] = x;
    CarInfo[idd][cLocationy] = y;
    CarInfo[idd][cLocationz] = z;
    CarInfo[idd][cTime] = gettime()+600;
    CarInfo[idd][cAngle] = a;
    CarInfo[idd][cVirtual] = GetPlayerVirtualWorld(playerid);

    DestroyVehicle(car);

    if(strlen(CarInfo[idd][cText]) >= 3) {
        DestroyDynamicObject(nameobject[CarInfo[idd][Spawned]]);
    }
    CarInfo[idd][Spawned] = CreateVehicleEx(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],CarInfo[idd][cColorOne],CarInfo[idd][cColorTwo], -1, 0);
    SetVehicleVirtualWorld(CarInfo[idd][Spawned], CarInfo[idd][cVirtual]);
    attach_vip_text(idd);
    SetVehicleHealth(CarInfo[idd][Spawned], CarInfo[idd][cVip] ? 2000 : 1000);
    SetTunning(idd);
    SetVehicleNumberPlate(CarInfo[idd][Spawned], CarInfo[idd][cLicense]);
    saveCar(idd);
    new Float: Pos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    CarInfo[idd][cLastPos][0] = Pos[0];
    CarInfo[idd][cLastPos][1] = Pos[1];
    CarInfo[idd][cLastPos][2] = Pos[2];
    return true;
}

function IsVehicleOccupied(vehicleid) return VehicleOccupied[vehicleid] != 0 ? (true) : (false);

stock ShowPlayerVehicle(playerid, bool: type) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
    new szTitle[2000], szDialog[2000], x = 0;
    if(Iter_Count(MyVehicle[playerid]) == 0) 
        return SCM(playerid, COLOR_LGREEN, "Error: You do not have a personal vehicle!");
    
    format(szTitle, sizeof(szTitle), "Your Vehicles {E3DE31}%d/%d", Iter_Count(MyVehicle[playerid]), GetSlots(playerid));
    strcat(szDialog, "Vehicul\tStatus\tDespawn Time\tOthers details\n");
    foreach(MyVehicle[playerid], car) {
        format(szDialog, sizeof(szDialog), "%s%s\t%s\t%s\t%s\n", szDialog, aVehicleNames[CarInfo[car][cModel]-400], CarInfo[car][Spawned] != 0 ? IsVehicleOccupied(CarInfo[car][Spawned]) ? ("{FFFF00}[occupied]") : ("{26B309}[spawned]") : ("{FF0000}[despawned]"), CheckDespawnCar(car), TotalUp(car)); 
        PlayerInfo[playerid][pCarKey][x] = car;
        x++;
    }
    ShowPlayerDialog(playerid, type ? DIALOG_STICKET : DIALOG_GARAGE, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog, "Ok", "Exit");
    return true;
}

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
YCMD:park(playerid, params[], help) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
    new car = GetPlayerVehicleID(playerid);
    if(!IsPlayerInAnyVehicle(playerid)) 
        return SCM(playerid, COLOR_ERROR, "Error: {FFFFFF}You are not in your vehicle.");
    
    if(Iter_Count(MyVehicle[playerid]) == 0) 
        return SCM(playerid, COLOR_ERROR, "Error: {FFFFFF}You do not have a personal vehicle!");
    
    if(PersonalCar(playerid) == -1) 
        return SCM(playerid, COLOR_ERROR, "Error: {FFFFFF}You are not in one of your vehicles!");
    
    if(GetPlayerState(playerid) != 2) 
        return SCM(playerid, COLOR_GREEN, "* You need to drive the car in order to use this command!");
    new idd = PersonalCar(playerid);
    new Float: vhp;
    GetVehicleHealth(car, vhp);
    if(vhp < 800) return SCM(playerid, COLOR_GREY, "You can not park the car because it has less than 800 'health'!");
    if(PlayerToPoint(150, playerid, 564.1226, -1270.0704, 17.2477)) return SCM(playerid, COLOR_ERROR, "INFO: {FFFFFF}You can not park the car near the spawn.");
    new Float:x, Float:y, Float:z, Float:a;
    saveTuning(playerid, CarInfo[idd][Spawned]);
    GetVehiclePos(car, x, y, z);
    GetVehicleZAngle(car, a);
    CarInfo[idd][cLocationx] = x;
    CarInfo[idd][cLocationy] = y;
    CarInfo[idd][cLocationz] = z;
    CarInfo[idd][cTime] = gettime()+600;
    CarInfo[idd][cAngle] = a;
    CarInfo[idd][cVirtual] = GetPlayerVirtualWorld(playerid);

    DestroyVehicle(car);

    if(strlen(CarInfo[idd][cText]) >= 3) {
        DestroyDynamicObject(nameobject[CarInfo[idd][Spawned]]);
    }
    CarInfo[idd][Spawned] = CreateVehicleEx(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],CarInfo[idd][cColorOne],CarInfo[idd][cColorTwo], -1, 0);
    SetVehicleVirtualWorld(CarInfo[idd][Spawned], CarInfo[idd][cVirtual]);
    attach_vip_text(idd);
    SetVehicleHealth(CarInfo[idd][Spawned], CarInfo[idd][cVip] ? 2000 : 1000);
    SetTunning(idd);
    SetVehicleNumberPlate(CarInfo[idd][Spawned], CarInfo[idd][cLicense]);
    saveCar(idd);
    VehicleOccupied[idd] = 0;
    new Float: Pos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    CarInfo[idd][cLastPos][0] = Pos[0];
    CarInfo[idd][cLastPos][1] = Pos[1];
    CarInfo[idd][cLastPos][2] = Pos[2];
    return true;
}

function IsVehicleOccupied(vehicleid) return VehicleOccupied[vehicleid] != 0 ? (true) : (false);

stock ShowPlayerVehicle(playerid, bool: type) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Wait %d seconds.", aspam[playerid]);
    new szTitle[2000], szDialog[2000], x = 0;
    if(Iter_Count(MyVehicle[playerid]) == 0) 
        return SCM(playerid, COLOR_LGREEN, "Error: You do not have a personal vehicle!");
    
    format(szTitle, sizeof(szTitle), "Your Vehicles {E3DE31}%d/%d", Iter_Count(MyVehicle[playerid]), GetSlots(playerid));
    strcat(szDialog, "Vehicul\tStatus\tDespawn Time\tOthers details\n");
    foreach(MyVehicle[playerid], car) {
        format(szDialog, sizeof(szDialog), "%s%s\t%s\t%s\t%s\n", szDialog, aVehicleNames[CarInfo[car][cModel]-400], CarInfo[car][Spawned] != 0 ? IsVehicleOccupied(CarInfo[car][Spawned]) ? ("{FFFF00}[occupied]") : ("{26B309}[spawned]") : ("{FF0000}[despawned]"), CheckDespawnCar(car), TotalUp(car)); 
        PlayerInfo[playerid][pCarKey][x] = car;
        x++;
    }
    ShowPlayerDialog(playerid, type ? DIALOG_STICKET : DIALOG_GARAGE, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog, "Ok", "Exit");
    return true;
}


// toata problema era ca tie nu-ti seta VehicleOcuppied pe 0.

 

Link to comment
Share on other sites

  • 0

function IsVehicleOccupied(vehicleid) return VehicleOccupied[vehicleid] != 0 ? (true) : (false); - Nu inteleg rostul.

Inlocuieste-o cu : " VehicleOccupied[vehicleid] = 0;

Sa pastrezi un backup sau ceva, dau raspunsu asta dupa foarte mult timp in care nu am mai umblat in pawno :) Totusi merita o incercare.

Link to comment
Share on other sites

  • 0
14 minutes ago, VAurel said:

function IsVehicleOccupied(vehicleid) return VehicleOccupied[vehicleid] != 0 ? (true) : (false); - Nu inteleg rostul.

Inlocuieste-o cu : " VehicleOccupied[vehicleid] = 0;

Sa pastrezi un backup sau ceva, dau raspunsu asta dupa foarte mult timp in care nu am mai umblat in pawno :) Totusi merita o incercare.

Multumesc, voi incerca cand ajung acasa

Link to comment
Share on other sites

  • 0

Inainte de aceasta linie:

DestroyVehicle(car);

Adauga:

VehicleOccupied[car] = 0;

 

Tu trebuie sa pui aceasta valoare pe 0 inainte de a distruge vehiculul, ca urmatorul vehicul ce va capata acest ID sa nu aiba valoarea pe 1 si sa fie 0. Sper ca te-am ajutat.

Link to comment
Share on other sites

  • 0
23 minutes ago, irinel77 said:

Inainte de aceasta linie:

DestroyVehicle(car);

Adauga:

VehicleOccupied[car] = 0;

 

Tu trebuie sa pui aceasta valoare pe 0 inainte de a distruge vehiculul, ca urmatorul vehicul ce va capata acest ID sa nu aiba valoarea pe 1 si sa fie 0. Sper ca te-am ajutat.

Am pus cum ai zis si tot la fel face.

Link to comment
Share on other sites

  • 0
1 hour ago, TheGodfather said:

up

Incearca sa faci cum a zis @irinel77

Dar in loc de : VehicleOccupied[car] = 0;

pune : VehicleOccupied[idd] = 0;

 

Si legat de ce am scris mai sus, nu lua in seama :))) Nu am observat ca acolo era definita functia si nu inteleg cum am zis asa prostie :))

Daca nu reusesti da-mi add pe dis : VAurel#6901

Edited by VAurel
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.