/low won't work?
#1

This is my /low command:

pawn Код:
stock SendClosestMessage( playerid, color, const string[ ] )

{
    new
        Float: jPos[ 3 ]
    ;

    GetPlayerPos( playerid, jPos[ 0 ], jPos[ 1 ], jPos[ 2 ] );

    for ( new j = GetMaxPlayers( ), i; i < j; i ++ )
    {
        if ( !IsPlayerConnected( i ) )
            continue;

        if ( IsPlayerInRangeOfPoint( i, 7.0, jPos[ 0 ], jPos[ 1 ], jPos[ 2 ] ) )
        {
            SendClientMessage( i, color, string );
        }
    }

    return 1;
}

stock RemoveUnderScore(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/low", true, 3 ) )
    {
        if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
            return SendClientMessage( playerid, -1, "SERVER: /low <text>" );

        new
            tempString[ 128 ],
            pName[ 24 ]
        ;

        GetPlayerName( playerid, pName, sizeof pName );

        format( tempString, sizeof tempString, "*%s says [Low]: %s", RemoveUnderScore(playerid), cmdtext[ 3 ] );

        SendClosestMessage( playerid, COLOR_WHITE, tempString );

        return 1;
    }
    return 0;
}
Whenever I type just "/low" in-game, it comes up saying: "SERVER: /low <text>" which is perfectly fine. But whenever I add text to the command, say for example: "/low Hello" it will come up with: "SERVER: /low <text>"

Any help, please?
Reply
#2

Try it:
pawn Код:
if ( cmdtext[5] == ' ' )
Reply
#3

Yes! It worked, thanks! But it has one little error:

Whenever I speak IG, it shows up as: Gramercy_Riffs says [Low]:w Hello.

That little "w" was showing up, any ideas?
Reply
#4

Use cmdtext[5] on format instead of cmdtext[3].

See:
pawn Код:
The string "/low" contain 4 chars.
Variable structure: {'/', 'l', 'o', 'w' }
                      0    1    2    3
Reply
#5

Thank you.

In that case, would /shout be cmdtext[7]?
Reply
#6

Fixed! Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)