19.08.2009, 20:48
how i can make a announce in game?? like this for example..
and i need the code to put in my script and where to put please ...
![](/imageshack/img207/3054/samp037p.png)
and i need the code to put in my script and where to put please ...
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;
}
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;
}
new cmd[256], idx;
cmd = strtok(cmdtext,idx);
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;
}
Originally Posted by Amit B
pawn Код:
|
Originally Posted by Sfinx_17
i tryed first code...i get errors...5 errors put you say to me if i get error then to put the other two codes? ok but then this first code with that 5 erros i have to remove first from script then to put that two codes??
|
Originally Posted by Amit B
Here's code for announce command from my DM gamemode (with some little edits):
pawn Код:
If you get errors about the "cmd" or "idx" variable, put this at the bottom of your script: pawn Код:
pawn Код:
pawn Код:
![]() |
new
sString[128];
if(!strcmp(cmdtext,"/ann",true))
{
if(!cmdtext[4]) return SendClientMessage(playerid,color,"Parameters: /ann [text]");
format(string,sizeof(string),"%s",cmdtext[5]);
GameTextForAll(string,5000,4);
return 1;
}