Converting dcmd to zcmd -
_Outbreak_ - 07.05.2011
I'm looking at converting my commands from dcmd to zcmd. The way i have my commands at the moment, for admins and players makes it really easy to move commands.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(IsPlayerRegistered(playerid, name(playerid)) && PlayerNotSpawned[playerid])
return SendClientMessage(playerid, COLOR_RED, "You must spawn first before using commands.");
if(playerMod(playerid))
{
dcmd(ban,3,cmdtext);
}
if(playerAdmin(playerid))
{
dcmd(unban,5,cmdtext);
}
return 0;
}
That's a little example how my commands are laid out. So if I wanted to make ban a level 2 command I would just cut and paste "dcmd(ban,3,cmdtext);"
Is there a way i could do something like this with zcmd? I know the layout is different, and OnPlyerCommandText isn't used like it is in dcmd. I just don't really want to go to the command itself when i want to change who can use it, or for setting certain restrictions on command usages.
AW: Converting dcmd to zcmd -
Nero_3D - 07.05.2011
There is no other
good way for zcmd than putting the checks in the command itself (or I just dont know one)
Re: Converting dcmd to zcmd -
DRIFT_HUNTER - 07.05.2011
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(IsPlayerRegistered(playerid, name(playerid)) && PlayerNotSpawned[playerid] && success == 1)
return SendClientMessage(playerid, COLOR_RED, "You must spawn first before using commands.");
}
CMD:ban(playerid, params[])
{
if(playerMod(playerid)) return 0;
//ban cmd code here
return 1;
}
If you are using 0.3 server and ZCMD than OnPlayerCommandText is not called so we have two callback's
OnPlayerCommandPerformed(playerid, cmdtext[], success)
and
OnPlayerCommandReceived(playerid, cmdtext[])
Re: Converting dcmd to zcmd -
Calgon - 07.05.2011
OnPlayerCommandPerformed is executed AFTER the command executes, you would need to use OnPlayerCommandReceived instead.
Other than that, DRIFT_HUNTER has pointed out the only way that you can do this without trying to edit the zcmd include itself.
Re: Converting dcmd to zcmd -
DRIFT_HUNTER - 07.05.2011
Quote:
Originally Posted by Calg00ne
OnPlayerCommandPerformed is executed AFTER the command executes, you would need to use OnPlayerCommandReceived instead.
|
Didnt know that lol
But i think it will work that way...
Re: Converting dcmd to zcmd -
Calgon - 07.05.2011
You can't stop something after it's happened unless you can travel back in time... The same applies to this, you'd need to use OnPlayerCommandReceived, as that callback handles the returns and lets the command execute if you don't return 1 or 0 (I can't remember which return it expects).
Re: Converting dcmd to zcmd -
Artix - 17.05.2011
I think this might work
Quote:
CMD:unban(playerid,params[])
{
return 1;
}
|