komanda /fixveh

Započeo Risticc, Januar 27, 2024, 20:57:41 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.

[pawn]CMD:fixveh(playerid, params[]) {
    if (PlayerInfo[playerid][xAdmin] >= 1 || PlayerInfo[playerid][xModerator] >= 1 || PlayerInfo[playerid][xHelper] >= 1 || PlayerInfo[playerid][xVIPLevel] >= 1 || PlayerInfo[playerid][xPromoter] >= 1) {
        if (PlayerInfo[playerid][xWanted] >= 1) return SendErrorMessage(playerid, "Ne mozete to dok imate wanted.");

        if (!strlen(params)) {
            // If no parameters provided, fix player's own vehicle
            if (PlayerInfo[playerid][xHelper] >= 1 || PlayerInfo[playerid][xModerator] >= 1 || (PlayerInfo[playerid][xAdmin] >= 1 && PlayerInfo[playerid][xAdmin] <= 6)) {
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (!AdminDuty[playerid]) return SendErrorMessage(playerid, "Morate biti na admin duty.");
            } else if (PlayerInfo[playerid][xVIPLevel] >= 5) {
                // Additional conditions for VIP
                if (NaUtrci[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na trci.");
                if (PlayerCP[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na eventu.");
                if (naDeagle[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (poceoHangar[playerid] > 0 || poceoPrevoz[playerid] > 0 || poceoMisiju[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok radite misiju.");
                if (PlayerInvited[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (PoliceDuty[playerid]) return SendErrorMessage(playerid, "Ne mozete dok ste na duty.");

                if (GetFactionType(playerid) == ORG_TIP_MAFIJA && ServerInfo[PaketPoceo]) {
                    SendErrorMessage(playerid, "Ne mozete ovo jer je pokrenut sistem paketa za mafije (ANTI ABUSE).");
                    return 1;
                }
            } else if (PlayerInfo[playerid][xPromoter] >= 1) {
                // Additional conditions for Promoter
                if (NaUtrci[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na trci.");
                if (PlayerCP[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na eventu.");
                if (naDeagle[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (poceoHangar[playerid] > 0 || poceoPrevoz[playerid] > 0 || poceoMisiju[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok radite misiju.");
                if (PlayerInvited[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (PoliceDuty[playerid]) return SendErrorMessage(playerid, "Ne mozete dok ste na duty.");

                if (GetFactionType(playerid) == ORG_TIP_MAFIJA && ServerInfo[PaketPoceo]) {
                    SendErrorMessage(playerid, "Ne mozete ovo jer je pokrenut sistem paketa za mafije (ANTI ABUSE).");
                    return 1;
                }
            }

            // Code to fix player's own vehicle
            new Float:X, Float:Y, Float:Z, Float:A;
            if (!IsPlayerInAnyVehicle(playerid)) return SendErrorMessage(playerid, "Niste u vozilu!");
            if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Niste na mestu vozaca!");
            GetPlayerPos(playerid, X, Y, Z);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), A);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), A);
            KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(playerid));
            KGEyes_SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
            antiCheatCS[playerid][VehRepairTime] = 15;
            vCanDrive[GetPlayerVehicleID(playerid)] = 1;
            SendInfoMessage(playerid, "Okrenuli ste se sa vozilom i popravili vozilo.");

            return true;
        } else {
           if( PlayerInfo[ playerid ][ xAdmin ] >= 1 || PlayerInfo[ playerid ][ xModerator ] >= 1 ) {
            new targetPlayerID = strval(params);

            new Float:X, Float:Y, Float:Z, Float:A;
            if (!IsPlayerInAnyVehicle(targetPlayerID)) return SendErrorMessage(playerid, "Igrac nije u vozilu!");
            if (GetPlayerState(targetPlayerID) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Igrac nije na mestu vozaca!");
            GetPlayerPos(targetPlayerID, X, Y, Z);
            GetVehicleZAngle(GetPlayerVehicleID(targetPlayerID), A);
            SetVehicleZAngle(GetPlayerVehicleID(targetPlayerID), A);
            KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(targetPlayerID));
            KGEyes_SetVehicleHealth(GetPlayerVehicleID(targetPlayerID), 990.0);
            antiCheatCS[targetPlayerID][VehRepairTime] = 15;
            vCanDrive[GetPlayerVehicleID(targetPlayerID)] = 1;
            SendInfoMessage(targetPlayerID, "Admin %s Vam je popravio vozilo.", ImeIgraca(playerid));
            SendInfoMessage(playerid, "Popravili ste vozilo igracu %s.", ImeIgraca(targetPlayerID));
            return true;
           }
           else return SendErrorMessage(playerid, "Nemate ovlascenje da koristite ovaj deo komande.");
        }

    }

    return true;
}[/pawn]

napravio sam komandu kad se ukuca /fv da fixa tebi, a kad dodas ID nekome fixas, ali kada se ukuca npr /fv i prvo slovo necijeg imena ili celo ime popravi meni vozilo opet, kako to da resim?

Citat: Risticc poslato Januar 27, 2024, 20:57:41 POSLE PODNE
[pawn]CMD:fixveh(playerid, params[]) {
    if (PlayerInfo[playerid][xAdmin] >= 1 || PlayerInfo[playerid][xModerator] >= 1 || PlayerInfo[playerid][xHelper] >= 1 || PlayerInfo[playerid][xVIPLevel] >= 1 || PlayerInfo[playerid][xPromoter] >= 1) {
        if (PlayerInfo[playerid][xWanted] >= 1) return SendErrorMessage(playerid, "Ne mozete to dok imate wanted.");

        if (!strlen(params)) {
            // If no parameters provided, fix player's own vehicle
            if (PlayerInfo[playerid][xHelper] >= 1 || PlayerInfo[playerid][xModerator] >= 1 || (PlayerInfo[playerid][xAdmin] >= 1 && PlayerInfo[playerid][xAdmin] <= 6)) {
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (!AdminDuty[playerid]) return SendErrorMessage(playerid, "Morate biti na admin duty.");
            } else if (PlayerInfo[playerid][xVIPLevel] >= 5) {
                // Additional conditions for VIP
                if (NaUtrci[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na trci.");
                if (PlayerCP[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na eventu.");
                if (naDeagle[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (poceoHangar[playerid] > 0 || poceoPrevoz[playerid] > 0 || poceoMisiju[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok radite misiju.");
                if (PlayerInvited[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (PoliceDuty[playerid]) return SendErrorMessage(playerid, "Ne mozete dok ste na duty.");

                if (GetFactionType(playerid) == ORG_TIP_MAFIJA && ServerInfo[PaketPoceo]) {
                    SendErrorMessage(playerid, "Ne mozete ovo jer je pokrenut sistem paketa za mafije (ANTI ABUSE).");
                    return 1;
                }
            } else if (PlayerInfo[playerid][xPromoter] >= 1) {
                // Additional conditions for Promoter
                if (NaUtrci[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na trci.");
                if (PlayerCP[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na eventu.");
                if (naDeagle[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (poceoHangar[playerid] > 0 || poceoPrevoz[playerid] > 0 || poceoMisiju[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok radite misiju.");
                if (PlayerInvited[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (PoliceDuty[playerid]) return SendErrorMessage(playerid, "Ne mozete dok ste na duty.");

                if (GetFactionType(playerid) == ORG_TIP_MAFIJA && ServerInfo[PaketPoceo]) {
                    SendErrorMessage(playerid, "Ne mozete ovo jer je pokrenut sistem paketa za mafije (ANTI ABUSE).");
                    return 1;
                }
            }

            // Code to fix player's own vehicle
            new Float:X, Float:Y, Float:Z, Float:A;
            if (!IsPlayerInAnyVehicle(playerid)) return SendErrorMessage(playerid, "Niste u vozilu!");
            if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Niste na mestu vozaca!");
            GetPlayerPos(playerid, X, Y, Z);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), A);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), A);
            KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(playerid));
            KGEyes_SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
            antiCheatCS[playerid][VehRepairTime] = 15;
            vCanDrive[GetPlayerVehicleID(playerid)] = 1;
            SendInfoMessage(playerid, "Okrenuli ste se sa vozilom i popravili vozilo.");

            return true;
        } else {
           if( PlayerInfo[ playerid ][ xAdmin ] >= 1 || PlayerInfo[ playerid ][ xModerator ] >= 1 ) {
            new targetPlayerID = strval(params);

            new Float:X, Float:Y, Float:Z, Float:A;
            if (!IsPlayerInAnyVehicle(targetPlayerID)) return SendErrorMessage(playerid, "Igrac nije u vozilu!");
            if (GetPlayerState(targetPlayerID) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Igrac nije na mestu vozaca!");
            GetPlayerPos(targetPlayerID, X, Y, Z);
            GetVehicleZAngle(GetPlayerVehicleID(targetPlayerID), A);
            SetVehicleZAngle(GetPlayerVehicleID(targetPlayerID), A);
            KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(targetPlayerID));
            KGEyes_SetVehicleHealth(GetPlayerVehicleID(targetPlayerID), 990.0);
            antiCheatCS[targetPlayerID][VehRepairTime] = 15;
            vCanDrive[GetPlayerVehicleID(targetPlayerID)] = 1;
            SendInfoMessage(targetPlayerID, "Admin %s Vam je popravio vozilo.", ImeIgraca(playerid));
            SendInfoMessage(playerid, "Popravili ste vozilo igracu %s.", ImeIgraca(targetPlayerID));
            return true;
           }
           else return SendErrorMessage(playerid, "Nemate ovlascenje da koristite ovaj deo komande.");
        }

    }

    return true;
}[/pawn]

napravio sam komandu kad se ukuca /fv da fixa tebi, a kad dodas ID nekome fixas, ali kada se ukuca npr /fv i prvo slovo necijeg imena ili celo ime popravi meni vozilo opet, kako to da resim?
Zasto komande koje su moguce napraviti u 40 linija napravite u 80+? A pritom 80% linija samo copypaste.

Citat: Risticc poslato Januar 27, 2024, 20:57:41 POSLE PODNE
[pawn]CMD:fixveh(playerid, params[]) {
    if (PlayerInfo[playerid][xAdmin] >= 1 || PlayerInfo[playerid][xModerator] >= 1 || PlayerInfo[playerid][xHelper] >= 1 || PlayerInfo[playerid][xVIPLevel] >= 1 || PlayerInfo[playerid][xPromoter] >= 1) {
        if (PlayerInfo[playerid][xWanted] >= 1) return SendErrorMessage(playerid, "Ne mozete to dok imate wanted.");

        if (!strlen(params)) {
            // If no parameters provided, fix player's own vehicle
            if (PlayerInfo[playerid][xHelper] >= 1 || PlayerInfo[playerid][xModerator] >= 1 || (PlayerInfo[playerid][xAdmin] >= 1 && PlayerInfo[playerid][xAdmin] <= 6)) {
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (!AdminDuty[playerid]) return SendErrorMessage(playerid, "Morate biti na admin duty.");
            } else if (PlayerInfo[playerid][xVIPLevel] >= 5) {
                // Additional conditions for VIP
                if (NaUtrci[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na trci.");
                if (PlayerCP[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na eventu.");
                if (naDeagle[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (poceoHangar[playerid] > 0 || poceoPrevoz[playerid] > 0 || poceoMisiju[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok radite misiju.");
                if (PlayerInvited[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (PoliceDuty[playerid]) return SendErrorMessage(playerid, "Ne mozete dok ste na duty.");

                if (GetFactionType(playerid) == ORG_TIP_MAFIJA && ServerInfo[PaketPoceo]) {
                    SendErrorMessage(playerid, "Ne mozete ovo jer je pokrenut sistem paketa za mafije (ANTI ABUSE).");
                    return 1;
                }
            } else if (PlayerInfo[playerid][xPromoter] >= 1) {
                // Additional conditions for Promoter
                if (NaUtrci[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na trci.");
                if (PlayerCP[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok ste na eventu.");
                if (naDeagle[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (poceoHangar[playerid] > 0 || poceoPrevoz[playerid] > 0 || poceoMisiju[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok radite misiju.");
                if (PlayerInvited[playerid] > 0) return SendErrorMessage(playerid, "Ne mozete dok ste na eventu.");
                if (UzeoOpremu[playerid]) return SendErrorMessage(playerid, "Ne mozete koristiti ovu komandu dok radite posao ili imate uniformu posla.");
                if (prevoziMigrante[playerid] != 0) return SendErrorMessage(playerid, "Ne mozete dok prevozite migrante!");
                if (PoliceDuty[playerid]) return SendErrorMessage(playerid, "Ne mozete dok ste na duty.");

                if (GetFactionType(playerid) == ORG_TIP_MAFIJA && ServerInfo[PaketPoceo]) {
                    SendErrorMessage(playerid, "Ne mozete ovo jer je pokrenut sistem paketa za mafije (ANTI ABUSE).");
                    return 1;
                }
            }

            // Code to fix player's own vehicle
            new Float:X, Float:Y, Float:Z, Float:A;
            if (!IsPlayerInAnyVehicle(playerid)) return SendErrorMessage(playerid, "Niste u vozilu!");
            if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Niste na mestu vozaca!");
            GetPlayerPos(playerid, X, Y, Z);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), A);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), A);
            KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(playerid));
            KGEyes_SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
            antiCheatCS[playerid][VehRepairTime] = 15;
            vCanDrive[GetPlayerVehicleID(playerid)] = 1;
            SendInfoMessage(playerid, "Okrenuli ste se sa vozilom i popravili vozilo.");

            return true;
        } else {
           if( PlayerInfo[ playerid ][ xAdmin ] >= 1 || PlayerInfo[ playerid ][ xModerator ] >= 1 ) {
            new targetPlayerID = strval(params);

            new Float:X, Float:Y, Float:Z, Float:A;
            if (!IsPlayerInAnyVehicle(targetPlayerID)) return SendErrorMessage(playerid, "Igrac nije u vozilu!");
            if (GetPlayerState(targetPlayerID) != PLAYER_STATE_DRIVER) return SendErrorMessage(playerid, "Igrac nije na mestu vozaca!");
            GetPlayerPos(targetPlayerID, X, Y, Z);
            GetVehicleZAngle(GetPlayerVehicleID(targetPlayerID), A);
            SetVehicleZAngle(GetPlayerVehicleID(targetPlayerID), A);
            KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(targetPlayerID));
            KGEyes_SetVehicleHealth(GetPlayerVehicleID(targetPlayerID), 990.0);
            antiCheatCS[targetPlayerID][VehRepairTime] = 15;
            vCanDrive[GetPlayerVehicleID(targetPlayerID)] = 1;
            SendInfoMessage(targetPlayerID, "Admin %s Vam je popravio vozilo.", ImeIgraca(playerid));
            SendInfoMessage(playerid, "Popravili ste vozilo igracu %s.", ImeIgraca(targetPlayerID));
            return true;
           }
           else return SendErrorMessage(playerid, "Nemate ovlascenje da koristite ovaj deo komande.");
        }

    }

    return true;
}[/pawn]

napravio sam komandu kad se ukuca /fv da fixa tebi, a kad dodas ID nekome fixas, ali kada se ukuca npr /fv i prvo slovo necijeg imena ili celo ime popravi meni vozilo opet, kako to da resim?
Isuse dragi kakve ovde gluposti imaju nabacane
Evo ti komanda sa mog moda
[pawn]
CMD:fixveh(playerid, params[]) {
  if(!PlayerInfo[playerid][xAdmin]) return SendErrorMessage(playerid, "Niste ovlasceni!");
  if(!AdminDuty[playerid]) return SendErrorMessage(playerid, "Morate biti na admin duty.");
  new vehicleid = GetPlayerVehicleID(playerid);
  if(!IsPlayerInAnyVehicle(playerid)) return SendErrorMessage(playerid, "Niste u vozilu!");
  RepairVehicle(vehicleid);
  SetVehicleHealth(vehicleid, 999.0);
  return 1;
}
[/pawn]
Samo da napomenem da komanda nije dovršena treba se dodati još par provjera

Pa onda mi pokazi kako treba, ako je nabacano?

[pawn] KGEyes_RepairVehicle(playerid, GetPlayerVehicleID(playerid));
KGEyes_SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
antiCheatCS[playerid][VehRepairTime] = 15;
vCanDrive[GetPlayerVehicleID(playerid)] = 1;[/pawn]

CMD:fixveh(playerid, params[]) {
   



    return true;
}
Upwork Skills
Back-end:
• PHP Frameworks (Laravel, Symfony,Codeigniter)
• Python/Django
• Node.js

Front-end:
• HTML
• CSS pre-processing (SASS, LESS)
• Javascript (JQuery, Ajax, Vue, Angular, React, etc.)
• Bootstrap

CMS
• Wordpress (Woocommerce)
• Shopify, Magento

Evo ti ovako primer pa se sam zajebavaj sa tim uslovima.
U sustini u je skraceno za user, malim slovom znaci da je obavezno. Prihvata ili id ili ime/deo imena, a uvek vraca ID igraca (INVALID_PLAYER_ID ako nije validan id/ime).
Posto sscanf ocekuje makar jedan argument, a ti ne prosledis nista, SSCANF failuje i vraca 1, sto ce u ovom slucaju pozvati targetid = playerid i ti automatski cuvas svoj id kao kao targetid.

Uglavnom nakon provere da li je igrac postojeci radis sve ostalo, i tu vec znas da je ID igraca validan (ja bih poceo od toga da uzmem vehicleid od igraca i da validujem to...)
[pawn]
CMD:fixveh(adminid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid))
        targetid = adminid;

    if(!IsPlayerConnected(targetid)) return SendError(adminid, "Player ID/Name does not exists.");

    //ostala sranja...

    //Komanda je uspjesna, nema unknown command poruke
    return 1;
}
[/pawn]

PS: Za sve ostale, kad neko pita konkretno pitanje, da informacije koje su potrebne onda ce uvek dobiti i normalan odgovor. A vi nastavite da trazite sve umesto vas da se odradi pa cekajte svetog petra da vam pomogne
Poslednja Izmena: Januar 28, 2024, 14:15:24 POSLE PODNE od Bit Frosty