strtok problems
#1

Hello, currently i got some troubles with strtok. I am scripting a stunt server. And well, i get this errors.

Код:
error 017: undefined symbol "strtok"
invalid expression, assumed zero
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
This is the line where the errors are on:

pawn Код:
strtok(const string[], &index)
This is my OnGameModeInit code, Where the strtok code is on:

pawn Код:
public OnGameModeInit()
{
    new string[MAX_PLAYER_NAME];
    SetGameModeText("WW-Stunts Beta");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 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;
    }
    return 1;
    }
}
Cant find what the problem is, Anybody knows?

Thanks, Alex
Reply
#2

Wrong; AddPlayerClass is a function, not a statement.
strtok shouldn't be placed in a callback. Fixed script:

pawn Код:
public OnGameModeInit()
{
    new string[MAX_PLAYER_NAME];
    SetGameModeText("WW-Stunts Beta");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

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;
}
That should be okay
Reply
#3

EDIT: To late.
Reply
#4

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Wrong; AddPlayerClass is a function, not a statement.
strtok shouldn't be placed in a callback. Fixed script:

pawn Код:
public OnGameModeInit()
{
    new string[MAX_PLAYER_NAME];
    SetGameModeText("WW-Stunts Beta");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

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;
}
That should be okay
lol fail Well thanks :P Didnt see that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)