why no show up? -
TheDiscussionCafe - 10.05.2012
hi everyone. i have this for my police radio code:
pawn Код:
CMD:policeradio(playerid, params[]) {
if(isnull(params))
return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");
if(gTeam[playerid] !=Team_Police)
return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");
new
szMessage[128],
szPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && gTeam[playerid] !=Team_Police)
SendClientMessage(playerid, 0, szMessage);
}
return 1;
}
all everything works but wen i type in /policeradio , and im a cop , the message just dont show up? why?
Re: why no show up? -
IceCube! - 10.05.2012
!= means fails to equal change it to ==
== means it equals that exact number no higher no lower
if(IsPlayerConnected(i) && gTeam[playerid] ==Team_Police)
Re: why no show up? -
Yuryfury - 10.05.2012
pawn Код:
CMD:policeradio(playerid, params[]) {
if(isnull(params))
return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");
if(gTeam[playerid] !=Team_Police)
return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");
new
szMessage[128],
szPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && gTeam[playerid] ==Team_Police)// you were sending it to people who were NOT Team_Police
SendClientMessage(playerid, 0, szMessage);
}
return 1;
}
As stated in the comment, you were sending the message to people who were NOT Team_Police.
Re: why no show up? -
IceCube! - 10.05.2012
Thanks for copying exactly what I put above
Re: why no show up? -
Yuryfury - 10.05.2012
Meh, you beat me to it. :P
Re: why no show up? -
TheDiscussionCafe - 10.05.2012
no that dont work. it now only work for civilian and other players and wen civilian and other players type /policeradio [message] it doesnt show.
Re: why no show up? -
Yuryfury - 11.05.2012
pawn Код:
CMD:policeradio(playerid, params[]) {
if(isnull(params))
return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");
if(gTeam[playerid] !=Team_Police)
return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");
new
szMessage[128],
szPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && gTeam[i] ==Team_Police)
SendClientMessage(i, 0, szMessage);
}
return 1;
}
You were checking if playerid was Team_Police (and sending the message only to playerid). I assume that you want to send it to all cops, so you needed to use i in gTeam[i] and SendClientMessage(i,0,szMessage)
Re: why no show up? -
TheDiscussionCafe - 11.05.2012
Quote:
Originally Posted by Yuryfury
pawn Код:
CMD:policeradio(playerid, params[]) { if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");
if(gTeam[playerid] !=Team_Police) return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");
new szMessage[128], szPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME); format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && gTeam[i] ==Team_Police) SendClientMessage(i, 0, szMessage); } return 1; }
You were checking if playerid was Team_Police (and sending the message only to playerid). I assume that you want to send it to all cops, so you needed to use i in gTeam[i] and SendClientMessage(i,0,szMessage)
|
hi sir!!! u are so very smart! thanks you so much!