[HELP]ANTIFLOOD
#1

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
Reply
#2

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?
Reply
#3

Line 305:

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

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]++;
Reply
#5

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 ...
Reply
#6

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?
Reply
#7

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

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

solved
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)