Just a quick help with a command -
Thundey - 28.02.2018
Hey,
So I've just been wondering where the hell did I mess up with the ban command here? It does not give me errors, however, whichever ID I ban, it always inserts ID 0's player's name. So, let's say I ban ID 8, it actually bans the correct ID, however, ID 0's name gets called in the format.
Code is below. I might be blind a bit here, but I can't see where did I mess up. Ty in advance ;-;
Код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2) {
new Playerid;
new reason[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(Playerid, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", Playerid,reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
if(!IsPlayerConnected(Playerid))
return SendClientMessage(playerid, COLOR_WHITE, "ERROR: Player is not connected!");
format(str, sizeof(str), "[ADMIN ACTION] %s have been banned by Administrator %s [Reason: %s] ", Playername, Adminname, reason);
BanEx(Playerid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "ERROR: You are not authorised to use this command!");
}
return 1;
}
Re: Just a quick help with a command -
Daddy Yankee - 28.02.2018
Try getting the name after the params check
Re: Just a quick help with a command -
RogueDrifter - 28.02.2018
Quote:
Originally Posted by Daddy Yankee
Try getting the name after the params check
|
Not try, you're actually right he does need to get the player's name after the params check that's why for him its returning id 0's name at all times,
@OP it should look like this:
PHP код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2) {
new Playerid;
new reason[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
if(sscanf(params, "us[64]", Playerid,reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
if(!IsPlayerConnected(Playerid))
return SendClientMessage(playerid, COLOR_WHITE, "ERROR: Player is not connected!");
GetPlayerName(Playerid, Playername, sizeof(Playername));//moved
format(str, sizeof(str), "[ADMIN ACTION] %s have been banned by Administrator %s [Reason: %s] ", Playername, Adminname, reason);
BanEx(Playerid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "ERROR: You are not authorised to use this command!");
}
return 1;
}
Re: Just a quick help with a command -
Thundey - 28.02.2018
Yup, you both are right.
Cheers guys, it totally dropped from me there.