[SOLVED] Switching from DCMD to ZCMD
#1

Well everyone is saying like 'Do you know ZCMD is faster?' I say yes I do know that, and they ask me why I don't change to it then.

This is the reason.
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
  if (!PLAYERLIST_authed[playerid]) {
    dcmd(login,5,cmdtext);          // because login has 5 characters
    dcmd(register,8,cmdtext);         // because register has 8 characters
    SendClientMessage(playerid,RED,"[ERROR] You have to login first before using commands.");
    return 1;
  }
  if (PLAYERLIST_authed[playerid]) {
    dcmd(rules,5,cmdtext);
    dcmd(stats,5,cmdtext);
    dcmd(help,4,cmdtext);
    dcmd(vehic,5,cmdtext);
    dcmd(me,2,cmdtext);
    dcmd(action,6,cmdtext);
    dcmd(do,2,cmdtext);
    dcmd(veh,3,cmdtext);
    dcmd(admins,6,cmdtext);
    dcmd(househelp,9,cmdtext);
      dcmd(houseinfo,9,cmdtext);
        dcmd(enter,5,cmdtext);
        dcmd(exit,4,cmdtext);
        dcmd(house,5,cmdtext);
        dcmd(lockhouse,9,cmdtext);
        dcmd(unlockhouse,11,cmdtext);
        dcmd(rentprice,9,cmdtext);
        dcmd(buyhouse,8,cmdtext);
        dcmd(sellhouse,9,cmdtext);
        dcmd(unsellhouse,11,cmdtext);
        dcmd(createhouse,11,cmdtext);
        dcmd(destroyhouse,12,cmdtext);
  }
  if (Faction[playerid] == 6) {
    dcmd(trace,5,cmdtext);
  }
  if(AdminLevel[playerid] >= 1 || IsPlayerAdmin(playerid)) {
    dcmd(respawncars,11,cmdtext);
    dcmd(settime,7,cmdtext);
    dcmd(clearchat,9,cmdtext);
    dcmd(spec,4,cmdtext);
    dcmd(gotoint,7,cmdtext);
    dcmd(specoff,7,cmdtext);
    dcmd(ahelp,5,cmdtext);
    dcmd(slap,4,cmdtext);
    dcmd(sslap,5,cmdtext);
    dcmd(freeze,6,cmdtext);
    dcmd(unfreeze,8,cmdtext);
    dcmd(gethere,7,cmdtext);
    dcmd(mute,4,cmdtext);
    dcmd(unmute,6,cmdtext);
    dcmd(ban,3,cmdtext);
    dcmd(goto,4,cmdtext);
  }
  if(AdminLevel[playerid] >= 2 || IsPlayerAdmin(playerid)) {
    dcmd(setha,5,cmdtext);
    dcmd(givegun,7,cmdtext);
    dcmd(freezeall,9,cmdtext);
    dcmd(unfreezeall,11,cmdtext);
    dcmd(setinterior,11,cmdtext);
    dcmd(announce,8,cmdtext);
    dcmd(setplayerskin,13,cmdtext);
  }
  if(AdminLevel[playerid] == 3 || IsPlayerAdmin(playerid)) {
    dcmd(makeadmin,9,cmdtext);
    dcmd(addveh,6,cmdtext);
    dcmd(gmx,3,cmdtext);
    dcmd(makeleader,10,cmdtext);
    dcmd(makedonator,11,cmdtext);
    dcmd(removeadmin,11,cmdtext);
    dcmd(givemoney,9,cmdtext);
  }
  else {
    return SendClientMessage(playerid,RED,"[ERROR] Insufficient access or wrong command.");
  }
  return SendClientMessage(playerid,RED,"[ERROR] Insufficient access or wrong command.");
}
This prevents me to put
pawn Код:
if(padmin[playerid] == 1)
and so on at every command. With one word, much faster that way to make a code.

Second I'd like to know if there's a fix for this. (I don't think there is one because then ZCMD would be the same as DCMD as ZCMD has CallLocalFunction and DMD doesn't, right?) I hope to get a response on this,

Thanks in advance!
Reply
#2

I'm pretty sure you can put that check at the top of OnPlayerCommandText (before the dcmds) to prevent that code from working.
Reply
#3

Well hmmmm I'll try to answer as much as I don't have a strong ability to piece together broken English (No offense)

Quote:

This prevents me to put if(padmin[playerid] == 1)

Sadly you would have to add that check under every command you create in Zcmd, if that was what you were asking/saying,

Quote:

Second I'd like to know if there's a fix for this. (I don't think there is one because then ZCMD would be the same as DCMD as ZCMD has CallLocalFunction and DMD doesn't, right?)

The only thing I could grasp was the part about the CallLocalFunction. That is what makes Zcmd better because using that makes it call the command you use directly instead of going down the list saying "is this it....uhhhh no. uhhhhh what about this one.....nope. this one?....nopers" until it finds the command you typed.

If this didn't exactly answer your questions can you please restate yourself and hopefully I or another will be able to answer you.
Reply
#4

Include the ZCMD include, ZCMD uses an alternative function for command responses, you'll need to remove the dcmd(xxx). There are two functions, one when the command is recieved and one when it has been performed.

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    return 1;
}

public OnPlayerCommandReceived(playerid, cmdtext[])
{
  return 1;
}
DCMD:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(afro, 4, cmdtext);
}

dcmd_afro(playerid, params[])
{
return 1;
}
With ZCMD:

pawn Код:
command(afro, playerid, params[])
{
return 1;
}
Just an example, to show you the difference. You should add level checks under the command, instead of the part where it's parsing the command.
Reply
#5

Alright, I'll restate myself :P

As many folks are saying, ZCMD is much faster then DCMD.

At the moment, I'am using DCMD. In the public
Код:
OnPlayerCommandText
I have stated some checks when a player enters that command. Like if the player is admin or not, it'll return the command or a negative message,

if I would switch to ZCMD, is there any possibility to do something similair to the public
Код:
OnPlayerCommandText
as stated at the top.

As CalgonX said these publics to use:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 1;
}

public OnPlayerCommandReceived(playerid, cmdtext[])
{
  return 1;
}
How will I use them?
Reply
#6

I clearly stated that you should move the actual checks into the command, instead.

pawn Код:
command(afro, playerid, params[])
{
if(GetPlayerTeam(playerid) == 69)
{
//yesyesyes
}
else
{
//nonon
}
}
Reply
#7

that's taking too much time to script it for each command, I want it to be as it is stated at the top.
Reply
#8

Well for the god knows how manyith time. You really can't do the checks outside of the commands because when you type a command Zcmd redirects DIRECTLY to the command so the only place where you can stop it is inside the command........besides it's 2 extra lines per command, not that big of a hassle probably 10 minutes per 10-20 commands. So if you have any OTHER questions regarding Zcmd then please don't hesitate to ask.

(Sorry if I sound like a dick, just trying to firmly state the above text.)
Reply
#9

Well, when I was using YSI, I got very confused with the if, else if, and else things. So I'll just stick with DCMD Thanks to the people who replied to this topic, considered as solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)