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

Код:
Starring:
Player ID 0 - Zacky (Other Players)
Player ID 1 - Josh (Me, For Example)
Player ID 2 - John (Other Players)
My Set VIP Code :-
pawn Код:
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, "uid", targetid, vipLevel)) return SendClientMessage(playerid, 0xFF0000FF, "Correct Usage: /setvip [playerid] [level]");
        {
            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;
}
Ok so, i wanted to make Player ID 2 - John as a VIP but whenever i typed '/setvip 2 1' it shows;
'Administrator Josh(1) have set Zacky(2)'s VIP Level to 1/3'
Player ID 0's Name (Zacky) but John's ID (ID: 2).

Whenever i typed /setvip or /setadmin, whatever...
It shows ID 0's Name but other's ID.

Please, help.
Reply
#2

You mean it makes id 2 vip but it shows wrong message?
i will edit my post after you reply
Reply
#3

Quote:
Originally Posted by R0
Посмотреть сообщение
You mean it makes Zacky vip but it shows wrong message?
i will edit my post after you reply
No, no, no.
It makes John (ID: 2)'s a VIP, but it shows on Message i've made Zacky (ID: 0)'s a VIP.
But Zacky's not a VIP.

Whenever i type a command with 'playerid' on Usage, it always shows ID 0's Name.
Reply
#4

Код:
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;
}
Reply
#5

Dear rittik,believe me,changing lines and...wont work,just dont waste time for wrong posts,well it's easy to fix,well,he is Getting targetid's name before even detecting if he wrote the targetid,so it wont know which id you wrote,so it always get id 0's name,code should be:
pawn Код:
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));

        if(sscanf(params, "ud", targetid, vipLevel)) return SendClientMessage(playerid, 0xFF0000FF, "Correct Usage: /setvip [playerid] [level]");
        {
            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;
            GetPlayerName(targetid, tName, sizeof(tName));
            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;
}
Reply
#6

It's the same as :-
pawn Код:
CMD:pingplayer(playerid, params[])
{
    new ppString[500];

    new tName[MAX_PLAYER_NAME];
    new targetid;
    GetPlayerName(targetid, tName, sizeof(tName));

    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");

    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;
}
EDIT :-
Quote:
Originally Posted by R0
Посмотреть сообщение
Dear rittik,believe me,changing lines and...wont work,just dont waste time for wrong posts,well it's easy to fix,well,he is Getting targetid's name before even detecting if he wrote the targetid,so it wont know which id you wrote,so it always get id 0's name,code should be:
pawn Код:
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));

        if(sscanf(params, "uid", targetid, vipLevel)) return SendClientMessage(playerid, 0xFF0000FF, "Correct Usage: /setvip [playerid] [level]");
        {
            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;
            GetPlayerName(targetid, tName, sizeof(tName));
            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;
}
So, i will do the same in,
Код:
CMD:pingplayer(playerid, params[])
?
Reply
#7

Quote:
Originally Posted by R0
Посмотреть сообщение
Dear rittik,believe me,changing lines and...wont work,just dont waste time for wrong posts,well it's easy to fix,well,he is Getting targetid's name before even detecting if he wrote the targetid,so it wont know which id you wrote,so it always get id 0's name,code should be:
pawn Код:
if(sscanf(params, "uid", targetid, vipLevel)) return SendClientMessage(playerid, 0xFF0000FF, "Correct Usage: /setvip [playerid] [level]");
 //why there is "u" and "i" ,see my post carefully I only used "i" not the "u" because there is no use of it.
Read the code carefully and then reply.
Reply
#8

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;
}
and rittik,yea but the main problem wasnt the same as you said,it was the getting name thingy.
Reply
#9

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.

EDIT: Yes, getting the name must be after the sscanf line in /pingplayer too. And change the size of ppString to 128.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)