Jump to content
  • 0

Anti spam


TheGodfather

Question

Salut, as vrea sa pun pe serverul meu un sistem de anti spam care sa fie pentru char, indiferent ca e doar scris sau comenzi. Am facut un timer doar ca indiferent ce as scrie imi tot spune ca trebuie sa astept 3 secunde chiar daca nu am mai scris nicio comanda pana atunci.

Link to comment
Share on other sites

Recommended Posts

  • 0
1 oră în urmă, TheGodfather a spus:

Salut, as vrea sa pun pe serverul meu un sistem de anti spam care sa fie pentru char, indiferent ca e doar scris sau comenzi. Am facut un timer doar ca indiferent ce as scrie imi tot spune ca trebuie sa astept 3 secunde chiar daca nu am mai scris nicio comanda pana atunci.

arata timerul cu problema

YouTube : Click

Discord : CosminAK47#8524

Link to comment
Share on other sites

  • 0

Am pus la task LocalTimer[1000] 
        if(antispam[i] > 0)
            antispam[i]--;

Cand jucatorul scrie ceva pe chat sau tasteaza o comanda, vreau sa primeasca deelay de 3 secunda dar nu reusesc nicicum...

Edited by TheGodfather
Link to comment
Share on other sites

  • 0

Poti face in felul asta:

new chatTime[MAX_PLAYERS];

OnPlayerConnect
{
	chatTime[playerid] = 0;
}

OnPlayerText
{
	// la inceput
	if((gettime() - chatTime[playerid]) < 3)
    {
        SendClientMessage(playerid, -1, "Te rugam sa astepti 3 secunde.");
    	return 0;
    }
    // la sfarsit
    chatTime[playerid] = gettime();
}

 

Link to comment
Share on other sites

  • 0
Acum 11 minute, iSkull a spus:

Poti face in felul asta:


new chatTime[MAX_PLAYERS];

OnPlayerConnect
{
	chatTime[playerid] = 0;
}

OnPlayerText
{
	// la inceput
	if((gettime() - chatTime[playerid]) < 3)
    {
        SendClientMessage(playerid, -1, "Te rugam sa astepti 3 secunde.");
    	return 0;
    }
    // la sfarsit
    chatTime[playerid] = gettime();
}

 

Merge pentru chat, dar pentru comenzi nu, de exemplu daca scriu /a 123 de mai multe trimite mesajul. Cum trebuie sa scriu aici SCMf(playerid, COLOR_LIGHTRED, "[Anti-Spam] Asteapta %d secunde.", antispam[playerid] - gettime()); ca sa imi arate fiecare secunda, gen 3 2 1?

Link to comment
Share on other sites

  • 0
Acum 1 minut, iSkull a spus:

Tu ai zis pentru chat, chatul nu are treaba cu acele comenzi, acolo trebuie sa ai onplayercommandperformed si trebuie alt anti spam

Cum pot face si pentru comenzi? Si sa imi arate secundele la SCMf(playerid, COLOR_LIGHTRED, "[Anti-Spam] Asteapta %d secunde.", antispam[playerid] - gettime());?

Link to comment
Share on other sites

  • 0
Acum 1 minut, TheGodfather a spus:

Cum pot face si pentru comenzi? Si sa imi arate secundele la SCMf(playerid, COLOR_LIGHTRED, "[Anti-Spam] Asteapta %d secunde.", antispam[playerid] - gettime());?

Faci alta variabila si restul e la fel

Link to comment
Share on other sites

  • 0
Acum 33 minute, iSkull a spus:

Faci alta variabila si restul e la fel

public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
    if((gettime() - antispam2[playerid]) < 3)
        {
            SCMf(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", antispam2[playerid] - gettime() + 3);
            return 0;
        }
    if(success) SpamCheck[playerid] = GetTickCount();
    if(!success) return SCM(playerid, COLOR_GREY, "ERROR: Unknown command!");
    antispam2[playerid] = gettime();
    return true;
}

Asta am la aceasta functie, de fiecare data cand tastez o comanda, indiferent ca e doar /a sau /a 123 imi da si mesajul unknown command si si mesajul de sus cu nu scrie...

Link to comment
Share on other sites

  • 0
Acum 1 minut, TheGodfather a spus:

public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
    if((gettime() - antispam2[playerid]) < 3)
        {
            SCMf(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", antispam2[playerid] - gettime() + 3);
            return 0;
        }
    if(success) SpamCheck[playerid] = GetTickCount();
    if(!success) return SCM(playerid, COLOR_GREY, "ERROR: Unknown command!");
    antispam2[playerid] = gettime();
    return true;
}

Asta am la aceasta functie, de fiecare data cand tastez o comanda, indiferent ca e doar /a sau /a 123 imi da si mesajul unknown command si si mesajul de sus cu nu scrie...

chatTime[playerid] = gettime() + 3; la onplayertext nu in format

E posibil sa ai onplayercommandtext

Link to comment
Share on other sites

  • 0
Acum 1 minut, iSkull a spus:

daca ai zcmd, incearca cu return 1 daca ai pawn cmd n are cum sa nu ti mearga return 0

Zcmd folosesc, am pus asa si la fel face.
public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
    if((gettime() - antispam2[playerid]) < 3)
        {
            SCMf(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", antispam2[playerid] - gettime());
            return 1;
        }
    if(success) SpamCheck[playerid] = GetTickCount();
    if(!success) return SCM(playerid, COLOR_GREY, "ERROR: Unknown command!");
    antispam2[playerid] = gettime() + 3;
    return true;
}

Link to comment
Share on other sites

  • 0
Acum 7 minute, iSkull a spus:

if(!success) return SCM(playerid, COLOR_GREY, "ERROR: Unknown command!"); 

asta zice tot, o poti sterge si pui return 0

Stai ca am vazut ca scrie SERVER: Unknown command! si eu in gamemode n-am niciunde mesajul asta, acolo scrie ERROR

Link to comment
Share on other sites

  • 0
Acum 1 minut, TheGodfather a spus:

Nu gasesc in niciun include, nu stiu ce are de arata mesajul ala

Dupa cum am mai zis, incearca return 1/return 0, daca nu treci pe pawn cmd, acolo pentru prescurtarea comenzii e alias

Altceva nu am ce sa fac pentru mesajul respectiv

 

Ex:

 

alias:test('te');

cmd:test(playerid, params[]) // cmd cu litere mici pe comanda

{

SendClientMessage(playerid, -1, "Welcome to server with pawn cmd.");

return 1;

}

Link to comment
Share on other sites

  • 0
Acum 8 minute, iSkull a spus:

Dupa cum am mai zis, incearca return 1/return 0, daca nu treci pe pawn cmd, acolo pentru prescurtarea comenzii e alias

Altceva nu am ce sa fac pentru mesajul respectiv

 

Ex:

 

alias:test('te');

cmd:test(playerid, params[]) // cmd cu litere mici pe comanda

{

SendClientMessage(playerid, -1, "Welcome to server with pawn cmd.");

return 1;

}

N-am idee de ce nu vrea, am pus in toate modurile. Iar de cmd, nu ma pun sa modific atatea comenzi dintr-un gm :))

Link to comment
Share on other sites

  • 0

Daca pun functia asta si o apelez separat la comanda merge bine, dar is 600+ comenzi in gm... pana le pun :l

function nomessage(playerid) {
    if(aspam[playerid] > 0)
        return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", aspam[playerid]);
    return 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
Answer this question...

×   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.