Jump to content

Recommended Posts

Posted

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 4

 

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

 

Posted

Bun tutorial +1

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 5 weeks later...

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.