SA-MP Forums Archive
[HELP]ANTIFLOOD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]ANTIFLOOD (/showthread.php?tid=285876)



[HELP]ANTIFLOOD - TheBluec0de - 25.09.2011

dosent work, why ?

OnPlayerText:

Код:
new MCount[MAX_PLAYERS], MaxMessages = 2;
    if(MCount[playerid] < MaxMessages) MCount++;
    else return SendClientMessage(playerid, 0x00FF00AA, "Warning: To much messages at once, wait till someone else wrote something!"), 0;
error

Код:
C:\Users\***\Desktop\***\pawno\***(305) : error 022: must be lvalue (non-constant)
C:\Users\***\Desktop\****\pawno\****(305) : warning 215: expression has no effect



Re: [HELP]ANTIFLOOD - JaTochNietDan - 25.09.2011

What's with the little bit of code after SendClientMessage? That doesn't make any sense, it should be just:

pawn Код:
else return SendClientMessage(playerid, 0x00FF00AA, "Warning: To much messages at once, wait till someone else wrote something!");
What were you trying to achieve with that little bit of code after it?


Re: [HELP]ANTIFLOOD - TheBluec0de - 25.09.2011

Line 305:

Код:
if(MCount[playerid] < MaxMessages) MCount++;
Код:
error 022: must be lvalue (non-constant)
warning 215: expression has no effect



Re: [HELP]ANTIFLOOD - JaTochNietDan - 25.09.2011

Quote:
Originally Posted by TheBluec0de
Посмотреть сообщение
Line 305:

Код:
if(MCount[playerid] < MaxMessages) MCount++;
Код:
error 022: must be lvalue (non-constant)
warning 215: expression has no effect
Oh yeah, I didn't notice that. MCount is an array and you're not specifying a cell to increment the value of, you need to specify a cell, for example:

pawn Код:
MCount[playerid]++;



- TheBluec0de - 25.09.2011

so I put it like this?

Код:
    new MCount[MAX_PLAYERS], MaxMessages = 2;
    if(MCount[playerid] < MaxMessages) MCount[playerid]++;
    else return SendClientMessage(playerid, 0x00FF00AA, "Warning: To much messages at once, wait till someone else wrote something!");
EDIT: I tried it but it does not work ...


Re: [HELP]ANTIFLOOD - JaTochNietDan - 25.09.2011

Quote:
Originally Posted by TheBluec0de
Посмотреть сообщение
so I put it like this?

Код:
    new MCount[MAX_PLAYERS], MaxMessages = 2;
    if(MCount[playerid] < MaxMessages) MCount[playerid]++;
    else return SendClientMessage(playerid, 0x00FF00AA, "Warning: To much messages at once, wait till someone else wrote something!");
EDIT: I tried it but it does not work ...
What do you mean it doesn't work? It doesn't compile?


Re: [HELP]ANTIFLOOD - TheBluec0de - 25.09.2011

allows me to flood in the game, whereas it should not. compile successfully with no errors the Pawn.


Re: [HELP]ANTIFLOOD - JaTochNietDan - 25.09.2011

Okay, well lets see all of the code in that callback.


Re: [HELP]ANTIFLOOD - TheBluec0de - 25.09.2011

solved


Re: [HELP]ANTIFLOOD - JaTochNietDan - 25.09.2011

Well there's your problem, you're creating the MCount variable in the local scope of OnPlayerText so when OnPlayerText is finished, that variable is destroyed and so are any values that were stored in it. You need to create it out-side of the OnPlayerText callback.

I recommend you read through the PAWN documentation at Compuphase's webpage for PAWN!

http://www.compuphase.com/pawn/pawn.htm