Jump to content

Recommended Posts

Posted

salut vreau sa fac comanda licenses, si vreau sa stiu daca e posibil sa fie mai usor decat codul pe care il scriu, adica sa apara daca are licenta am facut asa, (pentru toate licentele)

 

stock showLicenses(playerid)
{
    gString[0] = EOS;
    format(gString, sizeof(gString), "Licente lui %s", GetName(playerid));
    ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, gString, "** {8ba1f0}Carnet de sofer: {fcfcfc}Expirat  {8ba1f0}\n** Licenta de pilot: {fcfcfc}Expirata {8ba1f0}\n** Licenta de navigatie: {fcfcfc}Expirata {8ba1f0}\n** Licenta de pescar: {fcfcfc}Expirata {8ba1f0}\n** Licenta de port-arma: {fcfcfc}Expirata {8ba1f0}\n** Licenta de materiale: {fcfcfc}Expirata {8ba1f0}", "OK", "");

    if(PlayerInfo[playerid][pDrivingLicense] == 1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n** Licenta de pilot: {fcfcfc}Expirata {8ba1f0}\n** Licenta de navigatie: {fcfcfc}Expirata {8ba1f0}\n** Licenta de pescar: {fcfcfc}Expirata {8ba1f0}\n** Licenta de port-arma: {fcfcfc}Expirata {8ba1f0}\n** Licenta de materiale: {fcfcfc}Expirata {8ba1f0}", PlayerInfo[playerid][pDrivingLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");
        return 1;
    }
    if(PlayerInfo[playerid][pFlyingLicense] == 1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Expirat  {8ba1f0}\n** Licenta de pilot: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de navigatie: {fcfcfc}Expirata {8ba1f0}\n** Licenta de pescar: {fcfcfc}Expirata {8ba1f0}\n** Licenta de port-arma: {fcfcfc}Expirata {8ba1f0}\n** Licenta de materiale: {fcfcfc}Expirata {8ba1f0}", PlayerInfo[playerid][pFlyingLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");
        return 1;
    }
    if(PlayerInfo[playerid][pSailingLicense] == 1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Expirat  {8ba1f0}\n** Licenta de pilot: {fcfcfc}Expirat {8ba1f0}\n** Licenta de navigatie: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de pescar: {fcfcfc}Expirata {8ba1f0}\n** Licenta de port-arma: {fcfcfc}Expirata {8ba1f0}\n** Licenta de materiale: {fcfcfc}Expirata {8ba1f0}", PlayerInfo[playerid][pSailingLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");
        return 1;
    }
    if(PlayerInfo[playerid][pFishingLicense] == 1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Expirat  {8ba1f0}\n** Licenta de pilot: {fcfcfc}Expirat {8ba1f0}\n** Licenta de navigatie: {fcfcfc}Expirata {8ba1f0}\n** Licenta de pescar: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de port-arma: {fcfcfc}Expirata {8ba1f0}\n** Licenta de materiale: {fcfcfc}Expirata {8ba1f0}", PlayerInfo[playerid][pFishingLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");
        return 1;
    }
    if(PlayerInfo[playerid][pGunLicense] == 1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Expirat  {8ba1f0}\n** Licenta de pilot: {fcfcfc}Expirat {8ba1f0}\n** Licenta de navigatie: {fcfcfc}Expirata {8ba1f0}\n** Licenta de pescar: {fcfcfc}Expirata {8ba1f0}\n** Licenta de port-arma: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de materiale: {fcfcfc}Expirata {8ba1f0}", PlayerInfo[playerid][pGunLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");
        return 1;
    }
    if(PlayerInfo[playerid][pMaterialsLicense] == 1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Expirat  {8ba1f0}\n** Licenta de pilot: {fcfcfc}Expirat {8ba1f0}\n** Licenta de navigatie: {fcfcfc}Expirata {8ba1f0}\n** Licenta de pescar: {fcfcfc}Expirata {8ba1f0}\n** Licenta de port-arma: {fcfcfc}Expirata {8ba1f0}\n** Licenta de materiale: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore", PlayerInfo[playerid][pMaterialsLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");    
        return 1;
    }
    if(PlayerInfo[playerid][pMaterialsLicense] == 1 || PlayerInfo[playerid][pMaterialsLicense] == 1 || PlayerInfo[playerid][pGunLicense] == 1 || PlayerInfo[playerid][pFishingLicense] == 1 || PlayerInfo[playerid][pSailingLicense] == 1 || PlayerInfo[playerid][pFlyingLicense] == 1 || PlayerInfo[playerid][pDrivingLicense] ==1) {
        gString[0] = EOS;
        format(gString, sizeof(gString), "** {8ba1f0}Carnet de sofer: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n** Licenta de pilot: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de navigatie: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de pescar: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de port-arma: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore\n** Licenta de materiale: {fcfcfc}Valida {8ba1f0}- Valabilitate: %d ore", PlayerInfo[playerid][pMaterialsLicenseTime], PlayerInfo[playerid][pMaterialsLicenseTime] || PlayerInfo[playerid][pMaterialsLicenseTime] || PlayerInfo[playerid][pGunLicenseTime] || PlayerInfo[playerid][pFishingLicenseTime] || PlayerInfo[playerid][pSailingLicenseTime] || PlayerInfo[playerid][pFlyingLicenseTime] || PlayerInfo[playerid][pDrivingLicenseTime]);
        new string[126];
        format(string, sizeof(string), "Licente lui %s", GetName(playerid));
        ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, string, gString, "OK", "");    
        return 1;
    }
    return 1;
}

Posted (edited)

showLicenses(playerid)
{
    enum e_licenses {
        licenseName[64], 
        e_pInfo:licenseIdx,
        e_pInfo:licenseTime
    }

    static const licensesStructure[][e_licenses] = {
        {"Carnet de sofer", pDrivingLicense, pDrivingLicenseTime}, 
        {"Licenta de pilot", pFlyingLicense, pFlyingLicenseTime}, 
        {"Licenta de navigatie", pSailingLicense, pSailingLicenseTime}, 
        {"Licena de pescar", pFishingLicense, pFishingLicenseTime}, 
        {"Licenta de port-arma", pGunLicense, pGunLicenseTime}, 
        {"Licenta de materiale", pMaterialsLicense, pMaterialsLicenseTime}
    };
    
    gString[0] = EOS;
    
    for(new i = 0; i < sizeof licensesStructure; ++i) {
        if(PlayerInfo[playerid][licensesStructure[i][licenseIdx]] == 1)
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n", gString, licensesStructure[i][licenseName], PlayerInfo[playerid][licensesStructure[i][licenseTime]]);
    
        else 
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Expirat\n", gString, licensesStructure[i][licenseName]);
    }
    
    new headerText[64];
    format(headerText, sizeof headerText, "Licentele lui %s", GetName(playerid));
    ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, headerText, gString, "Ok", "");
    return 1;
}

 

Ai aici codul imbunatatit, am folosit un array in care stochez datele precum numele licentelor, index-urile pt licente, pt a le putea accesa usor in loop.

 

(!) In loc de tagul e_pInfo: din enum, pui cum ai tu enum-ul folosit pentru PlayerInfo

 

Un tip: ti-as recomanda doar o variabila in care stochezi timpul licentelor, cand este suspendata, ii poti stoca o valoare negativa cu timpul suspendarii, cand este expirata ii poti seta valoarea 0 iar cand este valabila ii poti seta valoarea pozitiva cu timpul valabilitatii, si poti verifica direct variabila cu timpul, nu mai e nevoie de una boolean pt a vedea asta.

Daca ai gasit ceva neregulă, da mi un tag, am rescris tot codul pe telefon, probabil sa fi omis ceva.

Edited by Sancky
  • Like 1
Posted
4 hours ago, Sancky said:

showLicenses(playerid)
{
    enum e_licenses {
        licenseName[64], 
        e_pInfo:licenseIdx,
        e_pInfo:licenseTime
    }

    static const licensesStructure[][e_licenses] = {
        {"Carnet de sofer", pDrivingLicense, pDrivingLicenseTime}, 
        {"Licenta de pilot", pFlyingLicense, pFlyingLicenseTime}, 
        {"Licenta de navigatie", pSailingLicense, pSailingLicenseTime}, 
        {"Licena de pescar", pFishingLicense, pFishingLicenseTime}, 
        {"Licenta de port-arma", pGunLicense, pGunLicenseTime}, 
        {"Licenta de materiale", pMaterialsLicense, pMaterialsLicenseTime}
    };
    
    gString[0] = EOS;
    
    for(new i = 0; i < sizeof licensesStructure; ++i) {
        if(PlayerInfo[playerid][licensesStructure[i][licenseIdx]] == 1)
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n", gString, licensesStructure[i][licenseName], PlayerInfo[playerid][licensesStructure[i][licenseTime]]);
    
        else 
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Expirat\n", gString, licensesStructure[i][licenseName]);
    }
    
    new headerText[64];
    format(headerText, sizeof headerText, "Licentele lui %s", GetName(playerid));
    ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, headerText, gString, "Ok", "");
    return 1;
}

 

Ai aici codul imbunatatit, am folosit un array in care stochez datele precum numele licentelor, index-urile pt licente, pt a le putea accesa usor in loop.

 

(!) In loc de tagul e_pInfo: din enum, pui cum ai tu enum-ul folosit pentru PlayerInfo

 

Un tip: ti-as recomanda doar o variabila in care stochezi timpul licentelor, cand este suspendata, ii poti stoca o valoare negativa cu timpul suspendarii, cand este expirata ii poti seta valoarea 0 iar cand este valabila ii poti seta valoarea pozitiva cu timpul valabilitatii, si poti verifica direct variabila cu timpul, nu mai e nevoie de una boolean pt a vedea asta.

Daca ai gasit ceva neregulă, da mi un tag, am rescris tot codul pe telefon, probabil sa fi omis ceva.

imi da warning urile astea.

../gamemodes/stock.pwn(165) : warning 213: tag mismatch
../gamemodes/stock.pwn(165) : warning 213: tag mismatch
../gamemodes/stock.pwn(166) : warning 213: tag mismatch
../gamemodes/stock.pwn(166) : warning 213: tag mismatch
../gamemodes/stock.pwn(167) : warning 213: tag mismatch
../gamemodes/stock.pwn(167) : warning 213: tag mismatch
../gamemodes/stock.pwn(168) : warning 213: tag mismatch
../gamemodes/stock.pwn(168) : warning 213: tag mismatch
../gamemodes/stock.pwn(169) : warning 213: tag mismatch
../gamemodes/stock.pwn(169) : warning 213: tag mismatch
../gamemodes/stock.pwn(170) : warning 213: tag mismatch
../gamemodes/stock.pwn(170) : warning 213: tag mismatch
../gamemodes/stock.pwn(176) : warning 213: tag mismatch
../gamemodes/stock.pwn(177) : warning 213: tag mismatch

Posted
1 hour ago, Valentin Tarnauceanu said:

imi da warning urile astea.

../gamemodes/stock.pwn(165) : warning 213: tag mismatch
../gamemodes/stock.pwn(165) : warning 213: tag mismatch
../gamemodes/stock.pwn(166) : warning 213: tag mismatch
../gamemodes/stock.pwn(166) : warning 213: tag mismatch
../gamemodes/stock.pwn(167) : warning 213: tag mismatch
../gamemodes/stock.pwn(167) : warning 213: tag mismatch
../gamemodes/stock.pwn(168) : warning 213: tag mismatch
../gamemodes/stock.pwn(168) : warning 213: tag mismatch
../gamemodes/stock.pwn(169) : warning 213: tag mismatch
../gamemodes/stock.pwn(169) : warning 213: tag mismatch
../gamemodes/stock.pwn(170) : warning 213: tag mismatch
../gamemodes/stock.pwn(170) : warning 213: tag mismatch
../gamemodes/stock.pwn(176) : warning 213: tag mismatch
../gamemodes/stock.pwn(177) : warning 213: tag mismatch

noteaza si tu care sunt liniile din functia aia, ca n am cum sa mi dau seama

Posted
11 hours ago, Sancky said:

noteaza si tu care sunt liniile din functia aia, ca n am cum sa mi dau seama

de aici

{"Carnet de sofer", pDrivingLicense, pDrivingLicenseTime},
        {"Licenta de pilot", pFlyingLicense, pFlyingLicenseTime},
        {"Licenta de navigatie", pSailingLicense, pSailingLicenseTime},
        {"Licena de pescar", pFishingLicense, pFishingLicenseTime},
        {"Licenta de port-arma", pGunLicense, pGunLicenseTime},
        {"Licenta de materiale", pMaterialsLicense, pMaterialsLicenseTime}
    };
    
    gString[0] = EOS;
    
    for(new i = 0; i < sizeof licensesStructure; ++i) {
        if(PlayerInfo[playerid][licensesStructure[i][licenseIdx]] == 1)
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n", gString, licensesStructure[i][licenseName], PlayerInfo[playerid][licensesStructure[i][licenseTime]]);

pana aici

Posted
18 minutes ago, Valentin Tarnauceanu said:

de aici

{"Carnet de sofer", pDrivingLicense, pDrivingLicenseTime},
        {"Licenta de pilot", pFlyingLicense, pFlyingLicenseTime},
        {"Licenta de navigatie", pSailingLicense, pSailingLicenseTime},
        {"Licena de pescar", pFishingLicense, pFishingLicenseTime},
        {"Licenta de port-arma", pGunLicense, pGunLicenseTime},
        {"Licenta de materiale", pMaterialsLicense, pMaterialsLicenseTime}
    };
    
    gString[0] = EOS;
    
    for(new i = 0; i < sizeof licensesStructure; ++i) {
        if(PlayerInfo[playerid][licensesStructure[i][licenseIdx]] == 1)
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n", gString, licensesStructure[i][licenseName], PlayerInfo[playerid][licensesStructure[i][licenseTime]]);

pana aici

ai citit macar ce am scris acolo mai jos? In special ce era cu (!)

Posted
20 minutes ago, Sancky said:

ai citit macar ce am scris acolo mai jos? In special ce era cu (!)

da,  asa am pus codul

stock showLicenses(playerid)
{
    enum e_licenses {
        licenseName[64],
        PlayerInfo:licenseIdx,
        PlayerInfo:licenseTime
    }

    static const licensesStructure[][e_licenses] = {
        {"Carnet de sofer", pDrivingLicense, pDrivingLicenseTime},
        {"Licenta de pilot", pFlyingLicense, pFlyingLicenseTime},
        {"Licenta de navigatie", pSailingLicense, pSailingLicenseTime},
        {"Licena de pescar", pFishingLicense, pFishingLicenseTime},
        {"Licenta de port-arma", pGunLicense, pGunLicenseTime},
        {"Licenta de materiale", pMaterialsLicense, pMaterialsLicenseTime}
    };
    
    gString[0] = EOS;
    
    for(new i = 0; i < sizeof licensesStructure; ++i) {
        if(PlayerInfo[playerid][licensesStructure[i][licenseIdx]] == 1)
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n", gString, licensesStructure[i][licenseName], PlayerInfo[playerid][licensesStructure[i][licenseTime]]);
    
        else
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Expirat\n", gString, licensesStructure[i][licenseName]);
    }
    
    new headerText[64];
    format(headerText, sizeof headerText, "Licentele lui %s", GetName(playerid));
    ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, headerText, gString, "Ok", "");
    return 1;
}

Posted
25 minutes ago, Valentin Tarnauceanu said:

da,  asa am pus codul

stock showLicenses(playerid)
{
    enum e_licenses {
        licenseName[64],
        PlayerInfo:licenseIdx,
        PlayerInfo:licenseTime
    }

    static const licensesStructure[][e_licenses] = {
        {"Carnet de sofer", pDrivingLicense, pDrivingLicenseTime},
        {"Licenta de pilot", pFlyingLicense, pFlyingLicenseTime},
        {"Licenta de navigatie", pSailingLicense, pSailingLicenseTime},
        {"Licena de pescar", pFishingLicense, pFishingLicenseTime},
        {"Licenta de port-arma", pGunLicense, pGunLicenseTime},
        {"Licenta de materiale", pMaterialsLicense, pMaterialsLicenseTime}
    };
    
    gString[0] = EOS;
    
    for(new i = 0; i < sizeof licensesStructure; ++i) {
        if(PlayerInfo[playerid][licensesStructure[i][licenseIdx]] == 1)
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Valid  {8ba1f0}- Valabilitate: %d ore\n", gString, licensesStructure[i][licenseName], PlayerInfo[playerid][licensesStructure[i][licenseTime]]);
    
        else
            format(gString, sizeof gString, "%s** {8ba1f0}%s: {fcfcfc}Expirat\n", gString, licensesStructure[i][licenseName]);
    }
    
    new headerText[64];
    format(headerText, sizeof headerText, "Licentele lui %s", GetName(playerid));
    ShowPlayerDialog(playerid, 2323, DIALOG_STYLE_MSGBOX, headerText, gString, "Ok", "");
    return 1;
}

N-ai pus bine, trebuia sa pui numele enum-ului folosit de catre array-ul PlayerInfo, te duci unde definesti PlayerInfo si o sa ai ceva de genul 'PlayerInfo[MAX_PLAYERS][nume enum]' , si pui numele ala acolo la tag-urile alea 2

Join the conversation

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

Guest
Reply to this topic...

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