about announced to see in the middle on the screen
#8

Quote:
Originally Posted by Amit B
Here's code for announce command from my DM gamemode (with some little edits):
pawn Код:
if((!strcmp(cmd,"/ann",true) || !strcmp(cmd,"/announce",true)) && IsPlayerAdmin(playerid))
    {
        new string[128];
        cmd = strrest(cmdtext,idx);
        if(!strlen(cmd)) return SendClientMessage(playerid,white," Usage: /announce(ann) [text]");
        GameTextForAll(string,5000,4);
        return 1;
    }
(Put it on OnPlayerCommandText)

If you get errors about the "cmd" or "idx" variable, put this at the bottom of your script:
pawn Код:
stock strtok(const string[], &index, somechar = ' ')
{  // by CompuPhase, improved by Amit_B
    new length = strlen(string), result[20];
    while((index < length) && (string[index] <= somechar)) index++;
    new offset = index;
    while((index < length) && (string[index] > somechar) && ((index - offset) < (sizeof(result) - 1))) result[index - offset] = string[index], index++;
    result[index - offset] = EOS;
    return result;
}
and this at the top of OnPlayerCommandText:
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext,idx);
And if you get errors about "strrest" put this too at the bottom of your script:
pawn Код:
stock strrest(const string[], index)
{  // by CompuPhase, improved by Amit_B
    new length = strlen(string), offset = index, result[M_S];
    while((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index - offset] = string[index], index++;
    result[index - offset] = EOS;
    if(result[0] == ' ' && string[0] != ' ') strdel(result,0,1);
    return result;
}
Enjoy
My code is better shorter and faster than this but what is the meaning of strrest?
string rest?
Reply


Messages In This Thread
about announced to see in the middle on the screen - by Sfinx_17 - 19.08.2009, 20:48
Re: about announced to see in the middle on the screen - by MatrixBoY - 19.08.2009, 20:51
Re: about announced to see in the middle on the screen - by Sfinx_17 - 19.08.2009, 21:16
Re: about announced to see in the middle on the screen - by Amit_B - 19.08.2009, 21:21
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 08:36
Re: about announced to see in the middle on the screen - by Dark_Kostas - 20.08.2009, 08:39
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 09:18
Re: about announced to see in the middle on the screen - by MenaceX^ - 20.08.2009, 09:27
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 11:39
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 11:43
Re: about announced to see in the middle on the screen - by MenaceX^ - 20.08.2009, 11:56
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 11:59
Re: about announced to see in the middle on the screen - by MenaceX^ - 20.08.2009, 12:17
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 12:19
Re: about announced to see in the middle on the screen - by Sfinx_17 - 20.08.2009, 12:53
Re: about announced to see in the middle on the screen - by EirikhO - 20.08.2009, 13:21
Re: about announced to see in the middle on the screen - by Doppeyy - 13.09.2009, 02:55

Forum Jump:


Users browsing this thread: 1 Guest(s)