Jump to content

Recommended Posts

Posted

Prima data mergem sub define uri si punem aceasta linie : 

new message[256];

Acum, mergem la enum pInfo si pune urmatorul lucru : 

pBonusTaken

Acum, vom face urmatoarea comanda /firsttime folosind ZCMD :

CMD:firsttime(playerid, params[])
{

    if(PlayerInfo[playerid][pAdmin] < 6)
    {
        if(PlayerInfo[playerid][pBonusTaken] == 1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "Ati revendicat deja bonusul.");
            return 1;
        }

        new randMoney = random(1000000, 1900000);
        new randPoints = random(20, 50);
        new randMats = random(1000, 5000);
        new randDrugs = random(500, 1000);

        GivePlayerCash(playerid, randMoney);
        PlayerInfo[playerid][pPremiumPoints] += randPoints;
        PlayerInfo[playerid][pMats] += randMats;
        PlayerInfo[playerid][pDrugs] += randDrugs;
        PlayerInfo[playerid][pBonusTaken] = 1;

        format(message, sizeof(message), "Felicitari! Ai primit $%d, %d Premium Points, %d Mats, and %d Drugs.", randMoney, randPoints, randMats, randDrugs);
        SendClientMessage(playerid, 0xFFFFFFFF, message);
    }
    else
    {
        new randMoney = random(1000000, 1900000);
        new randPoints = random(20, 50);
        new randMats = random(1000, 5000);
        new randDrugs = random(500, 1000);

        GivePlayerCash(playerid, randMoney);
        PlayerInfo[playerid][pPremiumPoints] += randPoints;
        PlayerInfo[playerid][pMats] += randMats; 
        PlayerInfo[playerid][pDrugs] += randDrugs; 

        format(message, sizeof(message), "Felicitari! Ai primit $%d, %d Premium Points, %d Mats, and %d Drugs.", randMoney, randPoints, randMats, randDrugs);
        SendClientMessage(playerid, 0xFFFFFFFF, message);
    }

    return 1;
}

Sper că o ajute!

  • Confused 2
Posted
On 6/7/2023 at 2:11 PM, Micu_Gamer said:

Prima data mergem sub define uri si punem aceasta linie : 

new message[256];

Acum, mergem la enum pInfo si pune urmatorul lucru : 

pBonusTaken

Acum, vom face urmatoarea comanda /firsttime folosind ZCMD :

CMD:firsttime(playerid, params[])
{

    if(PlayerInfo[playerid][pAdmin] < 6)
    {
        if(PlayerInfo[playerid][pBonusTaken] == 1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "Ati revendicat deja bonusul.");
            return 1;
        }

        new randMoney = random(1000000, 1900000);
        new randPoints = random(20, 50);
        new randMats = random(1000, 5000);
        new randDrugs = random(500, 1000);

        GivePlayerCash(playerid, randMoney);
        PlayerInfo[playerid][pPremiumPoints] += randPoints;
        PlayerInfo[playerid][pMats] += randMats;
        PlayerInfo[playerid][pDrugs] += randDrugs;
        PlayerInfo[playerid][pBonusTaken] = 1;

        format(message, sizeof(message), "Felicitari! Ai primit $%d, %d Premium Points, %d Mats, and %d Drugs.", randMoney, randPoints, randMats, randDrugs);
        SendClientMessage(playerid, 0xFFFFFFFF, message);
    }
    else
    {
        new randMoney = random(1000000, 1900000);
        new randPoints = random(20, 50);
        new randMats = random(1000, 5000);
        new randDrugs = random(500, 1000);

        GivePlayerCash(playerid, randMoney);
        PlayerInfo[playerid][pPremiumPoints] += randPoints;
        PlayerInfo[playerid][pMats] += randMats; 
        PlayerInfo[playerid][pDrugs] += randDrugs; 

        format(message, sizeof(message), "Felicitari! Ai primit $%d, %d Premium Points, %d Mats, and %d Drugs.", randMoney, randPoints, randMats, randDrugs);
        SendClientMessage(playerid, 0xFFFFFFFF, message);
    }

    return 1;
}

Sper că o ajute!

Aici varianta mai ok!

```

CMD:firsttime(playerid, params[]) {
    if(PlayerInfo[playerid][pBonusTaken] && !PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, 0xFFFFFFFF, "Ati revendicat deja bonusul.");
    new randMoney = random(1000000, 1900000), randPoints = random(20, 50), randMats = random(1000, 5000),randDrugs = random(500, 1000);

    GivePlayerCash(playerid, randMoney);
    PlayerInfo[playerid][pPremiumPoints] += randPoints;
    PlayerInfo[playerid][pMats] += randMats;
    PlayerInfo[playerid][pDrugs] += randDrugs;
    PlayerInfo[playerid][pBonusTaken] = 1;

    new message[128];
    format(message, sizeof(message), "Felicitari! Ai primit $%d, %d Premium Points, %d Mats, and %d Drugs.", randMoney, randPoints, randMats, randDrugs);
    return SendClientMessage(playerid, 0xFFFFFFFF, message);
}```

Posted

pe langa ca acesta nu este un tutorial, e doar copy-paste si nici macar nu ai explicat ce ai scris acolo, functia random foloseste doar un singur parametru, acela fiind maximul numarului aleatoriu, ca sa faci o chestie de min - max trebuie sa faci un calcul simplu, de exemplu sa zicem ca vrem un numar aleatoriu intre 5 si 50: `5 + random((50 - 5) + 1)`

si sa nu mai mentionez ca ai cod care se repeta inutil, foloseste tehnica de early returns.

Posted (edited)
On 6/8/2023 at 6:41 PM, Sancky said:

pe langa ca acesta nu este un tutorial, e doar copy-paste si nici macar nu ai explicat ce ai scris acolo, functia random foloseste doar un singur parametru, acela fiind maximul numarului aleatoriu, ca sa faci o chestie de min - max trebuie sa faci un calcul simplu, de exemplu sa zicem ca vrem un numar aleatoriu intre 5 si 50: `5 + random((50 - 5) + 1)`

si sa nu mai mentionez ca ai cod care se repeta inutil, foloseste tehnica de early returns.

Ai uitat sa precizezi ca aceasta variabila:

PlayerInfo[playerid][pBonusTaken] = 1;

este degeaba in tutorialul lui, nu salveaza in db, nu reseteaza la logout.

Tutorial incomplet parerea mea.

Edited by Stuber

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.