Jump to content

Recommended Posts

Tutorial Sistem de Gratar Facut de Dev aka KingZone!

//----------------------------Sistem De Gratar+Functi+Maping+comenzi!------------------------------------------//
Salut Dragi mei mam gandit ca sa va fac un scurt tutorial legat de Sistemul de Gratar pe serverul de samp! deci hai sa incepem!!

-Vom Pune la inceputul gamemodului New GratarTime; cu punct si virgula ca gamemodul sa nu dea erori! si avem:
new GratarTime;

Vom face un forward numit gratarTimer cu functia de playerid si vom avea:

forward GratarTimer(playerid);

Facem o functie numita! public GratarTimer
si va fi egal cu urmatoarea

public GratarTimer(playerid)
{
        SetPlayerCheckpoint(playerid,-828.4074,1439.5641,13.9604, 3.0);
        SendClientMessage(playerid, COLOR_YELLOW, "Carnea ta a fost prajita dute la checkpoint pentru a manca.");
        CP[playerid] = 773;
        PlayerData[playerid][pCarnePrajita] += 1;
}
Construim urmatoarea functie numita else if(CP[playerid] care va fi egal cu == 765) si vom avea!
//Functia noastra reprezantata aici!
//--------------------Functie!---------------------------//
else if(CP[playerid] == 773)
    {
        DisablePlayerCheckpoint(playerid);
        CP[playerid] = 0;
        KillTimer(GratarTime);
    }
=====================================================================================
Bun Gata cu munca! acum deschideti-va programul sa-mp map editor si vom construi si mapa si va rezulta! urmatoarea mapa

CreateDynamicObject(1481, -814.70001, 1446.40002, 13.50000,   0.00000, 0.00000, 44.00000);
CreateDynamicObject(1481, -815.70001, 1427.09998, 13.50000,   0.00000, 0.00000, 225.99500);
CreateDynamicObject(1481, -801.40002, 1428.00000, 13.50000,   0.00000, 0.00000, 225.99400);
CreateDynamicObject(1481, -801.50000, 1446.50000, 13.50000,   0.00000, 0.00000, 43.99400);
CreateDynamicObject(2780, -798.00000, 1424.19995, 14.00000,   0.00000, 0.00000, 0.00000);
CreateDynamicObject(2780, -817.59998, 1450.09998, 13.80000,   0.00000, 0.00000, 0.00000);
CreateDynamicObject(2780, -812.20001, 1425.19995, 14.60000,   0.00000, 0.00000, 0.00000);
CreateDynamicObject(2780, -803.90002, 1449.50000, 14.00000,   0.00000, 0.00000, 0.00000);

--Bun Trecem mai departe!
Vom construi urmatorul lucru numit CreateDynamic3DTextLabel si va rezulta!

    CreateDynamic3DTextLabel("{FFFFFF}Pentru a face gratar {FEEA05}nscrie n {00F8E0}/gratar",0xFF6600FF,-814.0182,1445.6233,13.7891 ,20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
    CreateDynamic3DTextLabel("{FFFFFF}Pentru a face gratar {FEEA05}nscrie n {00F8E0}/gratar",0xFF6600FF,-816.4177,1427.7321,13.7891 ,20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
    CreateDynamic3DTextLabel("{FFFFFF}Pentru a face gratar {FEEA05}nscrie n {00F8E0}/gratar",0xFF6600FF,-801.9002,1428.5662,13.7891 ,20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
    CreateDynamic3DTextLabel("{FFFFFF}Pentru a face gratar {FEEA05}nscrie n {00F8E0}/gratar",0xFF6600FF,-800.5424,1445.7963,13.7891 ,20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
    CreateDynamic3DTextLabel("{FFFFFF}Pentru a manca carnea {FEEA05}nscrie n {00F8E0}/mananc",0xFF6600FF,-828.4074,1439.5641,13.9604 ,20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);

Vom face pt acest sistem si niste pick-up uri amanuntite! pt bineinteles Sistemul Gratarului :) si va rezulta functia CreateDynamicPickup! este egal cu:
//---------------------------gratar----------------------------------//
       CreateDynamicPickup(2806,23,-814.0182,1445.6233,13.7891, -1, -1,-1,100.0);//gratar
    CreateDynamicPickup(2806,23,-816.4177,1427.7321,13.7891, -1, -1,-1,100.0);//gratar
       CreateDynamicPickup(2806,23,-801.9002,1428.5662,13.7891, -1, -1,-1,100.0);//gratar
       CreateDynamicPickup(2806,23,-800.5424,1445.7963,13.7891, -1, -1,-1,100.0);//gratar
       CreateDynamicPickup(1239,23,-828.4074,1439.5641,13.9604, -1, -1,-1,100.0);//mananc

Acum Vom Construi comanda /mananc pt a putea manca carnea care o va face gratarul :)
si vom avea pe format STRCMP [Varianta simpla]
Pentru a construi corect comanda veti fi nevoiti sa definiti pCarnePrajita!
    
if(strcmp(cmd, "/mananc", true) == 0)
        {
        if(PlayerData[playerid][pCarnePrajita] != 1)
        {
            SendClientMessage(playerid, COLOR_GRAD2, "TEST: Nu ai prajit nici-o carne.");
            SendClientMessage(playerid, COLOR_GRAD2, "TEST: Pentru a praji dute langa un gratar.");
            return 1;
         }
        if(PlayerToPoint(1.5, playerid, -828.4074,1439.5641,13.9604))
         {
        PlayerData[playerid][pExp] += 1;
        PlayerData[playerid][pCarnePrajita] -= 1;
        SendClientMessage(playerid, COLOR_GRAD2, "TEST: Ai mancat carnea si ai primit +1RP.");
           }
         return 1;
 }

Avem chiar si varianta ZCMD!

CMD:mananc(playerid, params[])
{
    if(playerVariables[playerid][pCarnePrajita] != 1)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "TEST: Nu ai prajit nici-o carne.");
        SendClientMessage(playerid, COLOR_GRAD2, "TEST: Pentru a praji dute langa un gratar.");
        return 1;
    }
    if(PlayerToPoint(1.5, playerid, -828.4074,1439.5641,13.9604))
    {
        PlayerData[playerid][pExp] += 1;
        PlayerData[playerid][pCarnePrajita] -= 1;
        SendClientMessage(playerid, COLOR_GRAD2, "TEST: Ai mancat carnea si ai primit +1RP.");
    }
    return 1;
}
Mai departe pt comanda urmatoare vom defini
pCarne la definuri![De Ex scrieti pJob in gm-ul vostru si veti gasi!]
Asa suntem pregatiti sa construim comanda /gratar hadeti sa o facem !

============================================================================

STRCMP FORMAT:

    
if(strcmp(cmd, "/gratar", true) == 0)
     {
        if(PlayerData[playerid][pCarne] != 1)
         {
            SendClientMessage(playerid, COLOR_GRAD2, "TEST: Nu poti praji carne ca nu ai carne.");
            SendClientMessage(playerid, COLOR_GRAD2, "TEST: Dute la 24/7 pentru a procura carne..");
            return 1;
          }
     if(PlayerToPoint(1.5, playerid, -814.0182,1445.6233,13.7891) || PlayerToPoint(1.5, playerid, -816.4177,1427.7321,13.7891) || PlayerToPoint(1.5, playerid, -801.9002,1428.5662,13.7891) || PlayerToPoint(1.5, playerid, -800.5424,1445.7963,13.7891))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "Asteapta 30 de minute pentru a praji carnea.");
            GratarTime = SetTimerEx("GratarTimer", 1800000, 0, "d", playerid);
            PlayerData[playerid][pCarne] -= 1;
           }
         return 1;
         }

Varianta ZCMD:

======================================================================================

CMD:gratar(playerid, params[])
{
    if(playerVariables[playerid][pCarne] = 1)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "TEST: Nu poti praji carne ca nu ai carne.");
        SendClientMessage(playerid, COLOR_GRAD2, "TEST: Dute la 24/7 pentru a procura carne..");
        return 1;
    }
    if(PlayerToPoint(1.5, playerid, -814.0182,1445.6233,13.7891) || PlayerToPoint(1.5, playerid, -816.4177,1427.7321,13.7891) || PlayerToPoint(1.5, playerid, -801.9002,1428.5662,13.7891) || PlayerToPoint(1.5, playerid, -800.5424,1445.7963,13.7891))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Asteapta 30 de minute pentru a praji carnea.");
        GratarTime = SetTimerEx("GratarTimer", 1800000, 0, "d", playerid);
        PlayerData[playerid][pCarne] -= 1;
    }
    return 1;
}

=====================================================================================
Bun....Daca ati construit corect putem merge mai departe!
Acum suntem pregatiti pt ultima functie din acest sistem pff mai avem o functie si eu sunt obosit deja :))))
Avem urmatoarea functie numita else if pe item-ul 14
si va rezulta urmatoarea!
=======================================================================================
else if (item == 14 && GetPlayerCash(playerid) > 200000)
            {
                   GivePlayerCash(playerid,-200000);
                SBizzData[9][sbTill] += 200000;
                ExtortionSBiz(9, 5000);
                format(string, sizeof(string), "~r~-$%d", 5000);
                GameTextForPlayer(playerid, string, 5000, 1);
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                PlayerData[playerid][pCarne] += 1;
                format(string, sizeof(string), "Ti-ai cumparat 1KG de carne, acum poti praji carnea la gratar!");
                SendClientMessage(playerid, COLOR_GRAD4, string);
                SendClientMessage(playerid, COLOR_WHITE, "HINT: Scrie /gratar.");
                format(string, sizeof(string), "UPDATE players SET Carne='%d' WHERE id=%d", PlayerData[playerid][pCarne], PlayerData[playerid][pSQLID]);
                mysql_query(string);
                rreturn 1;
            }

==============================================================================================
Cam Atat Dragi mei eu sper ca vam ajutat sa realizati un sistem destul de bun pt serverul vostru! Acestea sunt functile vam ajutat eu cu ele! totul conteaza sa aveti logica si sa stiti cum trebuie adaugate! aveti
explicatia indetaliata mai sus! Mare Grija la functi +cum le adaugati verificati tot timpul amx-ul serverului daca el este pe 0kb inseamna ca nu ati adugat functile sistemului bine! :)
Multumesc ca ati fost alaturi de mine eu am fost Dev Aka[KingZone] La Revedere!

                                                  //----------------------------------Tutoriale Scripting PWN-->Limbaj PWN!----------------------------------------------------//

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