Jump to content

[Tutorial]Faction Raport


Extremys

Recommended Posts

Salutare, astazi am sa va prezint un scurt tutorial prin care puteti crea un raport automatizat la unele  factiunii. In acest tutorial eu am ales factiunea School Instructor.

  • Adaugam in tabelul "users" sau cum il aveti voi denumit(tabelul in care sunt conturile jucatoriilor) o noua coloana numita 'playerCommands' sau cum doriti.
  • Ne ducem la public OnPlayerLogin(daca nu aveti asa cautati " cache_get_field_content( "  trebuie sa fie un sir cu mai multe variabile sa zic asa) si adaugati  cache_get_field_content(0, "playerCommands", result); playerVariables[extraid][pCommands] = strval(result);
  • Acum mergem la playerVariables(daca nu gasiti asta cautati pAdmin sau pLevel va dati voi seama la ce ma refer) acolo adaugam pCommands.
  • Acum ne ducem la comanda /givelicence(comanda cu care cei din factiunea School Instructor dau licentele) si adaugam urmatoarele,v a dau exemplu si dupa va zic.
  •  

     

    CMD:givelicence(playerid, params[])


    {
        if(playerVariables[playerid][pGroup] == 11 && playerVariables[playerid][pGroupRank] >= 2)
        {
            new x_nr[32],sendername[25],giveplayer[25],string[256],id;
            if(sscanf(params, "us[32]",id,x_nr))
            {
                SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/givelicense [playerid] [license] ");
                SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"Available names: Fly, Gun, Boat.");
            }
            else
            {
                if(id != INVALID_PLAYER_ID)
                {
                    if(strcmp(x_nr,"fly",true) == 0)
                    {
                        if(playerVariables[id][pFlyLicense] == 0)
                        {
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            GetPlayerName(id, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "%s ti-a dat licenta de fly.",sendername);
                            SendClientMessage(id, COLOR_IN2, string);
                            format(string, sizeof(string), "I-ai dat lui %s licenta fly.",giveplayer);
                            SendClientMessage(playerid, COLOR_IN2, string);
                            playerVariables[id][pFlyLicense] = 100;
                            new str[128];
                            format(str,128,"UPDATE `playeraccounts` SET `playerFlyLic`='100' WHERE `playerID`='%d'",playerVariables[id][pInternalID]);
                            mysql_tquery(handle,str);
                            format(string, sizeof(string), "(i) %s has given %s the fly license.",sendername,giveplayer);
                            SendToGroup(13, COLOR_IN, string);
                            playerVariables[playerid][pCommands] ++;
                            new rquery[256];
                            format(rquery, sizeof(rquery), "UPDATE `playeraccounts` SET `playerCommands`='%d' WHERE `playerID`='%d''", playerVariables[playerid][pCommands], playerVariables[id][pInternalID]);
                            mysql_query(handle, rquery);
                            return 1;
                        }
                        else SCM(playerid, -1, "This player already have the fly licese!");

                    }
                    else if(strcmp(x_nr,"gun",true) == 0)
                    {
                        if(playerVariables[id][pGunLicense] == 0)
                        {
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            GetPlayerName(id, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "%s ti-a dat licenta de gun.",sendername);
                            SendClientMessage(id, COLOR_IN2, string);
                            format(string, sizeof(string), "I-ai dat lui %s licenta gun.",giveplayer);
                            SendClientMessage(playerid, COLOR_IN2, string);
                            playerVariables[id][pGunLicense] = 100;
                            new str[128];
                            format(str,128,"UPDATE `playeraccounts` SET `playerGunLic`='100' WHERE `playerID`='%d'",playerVariables[id][pInternalID]);
                            mysql_tquery(handle,str);
                            format(string, sizeof(string), "(i) %s has given %s the gun license.",sendername,giveplayer);
                            SendToGroup(13, COLOR_IN, string);
                            playerVariables[playerid][pCommands] ++;
                            new rquery[256];
                            format(rquery, sizeof(rquery), "UPDATE `playeraccounts` SET `playerCommands`='%d' WHERE `playerID`='%d''", playerVariables[playerid][pCommands], playerVariables[id][pInternalID]);
                            mysql_query(handle, rquery);
                            return 1;
                        }
                        else SCM(playerid, -1, "This player already have the gun licese!");
                    }
                    else if(strcmp(x_nr,"boat",true) == 0)
                    {
                        if(playerVariables[id][pBoatLicense] == 0)
                        {
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            GetPlayerName(id, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "%s ti-a dat licenta de boat.",sendername);
                            SendClientMessage(id, COLOR_IN2, string);
                            format(string, sizeof(string), "I-ai dat lui %s licenta boat.",giveplayer);
                            SendClientMessage(playerid, COLOR_IN2, string);
                            playerVariables[id][pBoatLicense] = 100;
                            new str[128];
                            format(str,128,"UPDATE `playeraccounts` SET `playerBoatLic`='100' WHERE `playerID`='%d'",playerVariables[id][pInternalID]);
                            mysql_tquery(handle,str);
                            format(string, sizeof(string), "(i) %s has given %s the boat license.",sendername,giveplayer);
                            SendToGroup(13, COLOR_IN, string);
                            playerVariables[playerid][pCommands] ++;
                            new rquery[256];
                            format(rquery, sizeof(rquery), "UPDATE `playeraccounts` SET `playerCommands`='%d' WHERE `playerID`='%d''", playerVariables[playerid][pCommands], playerVariables[id][pInternalID]);
                            mysql_query(handle, rquery);
                            return 1;
                        }
                        else SCM(playerid, -1, "This player already have the gun licese!");
                    }
                    else SCM(playerid, -1, "Invalid license!");
                }
                else SCM(playerid, -1, "Player not connected!");
            }
        }
        else SCM(playerid, -1, "You're not faction School Instructors or not you rank 2.");
        return 1;
    }

     

  • Adaugati

    playerVariables[playerid][pCommands] ++;
                            new rquery[256];
                            format(rquery, sizeof(rquery), "UPDATE `playeraccounts` SET `playerCommands`='%d' WHERE `playerID`='%d''", playerVariables[playerid][pCommands], playerVariables[id][pInternalID]);
                            mysql_query(handle, rquery);

    inainte de return 1; dupa cum vedeti si in exemplu, nu am dormit 39 de ore sunt foarte obosit nu pot explica exact dar puteti da reply.

  • Inca ceva: playeraccounts-inlocuiti cu ce aveti voi adica users etc.
  • Acum pentru a vedea player-ul licentele acordate mergem la public showstats sau stock showstats (depinde de gamemode) Acolo adaugam urmatoarele:
  • if(playerVariables[targetid][pGroup] == 11)//aici puneti variabilele voastre si numarul factiuni  care reprezinta school instructor
    	{
    		format(szMessage, sizeof(szMessage), "{FF0000}Licente Date: %d", playerVariables[targetid][pCommands]);
    		SendClientMessage(playerid, COLOR_WHITE, szMessage);
    	}

    Acel text ne va aparea la /stats doar daca facem parte din factiune.

  • Acum sa facem o comanda la care va avea acces lider-ul si care ii va arata raport-ul fiecaruia.

  •  

     

    CMD:raports(playerid, params[])


    {
        if(playerVariables[playerid][pGroup] >= 1 && playerVariables[playerid][pGroupRank] >= 6)
        {
            new aim[2400];
            new query[300], test[300], test1[300], test2[300], test4[300];
            format(query, sizeof(query), "SELECT * FROM `playeraccounts` WHERE `playeraccounts`.`playerGroup` = '%d' ORDER BY `playeraccounts`.`playerGroupRank` DESC LIMIT 50", playerVariables[playerid][pGroup]);
            new Cache: membresult = mysql_query(handle, query);
            new memid;
            for ( new i, j = cache_get_row_count ( ); i != j; ++i )
            {
                cache_get_field_content(i, "playerName", result); format(test, 300, result);
                cache_get_field_content(i, "playerDays", result); format(test1, 300, result);
                cache_get_field_content(i, "playerCommands", result); format(test2, 300, result);
                cache_get_field_content(0, "playerLastLogin", test4); format(Selected[memid][slastlogin], 25, test4);
                format(Selected[memid][snume], MAX_PLAYER_NAME, test);
                new id = GetPlayerID(test);
                if(id != INVALID_PLAYER_ID)
                {
                    format(aim, sizeof(aim), "%s%s - {00FF00}Online{FFFFFF} - %s days  - {FF0000}%s {00FF00}Raport Saptamanal\n", aim, test, test1, test2);
                }
                else
                {
                    format(aim, sizeof(aim), "%s%s - {FF0000}Offline{FFFFFF} - %s days - {FF0000}%s {00FF00}Raport Saptamanal - {FFFFFF}Last ONLINE %s\n", aim, test, test1, test2, test4);
                }
                memid++;
            }
            cache_delete(membresult);
            ShowPlayerDialog(playerid,DIALOG_MEMBERSS2,DIALOG_STYLE_LIST,"Server: Raports",aim,"Clear","Cancel");
        }
        return 1;
    }

     

  • Cand scrieti /raports va va aparea lista cu toti membri si in dreptul lor cate licente a acordat

  • Totul este aproape gata si mai aveam doar de adaugat o comanda prin care sterge raport-ul.

 

 

CMD:craport(playerid,params[]) {


    if(playerVariables[playerid][pGroup] == 11 && playerVariables[playerid][pGroupRank] >= 6) {

        new
            targetid;

        if(sscanf(params, "u", targetid))
            return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/clearraport [playerid]");
            {
                playerVariables[targetid][pCommands] = 0;
                SendClientMessage(playerid, -1, "I-ai sters rapot-ul!");
                SendClientMessage(targetid, -1, "Lider-ul ti-a sters raport-ul factiunii");
                new quer[256];
                mysql_format(handle, quer, 256, "UPDATE playeraccounts SET playerCommands = '0' WHERE playerID = '%d'", playerVariables[playerid][pInternalID]);
                mysql_tquery(handle, quer);
            }
     }
    return 1;
}

SFARSIT.

Daca ti-am fost de ajutor nu uita de +1.

P.S-Daca am greseli gramaticale va rog sa nu ma criticati nu am dormit de ceva vreme si sunt obosit.

Daca aveti nelamuriri lasa-ti REPLY.

Daca am gresit ceva spuneti-mi.

Edited by Extremys
  • Upvote 3

giphy.gif

Link to comment
Share on other sites

Am mai vazut tutorialul undeva, ma cam indoiesc ca l-ai facut tu.

Edited by Ainox

                                                                                                 

Link to comment
Share on other sites

Chiar acum, Ainox a spus:

Am mai vazut tutorialul undeva, ma cam indoiesc ca l-ai facut tu.

Tutorialul facut de Ady.Capone pe o alta comunitate, l-am postat si acolo sub numele de [Tutorial]Faction Raport - Versiuena mea putin diferita de cea a lui Capone. Tutorialul facut de Capone este un sfert din ce am facut eu. Dar daca nu crezi ti-as putea demonstra intr-un fel?

  • Upvote 1

giphy.gif

Link to comment
Share on other sites

1 minute ago, Extremys said:

Tutorialul facut de Ady.Capone pe o alta comunitate, l-am postat si acolo sub numele de [Tutorial]Faction Raport - Versiuena mea putin diferita de cea a lui Capone. Tutorialul facut de Capone este un sfert din ce am facut eu. Dar daca nu crezi ti-as putea demonstra intr-un fel?

Nu am nevoie sa-mi demonstreze nimeni cat stie sa scripteze, daca ai facut tu bravo, ce sa zic, succes in continuare.

                                                                                                 

Link to comment
Share on other sites

Acum 3 minute, Ainox a spus:

Nu am nevoie sa-mi demonstreze nimeni cat stie sa scripteze, daca ai facut tu bravo, ce sa zic, succes in continuare.

Multumesc, si cand am spus ca vreau sa demonstrez am vrut sa arat tutoror ca nu sunt gen-ul copy-paste, daca capone posta si aici tutorial-ul, bineinteles ca mentionam ca de la el mi-am facut idee

Edited by Extremys

giphy.gif

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

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.