/r(adio) won't work -
Outcast - 12.01.2011
Hi. Im trying to make a /r(adio) command for players in a PD faction. This is my code:
pawn Код:
[COMMAND:r(playerid, params[])
{
new msg[128], copname[40], rchat[128];
if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid,COLOR_WHITE," You are not in a faction");
if(sscanf(params, "s[128]", rchat)) return SendClientMessage(playerid,COLOR_WHITE," Usage: /r [text]");
GetPlayerName(playerid, copname, sizeof(copname));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction])
{
format(msg, sizeof(msg), "%s (%i - %s): %s, over.", copname, PlayerInfo[playerid][pFRank], PlayerInfo[playerid][pFRankName], rchat);
SendClientMessage(i, COLOR_BLUE, msg);
return 1;
}
}
}
But, when I type /r sometext, nothing shows up on my screen. I don't know about the other's screen, cause I didn't test it on other players and I can't atm.
AW: /r(adio) won't work -
Kmitska - 12.01.2011
try this:
pawn Код:
for(new i; i<MAX_PLAYERS; i++)
if(IsPlayerConnected(i) && PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction])
Re: /r(adio) won't work -
Kyle_Olsen - 12.01.2011
pawn Код:
[COMMAND:r(playerid, params[])
{
new msg[128], copname[40], rchat[128];
if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid,COLOR_WHITE," You are not in a faction");
if(sscanf(params, "s", rchat)) return SendClientMessage(playerid,COLOR_WHITE," Usage: /r [text]");
GetPlayerName(playerid, copname, sizeof(copname));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction])
{
format(msg, sizeof(msg), "%s (%i - %s): %s, over.", copname, PlayerInfo[playerid][pFRank], PlayerInfo[playerid][pFRankName], rchat);
SendClientMessage(i, COLOR_BLUE, msg);
}
}
return 1;
}
Try that one
Do you get any errors, anyway?
Re: /r(adio) won't work -
Outcast - 12.01.2011
Quote:
Originally Posted by Kyle_Olsen
pawn Код:
[COMMAND:r(playerid, params[]) { new msg[128], copname[40], rchat[128]; if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid,COLOR_WHITE," You are not in a faction"); if(sscanf(params, "s", rchat)) return SendClientMessage(playerid,COLOR_WHITE," Usage: /r [text]"); GetPlayerName(playerid, copname, sizeof(copname)); for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction]) { format(msg, sizeof(msg), "%s (%i - %s): %s, over.", copname, PlayerInfo[playerid][pFRank], PlayerInfo[playerid][pFRankName], rchat); SendClientMessage(i, COLOR_BLUE, msg); } } return 1; }
Try that one
Do you get any errors, anyway?
|
No errors or warnings. Gonna try yours and Kmitska's solution.
EDIT: Thank you both of you. I got it working. It seemed that the array size of the rchat was too small. I increased it to 200 and it works now.
Re: /r(adio) won't work -
Scenario - 12.01.2011
You don't need to use sscanf there, it would be slower in this situation. Try doing this;
pawn Код:
COMMAND:r(playerid, params[])
{
new msg[128], copname[40];
if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid,COLOR_WHITE," You are not in a faction");
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /®adio [message]");
GetPlayerName(playerid, copname, sizeof(copname));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction])
{
format(msg, sizeof(msg), "%s (%i - %s): %s, over.", copname, PlayerInfo[playerid][pFRank], PlayerInfo[playerid][pFRankName], params);
SendClientMessage(i, COLOR_BLUE, msg);
}
}
return 1;
}
Re: /r(adio) won't work -
Outcast - 12.01.2011
Quote:
Originally Posted by RealCop228
You don't need to use sscanf there, it would be slower in this situation. Try doing this;
pawn Код:
COMMAND:r(playerid, params[]) { new msg[128], copname[40]; if(PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid,COLOR_WHITE," You are not in a faction"); if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /®adio [message]"); GetPlayerName(playerid, copname, sizeof(copname)); for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[i][pFaction] == PlayerInfo[playerid][pFaction]) { format(msg, sizeof(msg), "%s (%i - %s): %s, over.", copname, PlayerInfo[playerid][pFRank], PlayerInfo[playerid][pFRankName], params); SendClientMessage(i, COLOR_BLUE, msg); } } return 1; }
|
Thanks for that. I edited all my commands simmilar to /r (like /me, /do, /s ...).
Re: /r(adio) won't work -
Scenario - 12.01.2011
Quote:
Originally Posted by kreso932
Thanks for that. I edited all my commands simmilar to /r (like /me, /do, /s ...).
|
Good luck!