I dont get it!
#1

Hey, i am a scripting a /settalk command. and it dosent change. If you write /settalk it comes up a text USAGE:/settalk 1-5, and if i use settalk 1, it just comes up the usage text again. i dont get why.

Here is the /settalk command

pawn Код:
new cmdtext[128];
new idx;
command(settalk, playerid, params [])
{
    if(IsPlayerConnected(playerid))
    {
        new settalk[128];
        settalk = strtok(cmdtext, idx);
        if(!strlen(settalk))
        {
            SendClientMessage(playerid, WHITE, "USAGE: /settalk 1-5");
            return 1;
        }
        else if(strcmp(settalk,"1", true) == 0)
        {
            settalk1[playerid] = 1;
            SendClientMessage(playerid, WHITE, " Chat style has been set!");
        }
    }
    return 1;
}
And this is the chat function.

pawn Код:
else if(settalk1[playerid] == 1)
                            {
                                ApplyAnimation(playerid,"PED","WALK_DRUNK",4.1,1,1,1,1,1);
                                format( string, sizeof( string ), "%s says [%s Accent]: %s", UnderscoreToSpaceName( playerid ), Player[playerid][Accent], text);
                                NearByMessage( playerid, WHITE, string);
                                ICChatLog( string );
                            }
And when i compile, i dont get any errors, just two warnings.

Warning 1:
Код:
warning 219: local variable "cmdtext" shadows a variable at a preceding level
And this is the pawn code:
pawn Код:
#define                 DVEHMENU8                           2038
OPS: I dont know why that has to do with the code :S But i get a warning there.

Warning 2:
Код:
 warning 219: local variable "cmdtext" shadows a variable at a preceding level
And here is the pawn code:
pawn Код:
public OnPlayerCommandReceived( playerid, cmdtext[])
PS: I dont know what that have to do with it, the settalk cmd isnt even posted there.

This is the full OnPlayerCommandreceived script
pawn Код:
public OnPlayerCommandReceived( playerid, cmdtext[])
{
    if( IsPlayerConnectedEx( playerid ) )
    {
        if( Player[playerid][Muted] >= 1 )
        {
            SendClientMessage( playerid, WHITE, "You can't use any commands whilst you are muted." );
            return false;
        }
        else
        {

            /*if( strfind( cmdtext, "[myid]", true ) )
            {
                new tmpstr[ 4 ];
                format( tmpstr, sizeof( tmpstr ), "%d", playerid );
                cmdtext[ 128 ] = str_replace( "[myid]", tmpstr, cmdtext, substr_count( "[myid]", cmdtext ) );
            }*/


            if( Player[playerid][AdminLevel] >= 1 && strlen( Player[playerid][AdminName] ) == 0 )
            {
                SendClientMessage( playerid, WHITE, "You must have your admin name set first." );
                return false;
            }
            else
            {
                if( Player[playerid][AdminLevel] >= 1 && Player[playerid][PINAuth] == 0 )
                {
                    SendClientMessage( playerid, WHITE, "You must authenticate with your admin PIN first." );
                    return false;
                }
                else
                {
                    Player[playerid][SpamCount]++;

                    if( Player[playerid][SpamCount] >= 3 && Player[playerid][AdminLevel] >= 1 && Player[playerid][AdminLevel] < 5 )
                    {
                        if( strfind( cmdtext, "ban", true ) != -1 || strfind( cmdtext, "kick", true ) != -1 || strfind( cmdtext, "warn", true ) != -1 || strfind( cmdtext, "set", true ) != -1 )
                        {
                            new string[ 128 ], Name[ MAX_PLAYER_NAME ];
                            new hour, minute, second, day, year, month;
                            GetPlayerName( playerid, Name, sizeof( Name ) );
                            gettime( hour, minute, second );
                            getdate( year, month, day );
                            #pragma unused second
                            new IP[ 21 ];
                            GetPlayerIp( playerid, IP, sizeof( IP ) );
                            format( string, sizeof( string ), "%d/%d/%d | %d:%d | %s | %s | SPAMMING | System", day, month, year, hour, minute, IP, Name );
                            BanLog( string );
                            format( string, sizeof( string ), "Ban: %s has been auto-banned, defined reason: Spamming (ban/kick/warn/set).", Name);
                            SendClientMessageToAll( LIGHTRED, string );
                            Player[playerid][Banned] = 4;
                            Player[playerid][AdminDuty] = 0;
                            print( string );
                            Ban( playerid );
                            return false;
                        }
                        else
                        {
                            Kick( playerid );
                        }
                    }

                    if( substr_count( ".", cmdtext, true ) >= 3 && substr_count( ":", cmdtext, true ) >= 1 )
                    {
                        new string[ 128 ], tmp;
                        tmp = strfind( cmdtext, ":" );
                        if( tmp != -1 )
                        {
                            format( string, sizeof( string ), "WARNING: %s may be server-advertising (%s).", GetName( playerid ), cmdtext );
                            SendToAdmins( YELLOW, string, 1 );
                            return false;
                        }
                    }

                    if(CurGMX == 2)
                    {
                        SendClientMessage( playerid, WHITE, "Please wait until the server has completely restarted." );
                        return false;
                    }
                    else
                    {
                        if( Player[playerid][Tutorial] >= 1 && Player[playerid][AdminLevel] < 1)
                        {
                            SendClientMessage( playerid, WHITE, "You may not use commands whilst in the tutorial." );
                            return false;
                        }
                        else
                        {
                            printf( "[command] %s (%d) executes: %s", GetName( playerid ), playerid, cmdtext);
                            return true;
                        }
                    }
                }
            }
        }
    }
    else
    {
        SendClientMessage( playerid, WHITE, "Please authenticate first." );
        return false;
    }
}
Reply
#2

Dosent anyone know ? :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)