02.06.2016, 09:08
Quote:
Maybe something like this
Code:
CMD:command(playerid, params[], cmd_id) Code:
public OnPlayerReceivedCommand(playerid, cmd_id, params[], bool:exists) { switch(cmd_id) { // CODE GOES HERE } } |
Here's what I had in mind.
- Not ignoring the return value of commands:
Allow commands to return whatever integer the scripter wants. Returning '0' would result in the default actions, the unknown command stuff.
You could also add a new parameter to the callback, a 'result'. The 'result' parameter would hold the value returned by the command.
- Add a function for disabling/enabling specific commands for specific players.
SetPlayerCommandAllowed or something similiar, parameters: (playerid, cmdname[], bool:allow)
Setting 'allow' to false would return '0' if the player used this command, otherwise the command would execute.
Or, you could add yet another parameter to the callback, 'bool:allowed'. You would set this to the value set by the scripter. Then we could easily handle what happens when a player used a command they aren't allowed to use.
pawn Code:
native SetPlayerCommandAllowed(playerid, cmdname[], bool:allow);
forward OnPlayerReceivedCommand(playerid, cmd[], params[], bool:exists, result, bool:allowed);