SA-MP Forums Archive
SendClientMessage - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SendClientMessage (/showthread.php?tid=265813)



SendClientMessage - cruising - 02.07.2011

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;
}



Re: SendClientMessage - Jay. - 02.07.2011

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;
}



Re: SendClientMessage - cruising - 02.07.2011

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


Re: SendClientMessage - iPLEOMAX - 02.07.2011

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;
}



Re: SendClientMessage - Wesley221 - 02.07.2011

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


Re: SendClientMessage - cruising - 02.07.2011

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" ?


Re: SendClientMessage - Gazmull - 02.07.2011

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


Re: SendClientMessage - Sasino97 - 02.07.2011

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.


Re: SendClientMessage - cruising - 02.07.2011

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


Re: SendClientMessage - Wesley221 - 02.07.2011

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