Command in module script not working:
#1

I'll cut the slack. I'm creating a modular script (split in modules: callbacks, commands, functions, enums) and I ran across a problem that I cannot seem to figure out.

I have the following command in Commands.pwn, in the directory
gamemodes\Folder\Players
.

pawn Код:
CMD:island(playerid, params[])
{
    SetPlayerPos(playerid, -699.1899,-7450.6929,37.9266);
    return 1;
}
Then, my Main.pwn file has the following (and much more, but I decided not to post everything):

pawn Код:
/*Zeex's command processor*/
#include <zcmd>

/* INIT PLAYER */
#include "../gamemodes/Folder/Players/Commands.pwn"
However, when I type the command /island in-game, the "Unknown command" error message is sent to me. What should I do to fix this?
Reply
#2

Код:
CMD:island(playerid,params[])
{
    SetPlayerPos(playerid, -699.1899,-7450.6929,37.9266);
    return 1;
}
Try Now.
Reply
#3

Well.. for me i don't use like that via the gamemodes folder. I'm using it via pawno/includes(put your .pwn file here) folder and then just put it like this.

pawn Код:
#include "scriptname.pwn"
Reply
#4

Quote:
Originally Posted by YanLanger
Посмотреть сообщение
Код:
CMD:island(playerid,params[])
{
    SetPlayerPos(playerid, -699.1899,-7450.6929,37.9266);
    return 1;
}
Try Now.
Removing a space didn't work, and the syntax is CMD:command(playerid, params[]) (or COMMAND instead of CMD).
Reply
#5

I had a similar issue when I started working in this way, because I was trying to compile it instead of saving.
Save the commands.pwn then compile the main.pwn and then try again.
Reply
#6

Quote:
Originally Posted by GC
Посмотреть сообщение
I had a similar issue when I started working in this way, because I was trying to compile it instead of saving.
Save the commands.pwn then compile the main.pwn and then try again.
I don't compile anything but the Main.pwn file, because that's what supposed to be compiled. Regardless, I did what you told me to and it still doesn't work: I'm given the 'unknown command' error.
Reply
#7

Do you have OnPlayerCommandText in your script? (Even if it's empty)
If so, make sure you don't have return 0;
Reply
#8

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Do you have OnPlayerCommandText in your script? (Even if it's empty)
If so, make sure you don't have return 0;
I usually remove that callback because I use zcmd, so I don't think that that callback is a problem. It's not in the gamemode. I added it now (returning 1, of course) and I still get the error.
Reply
#9

Oh if you remove it, then there should be no problem.
Reply
#10

Use Easy DeAMX (https://sampforum.blast.hk/showthread.php?tid=349160) to see if your code actually gets included, if it does, it's not the include part that is the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)