[Help] Command Script
#1

Hello everyone, as the title says I need help with my Command Script. I am using Pawno that came with the download of SAMP. I created a blank document and added the #define FILTERSCRIPT to tell the server what it is. Then I scrolled down to the public OnPlayerCommandText and began creating my commands. I have searched ****** several times, and by my eyes the code is correct 100%. But when entered in the game it says Server: Unknown Command.

Here is the funny part, the very first command in the list, is /test I have it set to print out "Everything is working, sir!". I did this as a test to see if the command script is working. It will print out the Everything is working and then on the next line also print out Server: Unknown Command. Naturally I assumed another FS was messing with it. So I removed all FS from the .cfg accept the commands one. I get the same result.

Here is the code for the entire FS created.

http://pastebin.com/Q3yNPJGB

And here is just the part the contains the commands.

http://pastebin.com/HAEpw7rh

I am not the greatest Java coder in the world. I will be the first to admit this, and while I am taking classes on it I am still learning. I need a little help is all. Thank you for your time and I hope to here from you soon.

-
0Z3ro0
Reply
#2

Well, since you are starting, I don't recommend you start writing your commands in OPCT, rather use ZCMD(ZCMD). Why? It's easier, faster and looks better.


Here's how you would make a cmd in zcmd:

pawn Code:
#include <a_samp>
#include <zcmd>

public OnFilterScriptInit()
{
    return 1;
}

//

CMD:test(playerid, params[])
{
    SendClientMessage(playerid, COLOR_WHITE, "Everything is working, Sir!");
    return 1;
}
That's it. Also, you don't use OPCT when using zcmd. I know this didn't answer your question, but just some food for thought

Also, this is not java
Reply
#3

Use ZCMD it is better,

[Include] zcmd 0.3.1 | Fast & Simple Command Processor (updated 30/10/2009)

By using ZCMD, it will makes Command easier to make.

By the way, Try This:

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/test",true, 5)==0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Everything is working, Sir!");
        return 1;
    }

    if(strcmp(cmdtext,"/fixme",true, 6)==0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle dumbass!");
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, COLOR_WHITE, "It was a close call, but we got her fixed up!");
        return 1;
    }
    if (strcmp("/heal", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid, 100.0);
        return 1;
    }
    if(strcmp(cmdtext,"/where", true)==0)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        return 1;
    }
    return 0;
}
or If it is not Working, Try This:

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/test",true, 10)==0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Everything is working, Sir!");
        return 1;
    }

    if(strcmp(cmdtext,"/fixme",true, 10)==0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle dumbass!");
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, COLOR_WHITE, "It was a close call, but we got her fixed up!");
        return 1;
    }
    if (strcmp("/heal", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid, 100.0);
        return 1;
    }
    if(strcmp(cmdtext,"/where", true, 10)==0)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        return 1;
    }
    return 0;
}
Reply
#4

When I try Zcmd this is what I get when compiling,

A:\Users\Administrator\Desktop\SAMP Server\filterscripts\commands2.pwn(129) : error 029: invalid expression, assumed zero
A:\Users\Administrator\Desktop\SAMP Server\filterscripts\commands2.pwn(129) : error 017: undefined symbol "cmd_test"
A:\Users\Administrator\Desktop\SAMP Server\filterscripts\commands2.pwn(129) : error 029: invalid expression, assumed zero
A:\Users\Administrator\Desktop\SAMP Server\filterscripts\commands2.pwn(129) : fatal error 107: too many error messages on one line

I added #include <zcmd> and I also have the zcmd.inc in the pawno include. Thank you both for your help, what should I do now? Googling these errors just tells me what they stand for.
Reply
#5

Bump.

Hello?
Reply
#6

Mind post your script out again?
Reply
#7

Quote:
Originally Posted by LeeXian99
View Post
Mind post your script out again?
How silly of me, here you go;

http://pastebin.com/bvk0FX55

That contains the code and error message on that code.
Reply
#8

Did you remove
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
If not, try to remove it.
Reply
#9

here its example

first you must download zcmd include and put it into ur pawno/include folder then compile

pawn Code:
//just examlpe
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>

//============Color Define Begin============
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA // - Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA
#define COLOR_YELLOWGREEN 0x9ACD32AA
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA
//============Color Define End============



#define FILTERSCRIPT
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

CMD:test(playerid,params[])
    {
        SendClientMessage(playerid, COLOR_WHITE, "Everything is working, Sir!");
        return 1;
    }
   
CMD:fixme(playerid,params[])
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle dumbass!");
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, COLOR_WHITE, "It was a close call, but we got her fixed up!");
        return 1;
    }
   
CMD:heal(playerid,params[])
    {
        SetPlayerHealth(playerid, 100.0);
        return 1;
    }
CMD:where(playerid,params[])
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        return 1;
}
Reply
#10

Quote:
Originally Posted by Namer
View Post
here its example

first you must download zcmd include and put it into ur pawno/include folder then compile

pawn Code:
//just examlpe
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>

//============Color Define Begin============
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA // - Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA
#define COLOR_YELLOWGREEN 0x9ACD32AA
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA
//============Color Define End============



#define FILTERSCRIPT
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

CMD:test(playerid,params[])
    {
        SendClientMessage(playerid, COLOR_WHITE, "Everything is working, Sir!");
        return 1;
    }
   
CMD:fixme(playerid,params[])
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle dumbass!");
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, COLOR_WHITE, "It was a close call, but we got her fixed up!");
        return 1;
    }
   
CMD:heal(playerid,params[])
    {
        SetPlayerHealth(playerid, 100.0);
        return 1;
    }
CMD:where(playerid,params[])
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        return 1;
}
Thank you a bunch! My zcmd code was correct but I keep putting it in the OnPlayerCommandText. When I put it under like you showed me, they all work now.

I am used to 0.3e where all the commands went inside OnPlayerCommandText. Thank you again for your help, I knew it was something simple that I had screwed up. I just needed an experienced coder like you to come along and point what it was out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)