Best way to get a players text -
Torran - 20.02.2010
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
Re: Best way to get a players text -
BlackFoX - 20.02.2010
Код:
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
Re: Best way to get a players text -
Torran - 20.02.2010
One question, Why [7] ??
Re: Best way to get a players text -
BlackFoX - 20.02.2010
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 )
Re: Best way to get a players text -
Torran - 20.02.2010
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
Re: Best way to get a players text -
Torran - 21.02.2010
Bumpety bump bump
Re: Best way to get a players text -
Rizard - 21.02.2010
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]);
}
}
Re: Best way to get a players text -
Nero_3D - 21.02.2010
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]);
}
}
Re: Best way to get a players text -
Torran - 21.02.2010
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
Re: Best way to get a players text -
Rzzr - 21.02.2010
The best and fastest way is using DCMD and sscanf.
https://sampwiki.blast.hk/wiki/Fast_Commands
https://sampwiki.blast.hk/wiki/Sscanf