SendClientMessage
#1

Hello!

i made a setscore cmd, it works and gives the right player the right score and gets the message about it.
But the user of the cmd does not get the message that he have given a player score, why?

code:
pawn Код:
CMD:setscore(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Admin] >= 5)
        {
            new id;
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,score;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ii", playerid,score))
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has set your score to %d",sendername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                    SetPlayerScore(playerid, score);
                    format(string, sizeof(string), "You have set %s score to %d",giveplayername,score);
                    SendClientMessage(id, COLOR_GRAD1, string);
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid] [score]");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not an level 5 Admin!, or you are not a Admin!");
    }
    return 1;
}
Reply
#2

pawn Код:
CMD:setscore(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Admin] >= 5)
        {
            new id;
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,score;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ii", playerid,score))
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has set your score to %d",sendername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                    SetPlayerScore(playerid, score);
                    format(string, sizeof(string), "You have set %s score to %d",giveplayername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid] [score]");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not an level 5 Admin!, or you are not a Admin!");
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Jay.
Посмотреть сообщение
pawn Код:
CMD:setscore(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Admin] >= 5)
        {
            new id;
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,score;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ii", playerid,score))
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has set your score to %d",sendername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                    SetPlayerScore(playerid, score);
                    format(string, sizeof(string), "You have set %s score to %d",giveplayername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid] [score]");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not an level 5 Admin!, or you are not a Admin!");
    }
    return 1;
}
I have already tested that, if i use SendClientMessage(playerid, COLOR_GRAD1, string); the scored player gets both messages
Reply
#4

Try this:
pawn Код:
CMD:setscore(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Admin] >= 5)
        {
            new id;
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,score;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ii", giveplayerid,score))
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has set your score to %d",sendername,score);
                    SendClientMessage(giveplayerid, COLOR_GRAD1, string);
                    SetPlayerScore(giveplayerid, score);
                    format(string, sizeof(string), "You have set %s score to %d",giveplayername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid] [score]");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not an level 5 Admin!, or you are not a Admin!");
    }
    return 1;
}
Reply
#5

pawn Код:
if (!sscanf(params, "ui", playerid,score))
You did "ii" instead of "ui"
Reply
#6

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
pawn Код:
if (!sscanf(params, "ui", playerid,score))
You did "ii" instead of "ui"
What is the different between "ii" and "ui" ?
Reply
#7

Quote:
Originally Posted by cruising
Посмотреть сообщение
What is the different between "ii" and "ui" ?
https://sampwiki.blast.hk/wiki/Fast_Commands#Data_types
Reply
#8

Quote:
Originally Posted by cruising
Посмотреть сообщение
What is the different between "ii" and "ui" ?
Sscanf uses "u" only for player IDs, and disabled "i" (int) for players.
Reply
#9

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
Try this:
pawn Код:
CMD:setscore(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Admin] >= 5)
        {
            new id;
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,score;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ii", giveplayerid,score))
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has set your score to %d",sendername,score);
                    SendClientMessage(giveplayerid, COLOR_GRAD1, string);
                    SetPlayerScore(giveplayerid, score);
                    format(string, sizeof(string), "You have set %s score to %d",giveplayername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid] [score]");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not an level 5 Admin!, or you are not a Admin!");
    }
    return 1;
}
With this i get the message, but of some reason the name you get back is ID 0 always, who is my NPC :O
Reply
#10

Quote:
Originally Posted by cruising
Посмотреть сообщение
With this i get the message, but of some reason the name you get back is ID 0 always, who is my NPC :O
pawn Код:
CMD:setscore(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][Admin] >= 5)
        {
            new id;
            new sendername[MAX_PLAYER_NAME];
            new giveplayername[MAX_PLAYER_NAME];
            new giveplayerid,score;
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
            if (!sscanf(params, "ui", giveplayerid,score)) // This was "ii" again
            {
                if (giveplayerid != INVALID_PLAYER_ID)
                {
                    new string[128];
                    format(string, sizeof(string), "The admin %s has set your score to %d",sendername,score);
                    SendClientMessage(giveplayerid, COLOR_GRAD1, string);
                    SetPlayerScore(giveplayerid, score);
                    format(string, sizeof(string), "You have set %s score to %d",giveplayername,score);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setscore [playerid] [score]");
        }
        else SendClientMessage(playerid, 0xFF0000FF, "You are not an level 5 Admin!, or you are not a Admin!");
    }
    return 1;
}
Again there was "ii" as you can see in my comment
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)