Chuck Norris
#1

Hey guys i added chuck norris system and now it's giving this damn warning
pawn Код:
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(699) : error 017: undefined symbol "cmd"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(699) : error 017: undefined symbol "strtok"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(700) : error 017: undefined symbol "cmd"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(709) : error 017: undefined symbol "RandomMessages"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(709) : error 029: invalid expression, assumed zero
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(709) : warning 215: expression has no effect
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(710) : error 017: undefined symbol "RandomMessages"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(710) : warning 215: expression has no effect
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(710) : error 001: expected token: ";", but found "]"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(710) : error 029: invalid expression, assumed zero
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(710) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


9 Errors.
Script

pawn Код:
{
    new string[512 char];
    new sendername[MAX_PLAYER_NAME];
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/chucknorris", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(!IsPlayerAdmin(playerid))
            {
                SendClientMessage(playerid, 0xFF9900AA, "You are not authorized to use that command.");
                return 1;
            }
            new randMSG = random(sizeof(RandomMessages));
            SendClientMessageToAll(0xFF9900AA, RandomMessages[randMSG]);
            format(string, sizeof(string), "[ADMIN]: %s has Announced Chuck's Fact!.", sendername);
        }
        return 1;
    }
    return 0;
}
And yes pleaze tell me what was the problem?
Reply
#2

Someone Help ME? PLeaze
Reply
#3

replace cmd in cmdtext k:
Reply
#4

512 cells for a string? No, that's just too much, unless you're splitting a string that will cover the whole chat box, it's not recommended.

And there's no need for the 'char' in the string, and why did you format the string but not use it?

And you didn't define idx and cmd.

Fixed code:

pawn Код:
new RandomMessages[][] =
{
    "blabla",
    "blabla2",
    "blabla3",
    "blabla4",
    "blabla5",
    "blabla6",
    "blabla7",
    "blabla8",
    "blabla9",
    "blabla10"
};

public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[128], sendername[24],
    cmd[128], idx; // You forgot these.
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/chucknorris", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(!IsPlayerAdmin(playerid))
            {
                SendClientMessage(playerid, 0xFF9900AA, "You are not authorized to use that command.");
                return 1;
            }
            new randMSG = random(sizeof(RandomMessages));
            SendClientMessageToAll(0xFF9900AA, RandomMessages[randMSG]);
            format(string, sizeof(string), "[ADMIN]: %s has Announced Chuck's Fact!.", sendername);
            SendClientMessageToAll(0xFF9900AA, string);
        }
        return 1;
    }
    return 0;
}

strtok(const string[], &index)
{
    // taken out of pawn_lang.pdf, credits to CompuPhase
    new length = strlen(string);
    /* skip leading white space */
    while (index < length && string[index] <= ' ') index++;
    /* store the word letter for letter */
    new offset = index; /* save start position of token */
    new result[20]; /* string to store the word in */
    while (index < length
    && string[index] > ' '
    && index - offset < sizeof result - 1)
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS; /* zero-terminate the string */
    return result;
}
Works perfectly, but next time, I'd recommend you use zcmd + sscanf for improved speed, plus it's easier.
Reply
#5

pawn Код:
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(647) : error 017: undefined symbol "RandomMessages"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(647) : error 029: invalid expression, assumed zero
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(647) : warning 215: expression has no effect
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(648) : error 017: undefined symbol "RandomMessages"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(648) : warning 215: expression has no effect
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(648) : error 001: expected token: ";", but found "]"
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(648) : error 029: invalid expression, assumed zero
I:\Games\RockStar Game Gta San Andreas\Gta Sanandreas\My Script\gamemodes\My Script.pwn(648) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


6 Errors.
Really?Some Errors

pawn Код:
647)new randMSG = random(sizeof(RandomMessages));
648)           SendClientMessageToAll(0xFF9900AA, RandomMessages[randMSG]);
            format(string, sizeof(string), "[ADMIN]: %s has Announced Chuck's Fact!.", sendername);
            SendClientMessageToAll(0xFF9900AA, string);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)