Whats wrong with this?
#1

Whats wrong with this GM so far??


http://pastebin.com/SL4K2bP6


Everything returns Unknown command
Reply
#2

Open up pawno and click New. Select-all and delete everything.

Copy this:
pawn Код:
/**********************************
 *                *
 *  @Author:   ZeeX      *
 *  @Version:   0.3.1     *
 *  @Released:  31/10/2009   *
 *                *
 **********************************/


#if defined _zcmd_included
    #endinput
#endif 
#define _zcmd_included

#define MAX_FUNC_NAME (32)

#define COMMAND:%1(%2)     \
            forward cmd_%1(%2); \
            public cmd_%1(%2)      
           
#define CMD:%1(%2) \
            COMMAND:%1(%2)

#define command(%1,%2,%3) \
            COMMAND:%1(%2, %3)  
   
#define cmd(%1,%2,%3) \
            COMMAND:%1(%2, %3)

#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif


forward OnPlayerCommandReceived(playerid, cmdtext[]);
forward OnPlayerCommandPerformed(playerid, cmdtext[], success);


static
    bool:zcmd_g_HasOPCS = false,
    bool:zcmd_g_HasOPCE = false;

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    zcmd_g_HasOPCS = funcidx("OnPlayerCommandReceived") != -1;
    zcmd_g_HasOPCE = funcidx("OnPlayerCommandPerformed") != -1;
  return CallLocalFunction("zcmd_OnFilterScriptInit", "");
}

#if defined _ALS_OnFilterScriptInit
  #undef OnFilterScriptInit
#else
  #define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit zcmd_OnFilterScriptInit
forward zcmd_OnFilterScriptInit();

#else /*not a filterscript*/

public OnGameModeInit()
{
    zcmd_g_HasOPCS = funcidx("OnPlayerCommandReceived") != -1;
    zcmd_g_HasOPCE = funcidx("OnPlayerCommandPerformed") != -1;
    if (funcidx("zcmd_OnGameModeInit") != -1)
    {
        return CallLocalFunction("zcmd_OnGameModeInit", "");
    }  
    return 1;
}

#if defined _ALS_OnGameModeInit
  #undef OnGameModeInit
#else
  #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit zcmd_OnGameModeInit
forward zcmd_OnGameModeInit();

#endif /*if defined FILTERSCRIPT*/

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (zcmd_g_HasOPCS && !CallLocalFunction("OnPlayerCommandReceived", "is", playerid, cmdtext))
  {
    return 1;
  }
  new
    pos,
    funcname[MAX_FUNC_NAME];
  while (cmdtext[++pos] > ' ')
    {
        funcname[pos-1] = tolower(cmdtext[pos]);
    }
    format(funcname, sizeof(funcname), "cmd_%s", funcname);
  while (cmdtext[pos] == ' ') pos++;
    if (!cmdtext[pos])
    {
        if (zcmd_g_HasOPCE)
        {
            return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, "\1"));
        }
        return CallLocalFunction(funcname, "is", playerid, "\1");  
    }
    if (zcmd_g_HasOPCE)
    {
        return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos]));
    }
    return CallLocalFunction(funcname, "is", playerid, cmdtext[pos]);
}

#if defined _ALS_OnPlayerCommandText
  #undef OnPlayerCommandText
#else
  #define _ALS_OnPlayerCommandText
#endif
#define OnPlayerCommandText zcmd_OnPlayerCommandText
forward zcmd_OnPlayerCommandText(playerid, cmdtext[]);
Click Save, and go to /.../pawno/Include/ and click on the drop down menu and select All Files and name this zcmd.inc. Click Yes.

Go into your script and delete OnPlayerCommandText. Some reason OnPlayerCommandText doesn't work with zcmd in it in 0.3.
Reply
#3

Should you possibly define it as a filterscript? If you're using it as a filterscript.. Remember to add it in the server.cfg
Reply
#4

Quote:
Originally Posted by Jay420
Should you possibly define it as a filterscript? If you're using it as a filterscript.. Remember to add it in the server.cfg
Oh sorry i ment GM. I only added one thing so far and it all returns "Unknown command" anyone help?
Reply
#5

I find I get problems like that whenever I use zcmd and put my commands as CMD:mycmd, but it works as zcmd(mycmd, playerid, params[]) for some reason.

EDIT: You also can't use OnPlayerCommandText with zcmd.
Reply
#6

I did not use onplayercommandtext with Zcmd.


It's on top of it (right before it) It was working fine before, now it's not.. I'm not sure why.
Reply
#7

You can't use the OnPlayerCommandText function if you included the zcmd include file. So change the OnPlayerCommandText to "OnPlayerCommandRecieved( playerid, cmdtext, success )" .
Reply
#8

Yeah, we mean you cant use the actual callback itself. Even then OnPlayerCommandReceived doesn't work properly for me, so I just converted all my commands to zcmd.

As I said, try using them with the format
pawn Код:
zcmd(mycmd, playerid, params[])
{
  //code
  return 1;
}
Reply
#9

I'm not sure how to convert my code into Zcmd, so i followed what the other guy said to change my Onplayercommandtext.



Now, Everytime i type a command lets say /cuff, it works but it also says "Unknown command"


http://pastebin.com/Wmxeiw9L
Reply
#10

Quote:
Originally Posted by ruckfules99
I'm not sure how to convert my code into Zcmd
[quote=biltong ]
pawn Код:
zcmd(mycmd, playerid, params[])
{
  //code
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)