SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 16/08/2009, 10:32 AM   #21
kc
Gangsta
 
kc's Avatar
 
Join Date: Aug 2007
Posts: 618
Reputation: 115
Default Re: [INC] zcmd - simple command system [updated]

Quote:
Originally Posted by [MeTalgEaR
]
i do recommend u use dcmd instead its all out easier and more efficient for this type of thing although zcmd is good too
Err... no? The main reason to switch from dcmd to zcmd is that zcmd is MORE efficient than dcmd in a large percentage of cases.
kc is offline   Reply With Quote
Old 16/08/2009, 07:10 PM   #22
nuriel8833
High-roller
 
nuriel8833's Avatar
 
Join Date: Jun 2009
Location: Israel
Posts: 1,157
Reputation: 16
Default Re: [INC] zcmd - simple command system [updated]

Wait
is it like zcmd
__________________
Back to forums
Although I am not scripting much,only my gamemode on my free time

My works:
80.179.219.89:7778
[Tutorial] Kills Table BonusLast.fm
nuriel8833 is offline   Reply With Quote
Old 27/08/2009, 11:49 AM   #23
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,862
Reputation: 230
Default Re: [INC] zcmd v0.2.2

Hey.

I'm thinking about moving from dcmd to zcmd, but I have one problem.

My current OnPlayerCommandText looks like this:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(IsPlayerConnected(playerid) && gPlayerLogged[playerid] == 1)
    {
        ...
        dcmd(bla,3,cmdtext);
        ...
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"[INFO:] Your not logged in, therefore you can not use any commands.");
        SendClientMessage(playerid,COLOR_RED,"[INFO:] Type your password to register/login.");
        return 1;
    }
    return 0;
}

I want to keep that checks, so I use method from note #1 about manually calling ZCMD_ProcessCommand. I did that and made test command /lol. When I came IG and used /lol it did what it was supposed to do, but on the end it returned 0 (SERVER: Unknown command).

pawn Code:
zcmd(lol,playerid,params[])
{
   #pragma unused params
   SendClientMessage(playerid,COLOR_WHITE,"It works");
   return 1;
}

I deleted manual calling ZCMD_ProcessCommand and left my default OnPlayerCommandText and everything worked fine (checks from OnPlayerCommandText were called and it didn't returned 0 on the end). I don't know if this is the best solution, so I would like to use that with manual calling more likely.

So what am I doing wrong here?
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 27/08/2009, 12:12 PM   #24
Zeex
Guest
 
Posts: n/a
Default Re: [INC] zcmd v0.2.2

Hi
If you want manually call ZCMD_ProcessCommand
pawn Code:
#define ZCMD_NO_CALLBACK

#include <zcmd>

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (IsPlayerConnected(playerid) && gPlayerLogged[playerid] == 1)
    {
        return ZCMD_ProcessCommand(playerid, cmdtext);
    }
    SendClientMessage(playerid,COLOR_RED,"[INFO:] Your not logged in, therefore you can not use any commands.");
    SendClientMessage(playerid,COLOR_RED,"[INFO:] Type your password to register/login.");
    return 1;
}
but if you don't:
pawn Code:
#include <zcmd>


public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!IsPlayerConnected(playerid) || gPlayerLogged[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"[INFO:] Your not logged in, therefore you can not use any commands.");
        SendClientMessage(playerid,COLOR_RED,"[INFO:] Type your password to register/login.");
        return 1;
    }
    return 0;
}
  Reply With Quote
Old 27/08/2009, 12:17 PM   #25
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,862
Reputation: 230
Default Re: [INC] zcmd v0.2.2

Ah what a stupid mistake.
In first post it only says
Code:
  ...
  ZCMD_ProcessCommand(playerid, cmdtext);
  ...
so I didn't think about returning that

But second solution seems simplier, so I will be using that one.

Thanks for help.

----------------------------------------------
I'd like to make that for example when you type /l and /local it does the same thing. With dcmd I did like this:
pawn Code:
dcmd_l(playerid, params[])
{
    return dcmd_local(playerid, params);
}
If I try to do this with zcmd I get errors like:
Quote:
...(5560) : error 029: invalid expression, assumed zero
...(5560) : error 029: invalid expression, assumed zero
...(5561) : warning 209: function "zcmd_local" should return a value
What's the right way of doing that with zcmd?
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 27/08/2009, 03:25 PM   #26
Zeex
Guest
 
Posts: n/a
Default Re: [INC] zcmd v0.2.2

Do you have return 1; at the end of zcmd_local(...) ?
  Reply With Quote
Old 27/08/2009, 09:15 PM   #27
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,862
Reputation: 230
Default Re: [INC] zcmd v0.2.2

All my commands end with 'return 1;'.

-----------------------------
Fixed it.

I had like this:
pawn Code:
zcmd(l,playerid,params[])
{
    return zcmd(local,playerid, params);
}
zcmd(local,playerid,cmdtext[])
{
     ....
     return 1;
}

but I have changed to this and it works:
pawn Code:
zcmd(l,playerid,params[])
{
    return zcmd_local(playerid, params);
}
zcmd(local,playerid,cmdtext[])
{
     ....
     return 1;
}
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 28/08/2009, 03:01 PM   #28
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: [INC] zcmd v0.2.2

A good release. Also it doesn't use strcmp which is bugged.
MenaceX^ is offline   Reply With Quote
Old 29/08/2009, 03:11 PM   #29
member
Huge Clucker
 
Join Date: Sep 2007
Posts: 365
Reputation: 0
Default Re: [INC] zcmd v0.2.2

Hi guys, i was recommended to try out zcmd, as i'm thinking of converting my commands which use the old and slow version (strcmp).

Only thing is, i don't know fully how to use it, and need some guidance. So far I've added the Include:
pawn Code:
#include <zcmd>

And I've added the function for the command as was given in the example on the first post.

pawn Code:
zcmd(mycommand, playerid, params[])
{
  // Do something
  return 1;
}

Am i correct in saying that the above should not be in the OnPlayerCommandText callback?

Right, now that I have that, how do i make a command with multiple parameters for instance, can someone give me an example of lets say, /givemoney <playerid> <amount> command. I haven't worked with dcmd either which may have helped, and also do i need Sscanf?

Thanks ur help is much appreciated.
member is offline   Reply With Quote
Old 29/08/2009, 03:45 PM   #30
Zeex
Guest
 
Posts: n/a
Default Re: [INC] zcmd v0.2.2

Hi
Quote:
Originally Posted by [B2K
Hustler ]
pawn Code:
zcmd(mycommand, playerid, params[])
{
  // Do something
  return 1;
}
Am i correct in saying that the above should not be in the OnPlayerCommandText callback?
Yes, it should be declared as separate function.
Quote:
Originally Posted by [B2K
Hustler ]
Right, now that I have that, how do i make a command with multiple parameters for instance, can someone give me an example of lets say, /givemoney <playerid> <amount> command. I haven't worked with dcmd either which may have helped, and also do i need Sscanf?
and yes, if you want create a command with multiple parameters it's recommended to use sscanf.

With zcmd and sscanf /givemoney will look like:
pawn Code:
#include <zcmd>
#include <sscanf>

zcmd(givemoney, byplayerid, params[]) // btw, it doesn't matter how last 2 parameters are named
{
    new
      playerid,
      money;
    if (!sscanf(params, "ii", playerid, money)) // sscanf returns 0 on success
    {
      new
        message[50];
      GivePlayerMoney(playerid, money);
      format(message, sizeof(message), "You got $%d from %s", money, ReturnPlayerName(byplayerid));
      SendClientMessage(playerid, 0x00FF00FF, message);
      format(message, sizeof(message), "You gave $%d to %s", money, ReturnPlayerName(playerid));
      SendClientMessage(byplayerid, 0xFFFF00FF, message);
    }
    else SendClientMessage(byplayerid, 0xFFFFFFFF, "Usage: /givemoney <playerid> <amount>");
    return 1;
}
I used ReturnPlayerName in this example which is not native but very useful, if you want use it you may take it here
  Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HowTo] Fast command processor: DCMD (0.3 Ready) DracoBlue Help Archive 8 28/11/2010 11:13 AM
fast command processor [mad]MLK Help Archive 1 22/08/2009 01:32 AM
Fast rcon command processor: RCMD (modified DCMD) Correlli Filterscripts 7 01/08/2009 12:02 PM
[INC+FS] Aero File Processor by Luby * Updated! luby Filterscripts 15 14/05/2009 01:07 PM


All times are GMT. The time now is 08:41 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.