Jump to content

Question

Posted

Salut am si eu o Problema cu comanda:friends

Imagine:

PS:scuzati reclama dar e sv meuECtjmp1.png

4 answers to this question

Recommended Posts

  • 0
Posted (edited)
Quote
Quote

CMD:friends(playerid, params[])
{
    if(playerVariables[playerid][pAdminLevel] >= 7) //Moentan este in faza beta doar admini au acces la aceasta comanda
    {
        new szDialString[600];
        format(szDialString, 600, "Add a friend\n");
        new quer[256], test1[256], test2[256], quer2[256], test3[256];
        mysql_format(handle, quer, 256, "SELECT * FROM friends WHERE friendAddID = '%d'", playerVariables[playerid][pInternalID]);
        new Cache: res = mysql_query(handle, quer);
        new x;
        for(new i, j = cache_get_row_count(); i != j; i++)
        {
            cache_get_field_content(i, "friendInternalID", result); format(test2, 256, result);
            new id = strval(test2);
            mysql_format(handle, quer2, 256, "SELECT * FROM playeraccounts WHERE playerID = '%d'", id);
            new Cache: res2 = mysql_query(handle, quer2);
            if(cache_get_row_count() != 0)
            {
                x++;
                cache_get_field_content(0, "playerName", result); format(test3, 256, result);
                cache_get_field_content(i, "playerPhoneNumber", result); format(test1, 256, result);
                format(playerVariables[x][sfnume], MAX_PLAYER_NAME, test3);
                format(playerVariables[x][sfnumber], 25, test1);
                new id2 = GetPlayerID(test3);
                if(id2 != INVALID_PLAYER_ID)
                {
                    format(szDialString, 600, "%s{00FF00}%s(%s){FFFFFF}\n", szDialString, test3, test1);
                }
                else
                {
                    format(szDialString, 600, "%s{FF0000}%s(%s){FFFFFF}\n", szDialString, test3, test1);
                }
            }
            cache_delete(res2);
        }
        cache_delete(res);
        ShowPlayerDialog(playerid, DIALOG_FRIENDS, DIALOG_STYLE_LIST, "Server: Friends", szDialString, "Select", "Cancel");
    }
    return 1;
}

 

dialogul

case DIALOG_FRIENDS:
                {
                        if(response)
                        {
                                if(listitem == 0)
                                {
                                        ShowPlayerDialog(playerid, DIALOG_FRIENDS2, DIALOG_STYLE_INPUT, "Server: Add a Friend", "Put the playername in the box - type only the name, without the clan tag!", "Add", "Cancel");
                                }
                                else
                                {
                                        format(sName[playerid], MAX_PLAYER_NAME, playerVariables[playerid][sfnume]);
                                        //format(sName[playerid], MAX_PLAYER_NAME, Selectedf[listitem][sfnume]);
                                        new dialstr[40];
                                        SCM(playerid, -1, dialstr);
                                        new id = GetPlayerID(sName[playerid]);
                                        if(id != INVALID_PLAYER_ID)
                                        {
                                                ShowPlayerDialog(playerid, DIALOG_FRIENDS3, DIALOG_STYLE_LIST, dialstr, "Remove from friends\nCall\nSMS", "Select", "Cancel");
                                        }
                                        else
                                        {
                                                ShowPlayerDialog(playerid, DIALOG_FRIENDS3, DIALOG_STYLE_LIST, dialstr, "Remove from friends", "Select", "Cancel");
                                        }
                                }
                        }
                }
                case DIALOG_FRIENDS3:
                {
                        if(response)
                        {
                                new id = GetPlayerID(sName[playerid]);
                                switch(listitem)
                                {
                                        case 0:
                                        {
                                                new queryy[256], id2;
                                                mysql_format(handle, queryy, 256, "SELECT * FROM playeraccounts WHERE playerName = '%s'", sName[playerid]);
                                                new Cache: re = mysql_query(handle, queryy);
                                                if(cache_get_row_count() >= 1)
                                                {
                                                        cache_get_field_content(0, "playerID", result); id2 = strval(result);
                                                        new queryy2[256], frid;
                                                        mysql_format(handle, queryy2, 256, "SELECT * FROM friends WHERE friendInternalID = '%d' AND friendAddID = '%d'", id2, playerVariables[playerid][pInternalID]);
                                                        new Cache: re2 = mysql_query(handle, queryy2);
                                                        if(cache_get_row_count() == 0)
                                                        {
                                                                SCM(playerid, -1, "This player is not in your contact list!");
                                                                cache_get_field_content(0, "friendID", result); frid = strval(result);
                                                        }
                                                        else
                                                        {
                                                                mysql_format(handle, queryy2, 256, "DELETE * FROM friends WHERE friendID = '%d'", frid);
                                                                mysql_tquery(handle, queryy2);

                                                                SCM(playerid, -1, "Player removed from contacts.");
                                                        }
                                                        cache_delete(re2);
                                                }
                                                else
                                                {
                                                SCM(playerid, -1, "There's no such a player!");
                                                }
                                                cache_delete(re);
                                        }
                                        case 1:
                                        {
                                                if(id != INVALID_PLAYER_ID)
                                                {
                                                        ShowPlayerDialog(playerid, DIALOG_FRIENDS4, DIALOG_STYLE_INPUT, "Server: SMS", "What text do you wish to send?", "Go", "Cancel");
                                                }
                                        }
                                        case 2:
                                        {
                                                new number;
                                                new queryy[256];
                                                mysql_format(handle, queryy, 256, "SELECT * FROM playeraccounts WHERE playerName = '%s'", sName[playerid]);
                                                new Cache: re = mysql_query(handle, queryy);
                                                if(cache_get_row_count() >= 1)
                                                {
                                                        cache_get_field_content(0, "playerPhoneNumber", result); number = strval(result);
                                                }
                                                cache_delete(re);
                                                if(number != -1)
                                                {
                                                        new string[256];
                                                        if(playerVariables[playerid][pPhone] == 1)
                                                        {
                                                                format(string, sizeof(string), "* %s takes out their cellphone, and dials in a number.", szPlayerName, number);
                                                        }
                                                        else if(playerVariables[playerid][pPhone] == 2)
                                                        {
                                                                format(string, sizeof(string), "* %s takes out their iPhone, and dials in a number.", szPlayerName, number);
                                                        }
                                                        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
                                                        nearByMessage(playerid, COLOR_PURPLE, string);
                                                        if(playerVariables[playerid][pPhone] == 1)
                                                        {
                                                                SetPlayerAttachedObject(playerid,4,330,6, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
                                                        }
                                                        else if(playerVariables[playerid][pPhone] == 2)
                                                        {
                                                                SetPlayerAttachedObject( playerid, 4, 18865, 6, 0.086043, 0.027719, 0.003817, 95.232246, 178.651031, 1.691840, 1.002077, 1.000000, 1.000000 ); // MobilePhone1 - phone1
                                                        }

                                                        foreach(Player, i)
                                                        {
                                                                if(playerVariables[pPhoneNumber] == number)
                                                                {
                                                                        if(playerVariables[pStatus] == 1 && playerVariables[pSpectating] == INVALID_PLAYER_ID && playerVariables[pPhoneStatus] == 1 && playerVariables[pPhoneCall] == -1 && playerVariables[pPrisonID] != 3) {

                                                                                if(playerVariables[pPhone] == 1)
                                                                                {
                                                                                        GetPlayerName(i, szPlayerName, MAX_PLAYER_NAME);
                                                                                        format(string, sizeof(string), "* %s's cellphone starts to ring...", szPlayerName);
                                                                                }
                                                                                else if(playerVariables[pPhone] == 2)
                                                                                {
                                                                                        GetPlayerName(i, szPlayerName, MAX_PLAYER_NAME);
                                                                                        format(string, sizeof(string), "* %s's iPhone starts to ring...", szPlayerName);
                                                                                }
                                                                                nearByMessage(i, COLOR_PURPLE, string);
                                                                                format(szMessage, sizeof(szMessage), "You are called by %s. Type /p(ickup) to answer your phone.", playerVariables[playerid][pNormalName]);
                                                                                SCM(i, COLOR_YELLOW, szMessage);

                                                                                playerVariables[playerid][pCall] = i;
                                                                                return 1;
                                                                        }
                                                                        else
                                                                        {
                                                                                SendClientMessage(playerid, COLOR_GREY, "(cellphone) *busy tone*");
                                                                                return 1;
                                                                        }
                                                                }
                                                        }
                                                        if(playerVariables[playerid][pPhoneCall] == -1) SendClientMessage(playerid, COLOR_GREY, "(cellphone) *busy tone*");
                                                }
                                        }
                                }
                        }
                }
                case DIALOG_FRIENDS4:
                {
                        new number, count;
                        if(response)
                        {
                                new queryy[256];
                                        mysql_format(handle, queryy, 256, "SELECT * FROM playeraccounts WHERE playerName = '%s'", sName[playerid]);
                                        new Cache: re = mysql_query(handle, queryy);
                                        if(cache_get_row_count() >= 1)
                                        {
                                                cache_get_field_content(0, "playerPhoneNumber", result); number = strval(result);
                                        }
                                        cache_delete(re);
                                        foreach(Player, x)
                                        {
                                                if(playerVariables[x][pPhoneNumber] == number)
                                                {
                                                        if(playerVariables[x][pPhoneStatus] == 1)
                                                        {
                                                                GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);

                                                                format(szMessage, sizeof(szMessage), "SMS from %s (%d): %s", szPlayerName, playerVariables[playerid][pPhoneNumber], inputtext);
                                                                SendClientMessage(x, COLOR_YELLOW, szMessage);
                                                                LastPlayer[x] = playerid;

                                                                GetPlayerName(x, szPlayerName, MAX_PLAYER_NAME);

                                                                format(szMessage, sizeof(szMessage), "SMS sent to %s (%d): %s", szPlayerName, playerVariables[x][pPhoneNumber], inputtext);
                                                                SendClientMessage(playerid, COLOR_SMS, szMessage);
                                                                playerVariables[playerid][pPhoneCredit] -= 3;

                                                                new szQuery[256];
                                                                mysql_format(handle, szQuery, sizeof(szQuery), "INSERT INTO `phonelogs` (`phoneNumber`, `phoneAction`) VALUES('%d', 'SMS to %s: %s')", playerVariables[playerid][pPhoneNumber], szPlayerName, inputtext);
                                                                mysql_tquery(handle, szQuery);
                                                                return 1;
                                                        }
                                                        else {
                                                                return SendClientMessage(playerid, COLOR_GREY, "The cellphone that you're trying to SMS is currently unavailable.");
                                                        }
                                                }
                                        }
                                count++;
                        }
                        if(count < 1) return SendClientMessage(playerid, COLOR_GREY, "Invalid number.");
                }
                case DIALOG_FRIENDS2:
                {
                        if(response)
                        {
                                new quer69[256], id, number;
                                mysql_format(handle, quer69, 256, "SELECT * FROM friends WHERE friendAddID = '%d'", playerVariables[playerid][pInternalID]);
                                new Cache: q = mysql_query(handle, quer69);
                                if(cache_get_row_count() >= 10)
                                {
                                        SCM(playerid, -1, "You already have so many friends!");
                                        return 1;
                                }
                                cache_get_field_content(0, "friendInternalID", result); id = strval(result);
                                cache_delete(q);
                                mysql_format(handle, quer69, 256, "SELECT * FROM playeraccounts WHERE playerID = '%d'", id);
                                new Cache: q2 = mysql_query(handle, quer69);
                                if(cache_get_row_count() != 0)
                                {
                                        cache_get_field_content(0, "playerPhoneNumber", result); number = strval(result);
                                }
                                cache_delete(q2);
                                if(number != -1)
                                {
                                        mysql_format(handle, quer69, 256, "INSERT INTO `friends` (`friendNumber`, `friendInternalID`, `friendAddID`) VALUES ('%d', '%d', '%d')", number, id, playerVariables[playerid][pInternalID]);
                                        mysql_query(handle, quer69);
                                        SCM(playerid, -1, quer69);

                                        SCM(playerid, -1, "Friend added!");
                                }
                        }
                }

  Poza baza de date:

DntH9cH.png

 

Edited by SUSANU

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.