/amsg mutiple times?
#1

I have a command in my script, very simple but very anoyying:

/amsg (text)

the text appears, as it has to, but it appears more then once, sometimes 2 times, sometime 4 times...

Why the hell's that?
Reply
#2

Showing us your code might help
Reply
#3

PHP код:
 if(strcmp(cmd"/amsg"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if (
PlayerInfo[playerid][pAdmin] >= 3)
            {
                new 
length strlen(cmdtext);
                while ((
idx length) && (cmdtext[idx] <= ' '))
                {
                    
idx++;
                }
                new 
offset idx;
                new 
result[64];
                while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                {
                    
result[idx offset] = cmdtext[idx];
                    
idx++;
                }
                
result[idx offset] = EOS;
                if(!
strlen(result))
                {
                    
SendClientMessage(playeridCOLOR_LIGHTYELLOW2"[USAGE:] /amsg [Message]");
                    return 
1;
                }
                
format(stringsizeof(string), "Admin %s: %s",GetPlayerNameEx(playerid),result);
                for(new 
0MAX_PLAYERSi++)
                {
                    if(
IsPlayerConnected(i))
                    {
                        
SendClientMessageToAll(COLOR_GREEN,string);
                    }
                }
                return 
1;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_LIGHTYELLOW2"[ERROR:] Your not an administrator!");
                return 
1;
            }
        }
        return 
1;
    } 
Reply
#4

Try this:
Код:
if(strcmp(cmd, "/amsg", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] >= 3)
            {
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[64];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /amsg [Message]");
                    return 1;
                }
                format(string, sizeof(string), "Admin %s: %s",GetPlayerNameEx(playerid),result);
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        SendClientMessage(i, COLOR_GREEN,string);
                    }
                }
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] Your not an administrator!");
                return 1;
            }
        }
        return 1;
    }
Hope this helps
Reply
#5

Quote:
Originally Posted by AstonDA-G
Посмотреть сообщение
Try this:
Код:
if(strcmp(cmd, "/amsg", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] >= 3)
            {
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[64];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /amsg [Message]");
                    return 1;
                }
                format(string, sizeof(string), "Admin %s: %s",GetPlayerNameEx(playerid),result);
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        SendClientMessage(i, COLOR_GREEN,string);
                    }
                }
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] Your not an administrator!");
                return 1;
            }
        }
        return 1;
    }
Hope this helps
Thanks Worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)