command bug - 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)
+--- Thread: command bug (
/showthread.php?tid=431140)
command bug -
Michael_Cuellar - 16.04.2013
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
Re: command bug -
[XST]O_x - 16.04.2013
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.
Re: command bug -
Michael_Cuellar - 16.04.2013
whats different?
Re: command bug -
[XST]O_x - 16.04.2013
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.