Help with /dep -
BabyBauer - 27.12.2017
So I am having issues with /dep. It never returns the correct Faction Abbreviation before the message; Example Player A is LSPD and Player B is SASD. Player A types this /dep PD 101 for SD 240. It will come out as this;
[SASD] RankOfPlayerA PlayerA'sName: PD 101 for SD 240.
And the same for SD
[LSPD] RankOfPlayerB PlayerB'sName: SD 240 for PD 101.
Here is my code if someone could help...
Код:
alias:department("dep");
CMD:department(playerid, params[])
{
if(!PlayerInfo[playerid][pFaction])
return SendErrorMessage(playerid, "You aren't in any faction.");
if(FactionInfo[PlayerInfo[playerid][pFaction]][eFactionType] != FACTION_TYPE_POLICE && FactionInfo[PlayerInfo[playerid][pFaction]][eFactionType] != FACTION_TYPE_MEDICAL && FactionInfo[PlayerInfo[playerid][pFaction]][eFactionType] != FACTION_TYPE_DOC)
return SendClientMessage(playerid, COLOR_RED, "ACCESS DENIED:{FFFFFF} You can't use this command.");
if(isnull(params))
return SendUsageMessage(playerid, "/(dep)artment [text]");
if(PlayerInfo[playerid][pLoggedin] && GetPlayerTeam(playerid) != PLAYER_STATE_ALIVE)
{
SendServerMessage(playerid, "You can't talk when you aren't alive.");
return 0;
}
foreach(new i : Player)
{
new
factionid;
factionid = PlayerInfo[i][pFaction];
if(FactionInfo[factionid][eFactionType] == FACTION_TYPE_POLICE || FactionInfo[factionid][eFactionType] == FACTION_TYPE_MEDICAL || FactionInfo[factionid][eFactionType] == FACTION_TYPE_DOC)
{
sendMessage(i, COLOR_DEPT, "** [%s] %s %s: %s", FactionInfo[factionid][eFactionAbbrev], ReturnFactionRank(playerid), ReturnName(playerid, 0), params);
}
}
new Float:posx, Float:posy, Float:posz;
GetPlayerPos(playerid, posx,posy,posz);
foreach(new i : Player)
{
if(i == playerid)
continue;
else if(IsPlayerInRangeOfPoint(i, 20.0, posx,posy,posz))
{
sendMessage(i, COLOR_GRAD1, "%s says (radio): %s", ReturnName(playerid, 0), params);
}
}
return 1;
}
Re: Help with /dep -
Ritzy2K - 27.12.2017
Код:
GetPlayerTeam(playerid) != PLAYER_STATE_ALIVE
lol?
Код:
sendMessage(i, COLOR_DEPT, "** [%s] %s %s: %s", FactionInfo[factionid][eFactionAbbrev], ReturnFactionRank(playerid), ReturnName(playerid, 0), params);
Aren't we working with "i" instead of "playerid"?
I think your issue lies here.
Ugh, I also
think that ( I'm not sure :thonk: ) that here it should be OR instead of AND.
Код:
if(FactionInfo[PlayerInfo[playerid][pFaction]][eFactionType] != FACTION_TYPE_POLICE && FactionInfo[PlayerInfo[playerid][pFaction]][eFactionType] != FACTION_TYPE_MEDICAL && FactionInfo[PlayerInfo[playerid][pFaction]][eFactionType] != FACTION_TYPE_DOC)
return SendClientMessage(playerid, COLOR_RED, "ACCESS DENIED:{FFFFFF} You can't use this command.");
Re: Help with /dep -
Kane - 27.12.2017
Quote:
Originally Posted by Ritzy
Код:
GetPlayerTeam(playerid) != PLAYER_STATE_ALIVE
lol?
|
What's wrong? And no, none of that is the issue.
PHP код:
foreach(new i : Player)
{
new
factionid;
factionid = PlayerInfo[i][pFaction];
if(FactionInfo[factionid][eFactionType] == FACTION_TYPE_POLICE || FactionInfo[factionid][eFactionType] == FACTION_TYPE_MEDICAL || FactionInfo[factionid][eFactionType] == FACTION_TYPE_DOC)
{
sendMessage(i, COLOR_DEPT, "** [%s] %s %s: %s", FactionInfo[factionid][eFactionAbbrev], ReturnFactionRank(playerid), ReturnName(playerid, 0), params);
}
}
factionid is used inside foreach. It needs to be the player id's faction.
i.e:
Код:
factionid = PlayerInfo[playerid][pFaction]
Remove it from there as well.
EDIT:
Make an alternative var for the playerid's faction. You still need to check the other players factions.