OnPlayerCommandPerformed - PROBLEM -
SuperChock - 27.12.2011
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
Re: OnPlayerCommandPerformed - PROBLEM -
Mikkel_Pedersen - 27.12.2011
Go from:
pawn Код:
return SendClientMessage(playerid, 0xFF0000FF, "Forbidden commands flood.");
to
pawn Код:
return SendClientMessage(playerid, 0xFF0000FF, "Forbidden commands flood."), 0;
Re: OnPlayerCommandPerformed - PROBLEM -
SuperChock - 27.12.2011
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
Re: OnPlayerCommandPerformed - PROBLEM -
BrandyPenguin - 27.12.2011
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.
Re: OnPlayerCommandPerformed - PROBLEM -
SuperChock - 27.12.2011
All commands? I'm still not crazy... HAHAHAHAHAHA.
If I really need to put in all the commands, I have taken this system.
Re: OnPlayerCommandPerformed - PROBLEM -
Mikkel_Pedersen - 27.12.2011
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.
Re: OnPlayerCommandPerformed - PROBLEM -
SuperChock - 27.12.2011
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?
Re: OnPlayerCommandPerformed - PROBLEM -
Mikkel_Pedersen - 27.12.2011
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.
Re: OnPlayerCommandPerformed - PROBLEM -
SuperChock - 27.12.2011
Yeah, very good. It worked perfectly.
Thank you very much