Best way to get a players text
#1

I cant remember,
I think it was cmdtext[1] or something like that,
Well im making a command,
And i want to get what the player types after the command, Anyone know
Reply
#2

Код:
if(!strcmp(cmdtext,"/text",true,5))
{
if(!cmdtext[7])return SendClientMessage(playerid,0xFFFFFFFF,"use /text [text]");
return SendClientMessage(playerid,0xFFFFFFFF,cmdtext[7]);
}
Not the best but rly easy, you can use strtok Function from Compu Phase , i think thats the best Method
Reply
#3

One question, Why [7] ??
Reply
#4

The Text ,,/textґґ have a Length of 5 Characters , 6 is the Whitespace , 7 is your Text

cause SendClientMessage need at last Param a Char Array it will Send all Chars from Char 7 to End of Text ( \0 )
Reply
#5

Okay, One last question,
I want it to send it to teams,

How would i get it so i is a certain team,
Like i can remember doing it before,
Like:

if(gteam whatever
{
SendClientMessage(i

Or something like that, You should know what i mean, If not.. say
Reply
#6

Bumpety bump bump
Reply
#7

Something like this?

pawn Код:
#define TEAM_TEST 1

for(i=1;i<=MAX_PLAYERS;i++)
{
  if(gTeam[i] == 1)//had some problems in the past with gTeam .... try it anyway
  {
    SendClientMessage(i,0x222200FF,cmdtext[7]);
  }
}
Reply
#8

gTeam is just a variable (often used to store the teamid from each player)
Just check your script if it use a team variable or the native functions Set/GetPlayerTeam (just dont forget with that SetTeamCount)
With the native functions the friendly fire is disabled (so the team members cant kill themself)

And like Rizard said it would be

pawn Код:
for(new i; i < MAX_PLAYERS; i++) //playerids start at 0
{
  if(/*Teamvariable/GetPlayerTeam*/ == /*TEAMID*/) //or vice versa
  {
    SendClientMessage(i, 0x222200FF, cmdtext[7]);
  }
}
Reply
#9

I know im doing something wrong:

pawn Код:
if(!strcmp(cmdtext, "/r", true))
  {
  if(!cmdtext[7])
  {
    for(new i; i < MAX_PLAYERS; i++) //playerids start at 0
        {
        //if(GetPlayerTeam == TEAM_COP)
        //{
      SendClientMessage(i, 0x222200FF, cmdtext[7]);
    }
}
    return 1;
}
SERVER: UNKNOWN COMMAND
Reply
#10

The best and fastest way is using DCMD and sscanf.
https://sampwiki.blast.hk/wiki/Fast_Commands
https://sampwiki.blast.hk/wiki/Sscanf
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)