OnPlayerCommandPerformed - PROBLEM
#1

Hello, I'm using this code, but don't work correctly:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(pLs[playerid][pBlock] > GetTickCount())
        return SendClientMessage(playerid, 0xFF0000FF, "Forbidden commands flood.");
       pLs[playerid][pBlock] = GetTickCount() + 3000;
    if(!success)
        return SendClientMessage(playerid, 0xFF0000FF, "Ops! Unknown Command!");
    return 1;
}
When the flood happens, the message is displayed but the command is executed along
Reply
#2

Go from:
pawn Код:
return SendClientMessage(playerid, 0xFF0000FF, "Forbidden commands flood.");
to
pawn Код:
return SendClientMessage(playerid, 0xFF0000FF, "Forbidden commands flood."), 0;
Reply
#3

But I've tried returning 0 and didn't work O.o

EDIT: Besides not working with return 0, the message "SERVER: Unknown Command." is displayed
Reply
#4

I think that you have add check for all the commands because that callback will called when command action is done. I may misunderstand that public also.
Reply
#5

All commands? I'm still not crazy... HAHAHAHAHAHA.

If I really need to put in all the commands, I have taken this system.
Reply
#6

Oh my fault. I should have told you to use "OnPlayerCommandReceived(playerid, cmdtext[])" instead. In this callback, if you return 0, the command won't be performed.

And forget what I said about returning 0 in "OnPlayerCommandPerformed(playerid, cmdtext[], success)" As that will actually return the default "Server: Unknown command." text.
Reply
#7

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(pLs[playerid][pBlock] > GetTickCount())
        return SendClientMessage(playerid, 0xFF0000FF, "Forbidden commands flood."), 0;
       pLs[playerid][pBlock] = GetTickCount() + 3000;
    return 1;
}
This?
Reply
#8

I think that should work. Can't gurantee, but try it out. The odds are better while using the actual callback that was made for denying a command to be performed.
Reply
#9

Yeah, very good. It worked perfectly.

Thank you very much
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)