Jump to content

problema comanda /referal


Recommended Posts

Cand dau referal imi arata ca sunt 0 playeri inregistrati pe referalul meu si defapt sun vreo 2.

 

YCMD:myreferral(playerid, params[], help) {
    new szDialog[1200], szDialog2[256], string[256], szQuery[256], name[64], r, on;
    
    format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `Referral`='%d' ORDER BY `users`.`Level` DESC LIMIT 20", PlayerInfo[playerid][pSQLID]);
    new Cache: result = mysql_query(SQL, szQuery);    
    strcat(szDialog, "{FFB469}(+) Informatii{FFFFFF}\n");
    for(new i, x = cache_num_rows(); i < x; i++) {
        cache_get_field_content(i, "name", string); format(name, 64, string);

        new userID = GetPlayerID( name );
        if(userID != INVALID_PLAYER_ID) format(szDialog2, sizeof(szDialog2), "{1FA612}(Conectat){FFFFFF} %s (%d)\n", name, userID), on++;
        else format(szDialog2, sizeof(szDialog2), "{D60909}(Neconectat){FFFFFF} %s\n", name);
        strcat(szDialog, szDialog2);
        format(Selected[playerid][r], MAX_PLAYER_NAME, name);    
        r++;
    }    
    cache_delete(result);
    new title[64];
    format(title, sizeof(title), "My referrals (%d/%d)", on, r);
    ShowPlayerDialog(playerid, DIALOG_REFERRALS, DIALOG_STYLE_LIST, title, szDialog, "Ok", "Exit");
    return true;
}

Link to comment
Share on other sites

1 minute ago, RazvaNeLL110 said:

Cand dau referal imi arata ca sunt 0 playeri inregistrati pe referalul meu si defapt sun vreo 2.

 

YCMD:myreferral(playerid, params[], help) {
    new szDialog[1200], szDialog2[256], string[256], szQuery[256], name[64], r, on;
    
    format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `Referral`='%d' ORDER BY `users`.`Level` DESC LIMIT 20", PlayerInfo[playerid][pSQLID]);
    new Cache: result = mysql_query(SQL, szQuery);    
    strcat(szDialog, "{FFB469}(+) Informatii{FFFFFF}\n");
    for(new i, x = cache_num_rows(); i < x; i++) {
        cache_get_field_content(i, "name", string); format(name, 64, string);

        new userID = GetPlayerID( name );
        if(userID != INVALID_PLAYER_ID) format(szDialog2, sizeof(szDialog2), "{1FA612}(Conectat){FFFFFF} %s (%d)\n", name, userID), on++;
        else format(szDialog2, sizeof(szDialog2), "{D60909}(Neconectat){FFFFFF} %s\n", name);
        strcat(szDialog, szDialog2);
        format(Selected[playerid][r], MAX_PLAYER_NAME, name);    
        r++;
    }    
    cache_delete(result);
    new title[64];
    format(title, sizeof(title), "My referrals (%d/%d)", on, r);
    ShowPlayerDialog(playerid, DIALOG_REFERRALS, DIALOG_STYLE_LIST, title, szDialog, "Ok", "Exit");
    return true;
}

        case DIALOG_REFERRALS: {
            if(!response) return 1;
            new szQuery[256], szDialog[1024], Cache: result, money, rp, lvl, regdate[100], ore, name[100], szResult[256];
            
            if(listitem == 0)  {
                format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `id`='%d'", PlayerInfo[playerid][pReferral]);
                result = mysql_query(SQL, szQuery);
                cache_get_field_content(0, "name", szResult); format(name, 100, szResult);

                if(PlayerInfo[playerid][pReferral] != 0) format(szDialog, sizeof(szDialog),  "Ai fost adus pe comunitate de %s.\nTe-ai inregistrat pe data de %s\nCodul tau Referral este %d.", name, PlayerInfo[playerid][pRegistredDate], PlayerInfo[playerid][pSQLID]);
                else format(szDialog, sizeof(szDialog),  "Nu ai fost adus pe comunitate de cineva.\nTe-ai inregistrat pe %s\nCodul tau Referral este %d.\nAi adus in total %d jucatori.", PlayerInfo[playerid][pRegistredDate], PlayerInfo[playerid][pSQLID], CountReferrals(playerid));                
                ShowPlayerDialog(playerid, DIALOG_REFERRALS+1, DIALOG_STYLE_MSGBOX, "Referral info", szDialog, "Back", "Exit");            
                return 1;
            }
            listitem --;
            format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `name`='%s'", Selected[playerid][listitem]);
            result = mysql_query(SQL, szQuery);
            cache_get_field_content(0, "RegisterDate", szResult); format(regdate, 100, szResult);
            cache_get_field_content(0, "Level", szResult); lvl = strval(szResult);
            cache_get_field_content(0, "ReferralRP", szResult); rp = strval(szResult);
            cache_get_field_content(0, "ReferralMoney", szResult); money = strval(szResult);
            cache_get_field_content(0, "ConnectedTime", szResult); ore = strval(szResult);            
            cache_delete(result);        
            format(szDialog, sizeof(szDialog), "Informatii despre %s\nInregistrat la data de: %s\nLevel: %d\nOre jucate: %d\nBani castigati de la el: $%s\nRP-uri castigate de la el: %d", Selected[playerid][listitem], regdate, lvl, ore, FormatNumber(money), rp);
            ShowPlayerDialog(playerid, DIALOG_REFERRALS+1, DIALOG_STYLE_MSGBOX, "Referral player", szDialog, "Back", "Exit");    
        }

Link to comment
Share on other sites

  • 1 year later...

YCMD: myreferral(playerid, params[], help) {

    new szDialog[2048], szQuery[256], name[64], on = 0, r = 0;

 

    format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `Referral`='%d' ORDER BY `Level` DESC LIMIT 20", PlayerInfo[playerid][pSQLID]);

    new Cache: result = mysql_query(SQL, szQuery);

 

    if (result) {

        strcat(szDialog, "{FFB469}(+) Informatii{FFFFFF}\n");

 

        for (new i = 0, x = cache_num_rows(); i < x; i++) {

            cache_get_field_content(i, "name", name, sizeof(name);

 

            new userID = GetPlayerID(name);

            if (userID != INVALID_PLAYER_ID)

                format(szDialog, sizeof(szDialog), "{1FA612}(Conectat){FFFFFF} %s (%d)\n", name, userID);

            else

                format(szDialog, sizeof(szDialog), "{D60909}(Neconectat){FFFFFF} %s\n", name);

 

            r++;

        }

        cache_delete(result);

    } else {

        SendClientMessage(playerid, COLOR_RED, "Error while fetching data from the database.");

        return 0;

    }

 

    new title[64];

    format(title, sizeof(title), "My referrals (%d/%d)", on, r);

    ShowPlayerDialog(playerid, DIALOG_REFERRALS, DIALOG_STYLE_LIST, title, szDialog, "Ok", "Exit");

    return 1;

}

 

case DIALOG_REFERRALS: {

    if (!response) return 1;

 

    new szQuery[256], szDialog[1024], szResult[256];

    new money, rp, lvl, regdate[100], ore, name[100];

    listitem--;

 

    if (listitem == 0) {

        format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `id`='%d'", PlayerInfo[playerid][pReferral]);

        new result = mysql_query(SQL, szQuery);

 

        if (result) {

            cache_get_field_content(0, "name", szResult, sizeof(szResult));

            format(name, sizeof(name), szResult);

 

            if (PlayerInfo[playerid][pReferral] != 0)

                format(szDialog, sizeof(szDialog), "Ai fost adus pe comunitate de %s.\nTe-ai înregistrat pe data de %s\nCodul tău Referral este %d.", name, PlayerInfo[playerid][pRegistredDate], PlayerInfo[playerid][pSQLID]);

            else

                format(szDialog, sizeof(szDialog), "Nu ai fost adus pe comunitate de cineva.\nTe-ai înregistrat pe %s\nCodul tău Referral este %d.\nAi adus în total %d jucători.", PlayerInfo[playerid][pRegistredDate], PlayerInfo[playerid][pSQLID], CountReferrals(playerid));

 

            cache_delete(result);

        } else {

            SendClientMessage(playerid, COLOR_RED, "Error while fetching data from the database.");

            return 0;

        }

 

        ShowPlayerDialog(playerid, DIALOG_REFERRALS + 1, DIALOG_STYLE_MSGBOX, "Referral info", szDialog, "Back", "Exit");

    } else {

        format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `name`='%s'", Selected[playerid][listitem]);

        new result = mysql_query(SQL, szQuery);

 

        if (result) {

            cache_get_field_content(0, "RegisterDate", szResult, sizeof(szResult));

            format(regdate, sizeof(regdate), szResult);

            cache_get_field_content(0, "Level", szResult, sizeof(szResult));

            lvl = strval(szResult);

            cache_get_field_content(0, "ReferralRP", szResult, sizeof(szResult));

            rp = strval(szResult);

            cache_get_field_content(0, "ReferralMoney", szResult, sizeof(szResult));

            money = strval(szResult);

            cache_get_field_content(0, "ConnectedTime", szResult, sizeof(szResult));

            ore = strval(szResult);

            cache_delete(result);

 

            format(szDialog, sizeof(szDialog), "Informații despre %s\nÎnregistrat la data de: %s\nLevel: %d\nOre jucate: %d\nBani câștigați de la el: $%d\nRP-uri câștigate de la el: %d", Selected[playerid][listitem], regdate, lvl, ore, money, rp);

            ShowPlayerDialog(playerid, DIALOG_REFERRALS + 1, DIALOG_STYLE_MSGBOX, "Referral player", szDialog, "Back", "Exit");

        } else {

            SendClientMessage(playerid, COLOR_RED, "Error while fetching data from the database.");

            return 0;

        }

    }

    return 1;

}

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