Adding prefix to a const string[] ?
#1

Here are two functions I use frequently .. infact, to say the least I use them in all my Admin command .. and there's alot. So .. to make my life easier, I'd like to add a "prefix" of sorts to these that will be sent before the actual string.. here's the functions:

pawn Код:
stock MessageToMods(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 2) SendClientMessage(i, color, string);
    }
    return 1;
}

stock MessageToAdmins(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 3) SendClientMessage(i, color, string);
    }
    return 1;
}
Say I want to add the prefix "Admin Alert: " to them before the string itself .. is this how I would do it?

pawn Код:
stock MessageToAdmins(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      new str[128];
      format(str, sizeof(str), "Admin Message: %s", string);
        if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 3) SendClientMessage(i, color, str);
    }
    return 1;
}
Reply


Messages In This Thread
Adding prefix to a const string[] ? - by dcmd_crash - 27.04.2010, 22:02
Re: Adding prefix to a const string[] ? - by dice7 - 27.04.2010, 22:45
Re: Adding prefix to a const string[] ? - by dcmd_crash - 27.04.2010, 22:50
Re: Adding prefix to a const string[] ? - by Joe Staff - 27.04.2010, 22:57
Re: Adding prefix to a const string[] ? - by dcmd_crash - 27.04.2010, 23:23

Forum Jump:


Users browsing this thread: 1 Guest(s)