command bug
#1

pawn Код:
CMD:makeleader(playerid, params[])
{
   

    new targetid, factionid, string[128], targetname[24], playername[24];
    if(sscanf(params, "ui", targetid, factionid)) return SendClientMessage(playerid, -1, "Usage: /makeleader [playerid][factionid]");
    if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Invalid playerid!");
    if(0 < factionid < 6)
    {
        GetPlayerName(playerid, playername, sizeof(playername));
        GetPlayerName(targetid, targetname, sizeof(targetname));
        format(string, sizeof(string), "You made %s leader of faction id %i!", targetname, factionid);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "You were made leader of faction id %i by %s", factionid, playername);//Formats the string that the player will receive
        SendClientMessage(playerid, -1, string);
        PlayerInfo[playerid][pFaction] = factionid;
        PlayerInfo[playerid][pRank] = 6;
    }
    else return SendClientMessage(playerid, -1, "Invalid factionid.  Factionid's: 1-2");
    return 1;
}
This command when you use it on someone it says it made you leader and it says you've made your target leader but it only makes me leader and not my friend
Reply
#2

pawn Код:
CMD:makeleader(playerid, params[])
{
   

    new targetid, factionid, string[128], targetname[24], playername[24];
    if(sscanf(params, "ui", targetid, factionid)) return SendClientMessage(playerid, -1, "Usage: /makeleader [playerid][factionid]");
    if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Invalid playerid!");
    if(0 < factionid < 6)
    {
        GetPlayerName(playerid, playername, sizeof(playername));
        GetPlayerName(targetid, targetname, sizeof(targetname));
        format(string, sizeof(string), "You made %s leader of faction id %i!", targetname, factionid);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "You were made leader of faction id %i by %s", factionid, playername);//Formats the string that the player will receive
        SendClientMessage(targetid, -1, string);
        PlayerInfo[targetid][pFaction] = factionid;
        PlayerInfo[targetid][pRank] = 6;
    }
    else return SendClientMessage(playerid, -1, "Invalid factionid.  Factionid's: 1-2");
    return 1;
}
Should wrap it up for you.
Reply
#3

whats different?
Reply
#4

Quote:
Originally Posted by Michael_Cuellar
Посмотреть сообщение
whats different?
The final three statements... You've put playerid instead of targetid, therefore the sender of the command got the message instead of the recipient.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)