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

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 ...
Reply
#2

use the instructions GameTextForPlayer
Reply
#3

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
Reply
#4

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
Reply
#5

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??
Reply
#6

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

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

new cmd[256], idx;
cmd = strtok(cmdtext,idx);
Reply
#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
#9

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
Reply
#10

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

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;
}
Reply
#12

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

OnPlayerCommandText.
Reply
#14

i tryed but i get errors
Reply
#15

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;
}
Reply
#16

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

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

/Artix
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)