Adding a command problem
#1

Hi, I have a problem adding a command to my "team deathmatch" gamemode.
Can someone help me/add the command to my gamemode?
I appreciate any help!

This is the originally my "gamemode" - Which you can see "//process other commands"
But when I try to add the new command, I get a lot of errors.
Please help, ty.
pawn Код:
//------------------------------------------------------------------------------------------------------

public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new playermoney;
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new giveplayerid, moneys, idx;

    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/help", true) == 0) {
        SendPlayerFormattedText(playerid,"Las Venturas Deathmatch: Money Grub Coded By Jax and the SA-MP Team.",0);
        SendPlayerFormattedText(playerid,"Type: /objective : to find out what to do in this gamemode.",0);
        SendPlayerFormattedText(playerid,"Type: /givecash [playerid] [money-amount] to send money to other players.",0);
        SendPlayerFormattedText(playerid,"Type: /tips : to see some tips from the creator of the gamemode.", 0);
    return 1;
    }
    if(strcmp(cmd, "/objective", true) == 0) {
        SendPlayerFormattedText(playerid,"This gamemode is faily open, there's no specific win / endgame conditions to meet.",0);
        SendPlayerFormattedText(playerid,"In LVDM:Money Grub, when you kill a player, you will receive whatever money they have.",0);
        SendPlayerFormattedText(playerid,"Consequently, if you have lots of money, and you die, your killer gets your cash.",0);
        SendPlayerFormattedText(playerid,"However, you're not forced to kill players for money, you can always gamble in the", 0);
        SendPlayerFormattedText(playerid,"Casino's.", 0);
    return 1;
    }
    if(strcmp(cmd, "/tips", true) == 0) {
        SendPlayerFormattedText(playerid,"Spawning with just a desert eagle might sound lame, however the idea of this",0);
        SendPlayerFormattedText(playerid,"gamemode is to get some cash, get better guns, then go after whoever has the",0);
        SendPlayerFormattedText(playerid,"most cash. Once you've got the most cash, the idea is to stay alive(with the",0);
        SendPlayerFormattedText(playerid,"cash intact)until the game ends, simple right ?", 0);
    return 1;
    }

    if(strcmp(cmd, "/givecash", true) == 0) {
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = strval(tmp);

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);

        //printf("givecash_command: %d %d",giveplayerid,moneys);


        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }

    // PROCESS OTHER COMMANDS


    return 0;
}
This is the new command I want for my gamemode (Kinda like a /jail command, and I've added all the objects sucsessfully, I just cant make the command work)
I put the whole .pwn here:
pawn Код:
#include <a_samp>
new door;
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA


#define COLOR_RED 0xAA3333AA

#define COLOR_GREY 0xAFAFAFAA

#define COLOR_GREEN 0x33AA33AA

#define COLOR_YELLOW 0xFFFF00AA

#define COLOR_WHITE 0xFFFFFFAA

#define COLOR_BLUE 0x0000BBAA

#define COLOR_LIGHTBLUE 0x33CCFFAA

#define COLOR_ORANGE 0xFF9900AA

#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_LIMEGREEN 0x32CD32AA

#define COLOR_MIDNIGHTBLUE 0x191970AA

#define COLOR_MAROON 0x800000AA

#define COLOR_OLIVE 0x808000AA

#define COLOR_ORANGERED 0xFF4500AA

#define COLOR_PINK 0xFFC0CBAA

#define COLOR_SPRINGGREEN 0x00FF7FAA

#define COLOR_TOMATO 0xFF6347AA

#define COLOR_YELLOWGREEN 0x9ACD32AA

#define COLOR_MEDIUMAQUA 0x83BFBFAA

#define COLOR_MEDIUMMAGENTA 0x8B008BAA

#define COLOR_BRIGHTRED 0xDC143CAA

#define COLOR_SYSTEM 0xEFEFF7AA

#define COLOR_PURPLE 0x330066AA


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" jail made by cale");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else


#endif

public OnGameModeInit()
{
CreateObject(969, 2481.920654, -1662.276733, 12.410629, 0.0000, 0.0000, 277.3906);
CreateObject(969, 2490.467285, -1660.839478, 12.327827, 0.0000, 358.2811, 186.2903);
CreateObject(969, 2483.212402, -1670.867798, 12.402826, 0.0000, 359.1406, 318.5408);
CreateObject(969, 2485.501221, -1668.897217, 15.452816, 87.6625, 10.3132, 309.0871);
CreateObject(969, 2484.925537, -1661.584717, 15.560627, 91.1003, 32.6586, 248.0671);
CreateObject(969, 2487.844482, -1661.080566, 15.527813, 91.1003, 31.7992, 248.0671);
CreateObject(969, 2487.277588, -1666.721924, 15.402822, 91.1003, 29.2208, 291.0388);
CreateObject(969, 2488.957520, -1664.598022, 15.577820, 91.1003, 29.2208, 291.0388);
CreateObject(969, 2490.590088, -1660.637329, 15.577827, 91.1003, 29.2208, 248.9258);
CreateObject(969, 2498.165039, -1674.880127, 12.230127, 0.0000, 0.8594, 191.4461);
CreateObject(969, 2490.553223, -1660.875366, 12.277828, 0.0000, 359.1406, 279.1097);
CreateObject(2634, 2492.714600, -1669.627930, 13.480176, 0.0000, 0.0000, 327.3414);
CreateObject(1225, 2482.207275, -1662.126221, 12.749505, 0.0000, 0.0000, 0.0000);
CreateObject(1225, 2482.157471, -1662.126953, 13.824496, 0.0000, 0.0000, 0.0000);
CreateObject(1225, 2482.442871, -1662.809448, 12.721868, 0.0000, 0.0000, 0.0000);
CreateObject(1225, 2483.114990, -1662.078857, 12.741702, 0.0000, 0.0000, 0.0000);
CreateObject(969, 2503.541016, -1668.729126, 12.502831, 0.0000, 0.8594, 191.4461);
CreateObject(969, 2503.540527, -1668.837769, 12.529856, 0.0000, 0.8594, 301.3504);
CreateObject(969, 2498.163574, -1674.880371, 12.283159, 2.5783, 358.2811, 327.9927);
CreateObject(969, 2508.573975, -1676.614990, 12.713753, 0.0000, 359.1406, 185.3267);
CreateObject(969, 2494.252197, -1669.630127, 15.427835, 274.0563, 331.6386, 214.5467);
CreateObject(969, 2494.375244, -1669.417480, 15.202822, 274.0563, 311.8715, 222.2809);
CreateObject(969, 2496.936279, -1669.488525, 15.262341, 268.8997, 311.8715, 225.7187);
CreateObject(969, 2500.099121, -1668.879150, 15.115545, 274.0563, 310.1527, 223.9998);
CreateObject(969, 2503.150391, -1668.464600, 15.234543, 274.0563, 310.1527, 223.9998);
CreateObject(969, 2500.624268, -1670.890869, 15.003172, 274.0563, 326.4820, 272.9879);


door = CreateObject(2634, 2494.498779, -1670.283569, 13.480176, 0.0000, 0.0000, 331.6386);
}


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

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

public OnPlayerCommandText(playerid, cmdtext[])
            {
            new cmd[256];
            new idx;
            cmd = strtok(cmdtext, idx);

            //jail
            if (strcmp(cmd, "/grovejail", true) == 0)
            {
            if (IsPlayerAdmin(playerid))
            {
            new dir[256];
            dir = strtok(cmdtext, idx);

            if (!strlen(dir))
            {
            SendClientMessage(playerid, COLOR_RED, "USAGE: /grovejail [id]");
            return 1;
            }

            new giveplayerid = strval(dir);
            if (IsPlayerConnected(giveplayerid))
            {

            SetPlayerPos(giveplayerid, 2500.624268, -1670.890869, 15.003172);
            new giveplayername[MAX_PLAYER_NAME];
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            new senderplayername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, senderplayername, sizeof(senderplayername));
            new string[256];
            format(string, sizeof(string), " %s has been jailed", giveplayername);
            SendClientMessage(playerid, COLOR_GREEN, string);
            format(string, sizeof(string), "You Have Been Jailed by %s , ", senderplayername);
            SendClientMessage(giveplayerid, COLOR_GREEN, string);
            }
            else
            {
            new string[256];
            format(string, sizeof(string), " %d, is not an invalid player.", giveplayerid);
            SendClientMessage(playerid, COLOR_RED, string);
            }
            return 1;
            }
            else
            {
            SendClientMessage(playerid, COLOR_RED, "ADMIN ONLY!!!!!!!!");
            }
            }
//unjail
            if (strcmp(cmd, "/groveunjail", true) == 0)
            {
            if (IsPlayerAdmin(playerid))
            {
            new dir[256];
            dir = strtok(cmdtext, idx);

            if (!strlen(dir))
            {
            SendClientMessage(playerid, COLOR_RED, "USAGE: /groveunjail [id]");
            return 1;
            }

            new giveplayerid = strval(dir);
            if (IsPlayerConnected(giveplayerid))
            {
            SetPlayerInterior(giveplayerid, 0);
            SetPlayerPos(giveplayerid, 2500.624268, -1670.890869, 40.003172);
            GivePlayerMoney(giveplayerid, (0 - 2500));
            new giveplayername[MAX_PLAYER_NAME];
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            new senderplayername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, senderplayername, sizeof(senderplayername));
            new string[256];
            format(string, sizeof(string), "You Have Released %s from The Jail!", giveplayername);
            SendClientMessage(playerid, COLOR_GREEN, string);
            format(string, sizeof(string), "You have been set free and fined by %s for $2500!", senderplayername);
            SendClientMessage(giveplayerid, COLOR_GREEN, string);
            }
            else
            {
            new string[256];
            format(string, sizeof(string), "%d is not a valid id ", giveplayerid);
            SendClientMessage(playerid, COLOR_RED, string);
            }
            return 1;
            }
            else
            {
            SendClientMessage(playerid, COLOR_RED, "ADMINS ONLY!!!!!");
            }


            return 1;
            }







            if (strcmp(cmdtext, "/opendoor", true) == 0)
            {
            if(IsPlayerAdmin(playerid) == 1)
            {
            MoveObject(door, 2492.714600, -1669.627930, 13.480176, 30);

            SendClientMessage(playerid, 0xDEEE20FF, "The Door is opening");
            }
            else
            {
            SendClientMessage(playerid, 0xDEEE20FF, "you have to be an admin to do this");
            }
            return 1;
            }




            if (strcmp(cmdtext, "/closedoor", true) == 0)
            {
            if(IsPlayerAdmin(playerid) == 1)
            {
            MoveObject(door, 2494.498779, -1670.283569, 13.480176, 50);
            SendClientMessage(playerid, 0xDEEE20FF, "the door is closing.");
            }
            else
            {
            SendClientMessage(playerid, 0xDEEE20FF, "you have to be an admin to do this");
            }
            return 1;
            }

            if (strcmp(cmdtext, "/credits", true) == 0)
            {
            SendClientMessage(playerid, 0xDEEE20FF, "Jail made by cale");

            return 1;}

            return 0;
            }
            strtok(const string[], &index)
            {
            new length = strlen(string);
            while ((index < length) && (string[index] <= ' '))
            {
            index++;
            }

            new offset = index;
            new result[20];
            while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
            {
            result[index - offset] = string[index];
            index++;
            }
            result[index - offset] = EOS;
            return result;
            }
ANY IDEA HOW TO ADD THE COMMAND? PLEASE REPLY
Reply
#2

if(strcmp(cmdtext, "grovejail", true) == 0)
Reply
#3

ty, fixed it now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)