Jump to content

Tutorial: Sistem AFK/Back


Micu_Gamer

Recommended Posts

Salutare! Am create un tutorial simplu pentru a implementa un sistem AFK/Back in serverul vostru de SA:MP. Acest sistem permite jucatorilor sa intre in modul AFK si sa se intoarca la joc atunci cand doresc. Voi explica pasii necesari pentru implementarea acestui sistem folosind limbajul de scripting Pawn.

[Pasul 1: Declarare variabile]

Inainte de a incepe implementarea, trebuie sa declaram urmatoarea variabila:

new AFKMode[MAX_PLAYERS];

[Pasul 2: Comanda /afk

Pentru a activa AFK, am creat comanda /afk. Aceasta comanda are urmatorul cod:

CMD:afk(playerid, params[])
{
    if (AFKMode[playerid]) return SendClientMessage(playerid, COLOR_RED, "Esti deja AFK.");
    AFKMode[playerid] = 1;
    new string[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    TogglePlayerControllable(playerid, 0);
    format(string, sizeof(string), "%s este acum AFK.", pname);
    SendClientMessageToAll(COLOR_YELLOW, string);
    return 1;
}

[Pasul 3: Comanda /back

Pentru a reveni la joc din modul AFK, am creat comanda /back. Aceasta comanda are urmatorul cod:

CMD:back(playerid, params[])
{
    if (!AFKMode[playerid]) return SendClientMessage(playerid, COLOR_RED, "Nu esti afk.");
    AFKMode[playerid] = 0;
    new string[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(string));
    TogglePlayerControllable(playerid, 1);
    format(string, sizeof(string), "%s nu mai este acum AFK.", pname);
    SendClientMessageToAll(COLOR_YELLOW, string);
    return 1;
}

Aceasta a fost o scurta introducere despre cum puteti implementa un sistem AFK/Back in serverul vostru de SA:MP. Sper ca acest tutorial a fost util si ca va ajutat!

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.