SA-MP Forums Archive
about announced to see in the middle on the screen - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: about announced to see in the middle on the screen (/showthread.php?tid=92385)



about announced to see in the middle on the screen - Sfinx_17 - 19.08.2009

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 ...


Re: about announced to see in the middle on the screen - MatrixBoY - 19.08.2009

use the instructions GameTextForPlayer


Re: about announced to see in the middle on the screen - Sfinx_17 - 19.08.2009

i know that but that is another thing i guess....all i need is a code to put in my script to type everything i want...to appear in the middle of my screen like that"sfinx" name that is seen...please help me


Re: about announced to see in the middle on the screen - Amit_B - 19.08.2009

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


Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

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??


Re: about announced to see in the middle on the screen - Dark_Kostas - 20.08.2009

Quote:
Originally Posted by Amit B
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext,idx);
Why do you need 256cells when maximum is 128?

Quote:
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??
What errors do you get?


Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

this is all i have to put ?? and where to put this code??

new cmd[256], idx;
cmd = strtok(cmdtext,idx);


Re: about announced to see in the middle on the screen - MenaceX^ - 20.08.2009

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?


Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

that's bullshit!!! ...i get only errors i don't wanna crash my windows with someone who doesn't know how to make a code


Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

i want another code please someone who know and to explain me please i need help


Re: about announced to see in the middle on the screen - MenaceX^ - 20.08.2009

First of all, don't double post.
second, you can't request people to code for you here, as you're not at Script Request Thread.
I'll make you something, will not use some useless shit like Amit_B gave.
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;
}



Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

this code where i have to put MenaceX? please tell me


Re: about announced to see in the middle on the screen - MenaceX^ - 20.08.2009

OnPlayerCommandText.


Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

i tryed but i get errors


Re: about announced to see in the middle on the screen - Sfinx_17 - 20.08.2009

but i have to put all the code in OnPlayerCommandText?

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;
}


Re: about announced to see in the middle on the screen - EirikhO - 20.08.2009

You know, it helps to include the errors you get, not only saying "i get error".


Re: about announced to see in the middle on the screen - Doppeyy - 13.09.2009

Indeed post the errors you got.
And dont flame people for trying to help.

/Artix