[HELP] GetPVarString
#1

How to check if there is a value in a particular string assigned using GetPVarString?

I've tried
pawn Код:
if(!GetPVarString(playerb, "Report")) return SendClientMessage(playerid, COLOR_GREY, "This player doesn't have an active report");
But it gives me warnings.
Reply
#2

I don't use pvars but this is how the wiki suggests you do it:

pawn Код:
// 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");
}
Reply
#3

Thanks dude. Rep'ed +
Reply
#4

Quote:
Originally Posted by Psymetrix
Посмотреть сообщение
I don't use pvars but this is how the wiki suggests you do it:

pawn Код:
// 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");
}
There's one more problem. I want to get the value from the PVar and display 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;
}

Here's my code. Its bugged atm, but can you fix it?
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
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.
LOL! True! I never sent the message. Thanks for reminding.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)