Jump to content

Interdictie /ban admin


Gireada

Recommended Posts

hOpa # Hcs a cerut un tutorial cum sa pui interdictie la comanda ban, daca ea este folosita de prea multe ori.

Pai vom avea nevoie de un contor, care sa contorizeze de cate ori este folosita comanda, de un timer care sa scada acel contor dupa un anumit timp si o variabila unde vom stoca id-ul timer-ului.

Vom defini:

#define MAX_ACCES 3 // poate folosi de 3 ori maxim comanda
#define TIME_CONTOR 60000  // dupa 1 minut sa-i scada contorul

new contorCMD[MAX_PLAYERS]; //contorul nostru
new timerCMD[MAX_PLAYERS]; //timpul pe care il are jucatorul de cand a folosit comanda
new timer[MAX_PLAYERS]; //unde vom stoca id-ul timer-ului

forward TimeCMD(playerid); //definit functia, unde-i va scadea contorul

La comanda noastra adaugam:

 

if(timerCMD[playerid] == 0) // daca nu a facut exces sau a stat ceva timp
    timer[playerid] = SetTimerEx("TimeCMD", 1000, 1, "i", playerid); // va porni timer-ul cand va accesa comanda

contorCMD[playerid]++; // contorul va creste pentru ca a folosit comanda
if(contorCMD[playerid] >= 3) { BanEx(playerid, "Exces de ban"; return 1;}  //iar daca a folosit comanda de 3 ori ii va da Ban si-i va afisa mesajul "Exces de ban"

 

Iar acum la final vom creea timer-ul(functia)


 

public TimeCMD(playerid) // numele functie, pe care l-am definit la inceput de tutorial
{
    timerCMD[playerid]++; // variabila unde va creste timpul secunda dupa secunda
    if(timerCMD[playerid] >= TIME_CONTOR) // daca valoarea variabilei a depasit timpul definit
    {

        contorCMD[playerid]--; // contorul va scade
        timerCMD[playerid] = 0; // timpul va fi din nou 0
       
        if(contorCMD[playerid] == 0)// iar daca contorul va ajunge la 0 se va opri timer-ul
            KillTimer(timer[playerid]); // cu functia KillTimer
    }
}

 

Sper ca ti-a fost de folos hOpa # Hcs, si celorlalti.

  • Thanks 1
  • Upvote 5

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Link to comment
Share on other sites

  • 5 weeks 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.