SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/11/2013, 01:38 AM   #1
0Z3ro0
Little Clucker
 
Join Date: Nov 2013
Location: USA, Michigan
Posts: 41
Reputation: 1
Question [Help] Command Script

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
0Z3ro0 is offline   Reply With Quote
Old 02/11/2013, 01:46 AM   #2
-Prodigy-
Huge Clucker
 
Join Date: Dec 2010
Posts: 398
Reputation: 45
Default Re: [Help] Command Script

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
-Prodigy- is offline   Reply With Quote
Old 02/11/2013, 01:51 AM   #3
SAMProductions
Huge Clucker
 
SAMProductions's Avatar
 
Join Date: Aug 2013
Location: /System32/
Posts: 413
Reputation: 27
Default Re: [Help] Command Script

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;
}
__________________


RAGE Paradise [CNR/CTF/RACE/FREEROAM/PARKOUR/ZOMBIE
•• Call Of Duty - BattleZone 2050 •• (0.3z)




Life is like riding a Bicycle,
You don’t fall off unless you plan to stop peddling.

We Are Anonymous, We Are Legions, We Do Not Forgive, We Do Not Forget, Expect Us.
SAMProductions is offline   Reply With Quote
Old 02/11/2013, 02:34 AM   #4
0Z3ro0
Little Clucker
 
Join Date: Nov 2013
Location: USA, Michigan
Posts: 41
Reputation: 1
Question Re: [Help] Command Script

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.
0Z3ro0 is offline   Reply With Quote
Old 02/11/2013, 05:09 AM   #5
0Z3ro0
Little Clucker
 
Join Date: Nov 2013
Location: USA, Michigan
Posts: 41
Reputation: 1
Default Re: [Help] Command Script

Bump.

Hello?
0Z3ro0 is offline   Reply With Quote
Old 02/11/2013, 05:15 AM   #6
LeeXian99
Huge Clucker
 
LeeXian99's Avatar
 
Join Date: Feb 2013
Location: Malaysia
Posts: 328
Reputation: 34
Default Re: [Help] Command Script

Mind post your script out again?
LeeXian99 is offline   Reply With Quote
Old 02/11/2013, 05:50 AM   #7
0Z3ro0
Little Clucker
 
Join Date: Nov 2013
Location: USA, Michigan
Posts: 41
Reputation: 1
Default Re: [Help] Command Script

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.
0Z3ro0 is offline   Reply With Quote
Old 02/11/2013, 06:15 AM   #8
LeeXian99
Huge Clucker
 
LeeXian99's Avatar
 
Join Date: Feb 2013
Location: Malaysia
Posts: 328
Reputation: 34
Default Re: [Help] Command Script

Did you remove
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])

If not, try to remove it.
LeeXian99 is offline   Reply With Quote
Old 02/11/2013, 06:26 AM   #9
JeaSon
Gangsta
 
JeaSon's Avatar
 
Join Date: Aug 2013
Location: Future
Posts: 558
Reputation: 79
Default Re: [Help] Command Script

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;
}
__________________
Again back
JeaSon is offline   Reply With Quote
Old 02/11/2013, 06:41 AM   #10
0Z3ro0
Little Clucker
 
Join Date: Nov 2013
Location: USA, Michigan
Posts: 41
Reputation: 1
Thumbs up Re: [Help] Command Script

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.
0Z3ro0 is offline   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
How to script this type of command? rangerxxll Scripting Help 1 16/10/2011 10:18 AM
(HELP)I need add command /dlicense (id) in this script spaty2 Help Archive 4 14/07/2011 05:32 PM
How to script ban and kick command? Hitman-97- Help Archive 5 19/05/2011 07:49 AM
How to name script a command? Jack- Help Archive 0 02/01/2011 05:28 PM
Local /me command script. Waynewayne Help Archive 17 13/03/2010 10:08 PM


All times are GMT. The time now is 06:43 AM.


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