[Help] - SetVIP || About Target's Name and Target's ID
#10

Quote:
Originally Posted by Rittik
Посмотреть сообщение
Код:
CMD:setvip(playerid, params[])
{
    if(pInfo[playerid][pAdmin] >= 3)
    {
        new vipString[500];
        new vipLevel, targetid;
        new pName[MAX_PLAYER_NAME];
        new tName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        GetPlayerName(targetid, tName, sizeof(tName));

        if(sscanf(params, "id", targetid, vipLevel))
        {
            SendClientMessage(playerid, 0xFF0000FF, "Correct Usage: /setvip [playerid] [level]");
            return 1;
         }
        else
        {
            if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Player ID");
            if(vipLevel < 1 || vipLevel > 3) return SendClientMessage(playerid, 0xFF0000FF, "Only 1-3 Level is allowed");
            pInfo[targetid][pRDonator] = vipLevel;

            format(vipString, sizeof(vipString), "{FFFFFF}Administrator {%06x}%s(%d) {FFFFFF}have set {%06x}%s(%d){FFFFFF}'s VIP Level to %d/3", (GetPlayerColor(playerid) >>> 8), pName, playerid, (GetPlayerColor(targetid) >>> 8), tName, targetid, vipLevel);
            SendClientMessageToAll(0xFF0000FF, vipString);
        }
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You must be Level 3 to use this command");
    return 1;
}
Thanks for trying to help me too bro

Quote:
Originally Posted by R0
Посмотреть сообщение
as i have said,You are getting the name of the targetid before getting the string he wrote,and when you do that it always gets id 0's name,so it shows wrong name,and makes the id you wrote the thing you want it to make him,so command of pingplayer should be:
pawn Код:
CMD:pingplayer(playerid, params[])
{
    new ppString[500];

    new tName[MAX_PLAYER_NAME];
    new targetid;

    new playerPing = GetPlayerPing(targetid);

    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Correct Usage: /pingplayer [playerid]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Player ID");
    GetPlayerName(targetid, tName, sizeof(tName));
    format(pStringS, sizeof(pStringS), "{FFFFFF}You have pinged {%06x}%s(%d) {FFFFFF}- (Current Ping: {FF0000}%d{FFFFFF})", (GetPlayerColor(targetid) >>> 8), tName, targetid, pPing);
    SendClientMessage(playerid, 0xFF0000FF, pStringS);
    return 1;
}
Thanks man, i'll be sure to test it out

EDIT :-

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
What R0 said about getting the name of the targetid before sscanf is correct. You basically get the name of the player with ID 0.

Except that, the sscanf specifiers are wrong. You have 3 parameters and 2 specifiers, sscanf should've given a warning for that in the console. Change to:
pawn Код:
if(sscanf(params, "ui", targetid, vipLevel))
and also change the size of vipString to 144 since that is the max client lenght, 500 is just waste.
Thanks bhai
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)