Command doesn't work
#1

Hello
Anyone can help me?
This command doesn't work. Why?
pawn Код:
CMD:gethelper(playerid, params[])
    {
        new tmp[256];
        new string[256];
        new idx;
        tmp = strtok(params, idx);
        if(sscanf(params, "ud",params[0],params[1])) return SendClientMessage(playerid, COLOR_WHITE, "Type: /gothelper [SLOT] [NAME]");
        if (Info[playerid][pAdmin] >= 4)
        {
            new stat;
            stat = params[0];
            switch (stat)
            {
                case 1:
                {
                    new file = ini_openFile("/helpers.ini");
                    INI_WriteString(file,"HELPER1",params[1]);
                    format(string, sizeof(string), "Helper1 is now:   %s", string);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    ini_closeFile(file);//
                }
                default:
                {
                    SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
                }
            }
        }
        return 1;
    }
Reply
#2

I did not understand..
What's the problem ?
Reply
#3

Quote:
Originally Posted by LeonRP
Посмотреть сообщение
I did not understand..
What's the problem ?
When i type the command nothing happens.
Reply
#4

Don't use strtok with sscanf and zcmd.

pawn Код:
CMD:gethelper(playerid, params[])
{
    new slot, name[MAX_PLAYER_NAME], string[126];
    if(sscanf(params, "us[45]", slot, name)) return SendClientMessage(playerid, COLOR_WHITE, "Type: /gethelper [SLOT] [NAME]");
    if (Info[playerid][pAdmin] >= 4)
    {
        switch (slot)
        {
            case 1:
            {
                new file = ini_openFile("/helpers.ini");
                INI_WriteString(file, "HELPER1", name);
                format(string, sizeof(string), "Helper1 is now:   %s", string);
                SendClientMessage(playerid, COLOR_WHITE, string);
                ini_closeFile(file);
            }
            default: SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
Don't use strtok with sscanf and zcmd.

pawn Код:
CMD:gethelper(playerid, params[])
{
    new slot, name[MAX_PLAYER_NAME], string[126];
    if(sscanf(params, "us[45]", slot, name)) return SendClientMessage(playerid, COLOR_WHITE, "Type: /gethelper [SLOT] [NAME]");
    if (Info[playerid][pAdmin] >= 4)
    {
        switch (slot)
        {
            case 1:
            {
                new file = ini_openFile("/helpers.ini");
                INI_WriteString(file, "HELPER1", name);
                format(string, sizeof(string), "Helper1 is now:   %s", string);
                SendClientMessage(playerid, COLOR_WHITE, string);
                ini_closeFile(file);
            }
            default: SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
        }
    }
    return 1;
}
When i type command [/gethelper SLOT NAME] i received message "Invalid ID"
Reply
#6

pawn Код:
CMD:gethelper(playerid, params[])
{
    new slot, name[MAX_PLAYER_NAME], string[126];
    if(sscanf(params, "ds[45]", slot, name)) return SendClientMessage(playerid, COLOR_WHITE, "Type: /gethelper [SLOT] [NAME]");
    if (Info[playerid][pAdmin] >= 4)
    {
        switch (slot)
        {
            case 1:
            {
                new file = ini_openFile("/helpers.ini");
                INI_WriteString(file, "HELPER1", name);
                format(string, sizeof(string), "Helper1 is now:   %s", string);
                SendClientMessage(playerid, COLOR_WHITE, string);
                ini_closeFile(file);
            }
            default: SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
pawn Код:
CMD:gethelper(playerid, params[])
{
    new slot, name[MAX_PLAYER_NAME], string[126];
    if(sscanf(params, "ds[45]", slot, name)) return SendClientMessage(playerid, COLOR_WHITE, "Type: /gethelper [SLOT] [NAME]");
    if (Info[playerid][pAdmin] >= 4)
    {
        switch (slot)
        {
            case 1:
            {
                new file = ini_openFile("/helpers.ini");
                INI_WriteString(file, "HELPER1", name);
                format(string, sizeof(string), "Helper1 is now:   %s", string);
                SendClientMessage(playerid, COLOR_WHITE, string);
                ini_closeFile(file);
            }
            default: SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
        }
    }
    return 1;
}
It's the same command .....
Reply
#8

It's not, try it, type /gethelper 1 name
Reply
#9

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
It's not, try it, type /gethelper 1 name
We changed the order so
pawn Код:
CMD:gethelper(playerid, params[])
    {
    new slot, name[MAX_PLAYER_NAME], string[126];
    if(sscanf(params, "ds[45]", slot, name)) return SendClientMessage(playerid, COLOR_WHITE, "Type: /gethelper [SLOT] [NAME]");
    if (Info[playerid][pAdmin] >= 4)
    {
        switch (slot)
        {
            case 1:
            {
                new INI:file = INI_Open("/helpers.ini");
                INI_WriteInt(file,"HELPER1",name); // On this line is error                    << << << <<====
                format(string, sizeof(string), "HELPER1 is now:   %s", name);
                SendClientMessage(playerid, COLOR_WHITE, string);
                INI_Close(file);
            }
            default: SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
        }
    }
    return 1;
    }
When i compile mode, reiceved this error
pawn Код:
C:\Documents and Settings\Johnny\Desktop\wdrp8.pwn(54010) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
What it's wrong?
Reply
#10

Change INI_WriteInt to INI_WriteString
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)