if(!GetPVarString(playerb, "Report")) return SendClientMessage(playerid, COLOR_GREY, "This player doesn't have an active report");
// GetPVarString - This function returns the length of player's PVarString.
new
string[128];
if (!GetPVarString(playerid, "Report", string, 128))
{
SendClientMessage(playerid, COLOR_GREY, "This player doesn't have an active report");
}
I don't use pvars but this is how the wiki suggests you do it:
pawn Код:
|
CMD:reports(playerid, params[])
{
new string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
SendClientMessage(playerid, COLOR_REPORT, "Pending Reports:");
foreach(Player, i)
{
if (GetPVarString(i, "Report", string, 128))
{
new rtext[128];
GetPVarString(i, "Report", rtext, 128);
format(string, sizeof(string), "Report from {FF6347}[%d] {FFFF91}%s: %s", i, GetPlayerNameEx(i), rtext);
}
}
return 1;
}
Well for one thing, you don't need to call "GetPVarString" twice, just use "string" in your "format" call within the "if" instead of "rtext". That way you get the string in the call to "GetPVarString" in the "if" statement and use it straight away if it does exist. As for it being buggy, it would help if you said what the bug was. I suspect it's that you don't see the message - and that's because you never send the message after formatting it.
|