[HELP] Team Chat Bugging? -
<Weponz> - 24.12.2010
I have a team chat command it works but only shows the letters after the 3rd one
eg.
It should show for /ar test:
pawn Код:
** Name [0] At [A-F Radio]: test
But shows:
pawn Код:
** Name [0] At [A-F Radio]:t
/ar testing looks like this:
pawn Код:
** Name [0] At [A-F Radio]:ting
Is
to much for inbetween strings?
Any help?
The code:
pawn Код:
CMD:ar(playerid, params[])
{
if(gTeam[playerid] == CLASS_AIRFORCE)
{
new output[100];
new string[100];
new pname[24];
if(!params[3]) return SendClientMessage(playerid, RED, "USAGE: /ao [msg]");
GetPlayerName(playerid, pname, 24);
strmid(output,params,3,strlen(params));
format(string, sizeof(string), "** %s [%d] At [A-F Radio]: %s",pname,playerid,output);
printf("%s", string);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(gTeam[i] == CLASS_AIRFORCE)
{
format(string, sizeof(string), "** %s [%d] At [A-F Radio]: %s",pname,playerid,output);
AirforceRadio(WHITE,string);
}
}
}
else
{
SendClientMessage(playerid, RED, "Only The Airforce Can Use This Radio!");
}
return true;
}
Thanks In Advanced!
Re: [HELP] Team Chat Bugging? -
xxmitsu - 24.12.2010
Try:
pawn Код:
#if !defined isnull
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
CMD:ar(playerid, params[])
{
if(gTeam[playerid] == CLASS_AIRFORCE)
{
new string[100], pname[24];
if(isnull(params)) return SendClientMessage(playerid, RED, "USAGE: /ar [msg]");
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "** %s [%d] At [A-F Radio]: %s",pname,playerid,params);
printf("%s", string);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(gTeam[i] == CLASS_AIRFORCE) AirforceRadio(WHITE,string);
}
} else SendClientMessage(playerid, RED, "Only The Airforce Can Use This Radio!");
return 1;
}
Re: [HELP] Team Chat Bugging? -
<Weponz> - 24.12.2010
@xxmitsu
Thanks dude the usage shows up now when i /ar but when i /ar test it does nothing,
Any help?
Re: [HELP] Team Chat Bugging? -
xxmitsu - 24.12.2010
Post your AirforceRadio(WHITE,string) function. What does it print server_log?
EDIT: Seems fine to me.. try using the code again.
Re: [HELP] Team Chat Bugging? -
<Weponz> - 24.12.2010
Its just a radio code so i can use the function elsewhere just replace it with SendClientMessage and should compile..
EDIT:
SendClientMessage(playerid,WHITE,string);
Re: [HELP] Team Chat Bugging? -
xxmitsu - 24.12.2010
AirforceRadio(WHITE,string) doesn't have the playerid parameter. How does it gets playerid to send the text ? another for(player... maxplayer..) ?
Re: [HELP] Team Chat Bugging? -
<Weponz> - 24.12.2010
Ok..
pawn Код:
AirforceRadio(colour,const string[])
{
for(new i = 0; i <= MAX_PLAYERS; i++)//Gets the MAX_PLAYERS and "calls" it "i"
{
if(IsPlayerConnected(i) == 1)//Checks that the Are connected
{
if(gTeam[i] == CLASS_AIRFORCE)//If there in CLASS_AIRFORCE
{
SendClientMessage(i, colour, string);//Send them w/e color they state in the string using AirforceRadio(colour, string);
}
}
}
return 1;
}
//basically formats the SendClientMessage function to AirforceRadio for a specific class so you can use it elsewhere
//eg.
//string bla bla bla
//AirforceRadio(w/e colour,string);
Thats all you need.
Now can u help fix my code plz?
Re: [HELP] Team Chat Bugging? -
xxmitsu - 24.12.2010
Well, then all you need shoul be:
pawn Код:
CMD:ar(playerid, params[])
{
if(gTeam[playerid] == CLASS_AIRFORCE)
{
new string[100], pname[24];
if(isnull(params)) return SendClientMessage(playerid, RED, "USAGE: /ar [msg]");
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "** %s [%d] At [A-F Radio]: %s",pname,playerid,params);
printf("%s", string);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i)) if(gTeam[i] == CLASS_AIRFORCE) SendClientMessage(i, WHITE, string);
}
} else SendClientMessage(playerid, RED, "Only The Airforce Can Use This Radio!");
return 1;
}
or
pawn Код:
CMD:ar(playerid, params[])
{
if(gTeam[playerid] == CLASS_AIRFORCE)
{
new string[100], pname[24];
if(isnull(params)) return SendClientMessage(playerid, RED, "USAGE: /ar [msg]");
GetPlayerName(playerid, pname, 24);
format(string, sizeof(string), "** %s [%d] At [A-F Radio]: %s",pname,playerid,params);
printf("%s", string);
AirforceRadio(WHITE,string);
} else SendClientMessage(playerid, RED, "Only The Airforce Can Use This Radio!");
return 1;
}
It's your choice.