Let the Reason shows after kicked -
Tuntun - 25.11.2013
Hmm i need help with kick and ban command. It dosen't show the reason why i banned him. Only i can see it.
But it should show in main chat and the player screen who i kicked.
Код:
// Kicks a player with a reason
COMMAND:kick(playerid, params[])
{
new PlayerToKick, Reason[128], ReasonMsg[128], Name[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/kick", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "us[128]", PlayerToKick, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <PlayerToKick> <Reason>\"");
else
if (IsPlayerConnected(PlayerToKick)) // If the player is a valid playerid (he's connected)
{
// Get the name of the player who warned the player
GetPlayerName(playerid, Name, sizeof(Name));
// Send the warned player a message who kicked him and why he's been kicked
format(ReasonMsg, 128, "You have been kicked by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
// Kick the player
Kick(PlayerToKick);
}
else
SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
}
else
return 0;
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
// Bans a player for (days, hours, minutes, seconds)
COMMAND:ban(playerid, params[])
{
// Setup local variables
new PlayerToBan, Days, Hours, Reason[128], TotalBanTime, Msg[128], Name[24], AdminName[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/ban", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 3
if (APlayerData[playerid][PlayerLevel] >= 3)
{
if (sscanf(params, "uiis[128]", PlayerToBan, Days, Hours, Reason))
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/ban <PlayerToBan> <Days> <Hours> <Reason>\"");
else
{
if (IsPlayerConnected(PlayerToBan))
{
// Get the names of the player and the admin who executed the ban
GetPlayerName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(PlayerToBan, Name, sizeof(Name));
// Increase the number of bans
APlayerData[PlayerToBan][Bans]++;
// Calculate the total bantime (when the player can login again)
TotalBanTime = (Days * 86400) + (Hours * 3600) + gettime();
// Check if this is the player's 5th ban
if (APlayerData[PlayerToBan][Bans] == 5)
APlayerData[PlayerToBan][BanTime] = 2147483640; // Make the ban permanent (as high as it can go)
else
APlayerData[PlayerToBan][BanTime] = TotalBanTime; // Store this value for the player
// Inform the player about his ban
// Check if this is the player's 5th ban
if (APlayerData[PlayerToBan][Bans] == 5)
{
format(Msg, 128, "You have been banned permanently by %s, this was your 5th ban", AdminName);
SendClientMessage(PlayerToBan, 0x808080FF, Msg);
}
else
{
format(Msg, 128, "You have been banned by %s for %i days and %i hours", AdminName, Days, Hours);
SendClientMessage(PlayerToBan, 0x808080FF, Msg);
format(Msg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToBan, 0x808080FF, Msg);
format(Msg, 128, "You've been banned %i times now, 5th time is permament", APlayerData[PlayerToBan][Bans]);
SendClientMessage(PlayerToBan, 0x808080FF, Msg);
}
// Kick the player (his data will be saved)
Kick(PlayerToBan);
// Inform everybody else which player was banned and for how long
format(Msg, 128, "%s %s has banned %s for %i days and %i hours", AdminLevelName[APlayerData[playerid][PlayerLevel]], AdminName, Name, Days, Hours);
SendClientMessageToAll(0x808080FF, Msg);
}
}
}
else
return 0;
}
else
return 0;
return 1;
}
Like: Admin {FF0000}%s{FFFFFF} has kicked you from server due to: {FF0000}The message
And for banned: Admin {FF0000}%s{FFFFFF} has banned you from server due to: {FF0000}The message
Re: Let the Reason shows after kicked -
dominik523 - 25.11.2013
You need to make a timer, it can be i.e. 500ms, because kick is too fast so the player won't see any message that was written before kick.
AW: Let the Reason shows after kicked -
Blackazur - 25.11.2013
Use a timer since 0.3x it won't show the reason anymore. If you want that it shows the message in the main chat, use SendClientMessageForAll, tuntun. ^^
Re: Let the Reason shows after kicked -
Tuntun - 25.11.2013
Can you do it? ill rep you.
Because i'm too busy in other work. also i need this.
Re: Let the Reason shows after kicked -
dominik523 - 25.11.2013
You can add something like this:
pawn Код:
// command
KickEx(PlayerToKick);
// stock
stock KickEx(playerid)
{
SetTimerEx("KickTimer", 500, false, playerid, "i");
return 1;
}
public KickTimer(playerid)
{
Kick(playerid);
return 1;
}
Re: Let the Reason shows after kicked -
Tuntun - 25.11.2013
E:\Server\18WoS\pawno\include\commands.inc(1570) : error 017: undefined symbol "PlayerToKick"
E:\Server\18WoS\pawno\include\commands.inc(4942) : error 035: argument type mismatch (argument 4)
E:\Server\18WoS\pawno\include\commands.inc(4940) : warning 203: symbol is never used: "playerid"
E:\Server\18WoS\pawno\include\commands.inc(4940 -- 4946) : warning 235: public function lacks forward declaration (symbol "KickTimer")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: Let the Reason shows after kicked -
dominik523 - 25.11.2013
you are missing
forward KickTimer(playerid); and PlayerToKick is your variable to kick player, right?
oops, and this:
pawn Код:
SetTimerEx("KickTimer", 500, false, "i", playerid);