Emergency services radio
#1

Whats wrong with this? It breaks my register system

pawn Код:
if(!strcmp(cmdtext, "/e ", true, 3))
    {
        if (gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_WSPD || gTeam[playerid] == TEAM_FBI || gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_FIREMAN)
        {
            if(!strlen(cmdtext[3]))
            {
                SendClientMessage(playerid,COLOR_GREY, "USAGE: /e [text]");
                return 1;
            }
            GetPlayerName(playerid,player,sizeof(player));
            format(string,sizeof(string),"*Radio %s(%i):%s, over",player,playerid,cmdtext[2]);
            SendCopMessage(COLOR_BLUE, string);
            return 1;
        }
Reply
#2

Have you tried removing it and rewriting it with efficient includes provided now-a-days?

Strcmp is a really old method when it comes to creating commands, and is not that efficient anymore.

TRY y_cmds or zcmd w/ sscanf.
Reply
#3

I don't know why, but try :

pawn Код:
if ( !strcmp( cmdtext, "/e", true, 2 ) )
{
    if ( gTeam[ playerid ] == TEAM_COP || gTeam[ playerid ] == TEAM_WSPD || gTeam[ playerid ] == TEAM_FBI || gTeam[ playerid ] == TEAM_MEDIC || gTeam[ playerid ] == TEAM_FIREMAN )
    {
        if ( cmdtext[ 2 ] != ' ' || !cmdtext[ 3 ] )
            return SendClientMessage( playerid, -1, "{FF0000}USAGE: {AAAAAA}/e [ text ]" );

        new
            tempName[ 24 ],
            tempString[ 128 ]
        ;

        GetPlayerName( playerid, tempName, sizeof ( tempName );

        format( tempString, sizeof ( tempString ), "* Radio %s( %i ): %s, over.", tempName, playerid, cmdtext[ 2 ] );

        SendCopMessage( COLOR_BLUE, string );

        return 1;
    }
    else return SendClientMessage( playerid, -1, "{FF0000}ERROR: {AAAAAA}You are not in the correct team." );

    return 1;
}
Or, somethings wrong with the SendCopMessage function?

pawn Код:
stock SendCopMessage( color, const string[ ] )
{
    for ( new j = GetMaxPlayers( ), i; i < j; i ++ )
    {
        if ( !IsPlayerConnected( i ) )
            continue;

        if ( gTeam[ i ] == TEAM_COP || gTeam[ i ] == TEAM_WSPD || gTeam[ i ] == TEAM_FBI || gTeam[ i ] == TEAM_MEDIC || gTeam[ i ] == TEAM_FIREMAN )
        {
            SendClientMessage( i, color, string );
        }
    }

    return 1;
}
EDIT: Just added an example of a "SendCopMessage function".
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)