SendClientMessage
#1

This code sends the "You have set PLAYER admin level to VALUE" to the person that set it, but it doesn't send the second message to the person who's admin level is being set.

PHP код:
CMD:setadmin(playeridparams[])
{
    new 
pIDvalue;
    if(!
IsPlayerAdmin(playerid)) return 0;
    else if(
sscanf(params"ui"pIDvalue)) return SendClientMessage(playerid, -1"{FFFF00}[SERVER] {FF0000}USAGE: {FFFFFF}/setadmin id level");
    else if(
value || value 5) return SendClientMessage(playerid, -1"{FFFF00}[SERVER] {FF0000}ERROR: {FFFFFF}Pick a level between 1 and 5");
    else if(
pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"{FFFF00}[SERVER] {FF0000}ERROR: {FFFFFF}That player is not connected");
    else
    {
        new 
string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
          
GetPlayerName(playeridpNamesizeof(pName));
        
GetPlayerName(pIDtargetsizeof(target));
        
format(stringsizeof(string), "{FFFF00}[SERVER] {FFFFFF}You have set {FFFF00}%s{FFFFFF} admin level to {FFFF00}%i"targetvalue);
        
SendClientMessage(playerid, -1string);
        
format(stringsizeof(string), "{FFFF00}[SERVER] {FFFFFF}Your admin level has been set to {FFFF00}%i {FFFFFF}by {FFFF00}%s"valuepName);
        
SendClientMessage(pID, -1string1);
        
PlayerInfo[playerid][pAdmin] = value;
    }
    return 
1;

Reply
#2

Hmm, it should send it...

But...

PlayerInfo[playerid][pAdmin] = value;

PlayerInfo[pID][pAdmin] = value;

ohh it sends it, but its empty, look at formating...

SendClientMessage(pID, -1, string1);
Reply
#3

You're formatting 'string', but sending 'string1', that's why.

PHP код:
format(string <<<, sizeof(string) <<<, "{FFFF00}[SERVER] {FFFFFF}Your admin level has been set to {FFFF00}%i {FFFFFF}by {FFFF00}%s"valuepName); 
SendClientMessage(pID, -1string1 <<<); 
There's no need to use two strings at all, just use one (remove string1[128]) and change this:

Код:
SendClientMessage(pID, -1, string1);
to this

Код:
SendClientMessage(pID, -1, string);
Once the string has been formatted and the message sent to the player 1, you can use the same string with different format and send it again to player 2.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)