error /warn command - 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: error /warn command (
/showthread.php?tid=436861)
error /warn command -
DerickClark - 13.05.2013
Waring Errors
Код:
warning 219: local variable "PlayerName" shadows a variable at a preceding level
error 035: argument type mismatch (argument 2)
error 017: undefined symbol "name"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Код:
// Warn a player
COMMAND:warn(playerid, params[])
{
new id, Reason[128], ReasonMsg[128], Name[24];
SendAdminText(playerid, "/warn", 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]", id, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /warn [id] [Reason]");
else
if (IsPlayerConnected(id)) // If the player is a valid playerid (he's connected)
{
// Increase the number of warnings
APlayerData[id][Warnings]++;
// Get the name of the player who warned the player
GetPlayerName(playerid, Name, sizeof(Name));
// Send the warned player a message who warned him and why he's been warned
new PlayerName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, PlayerName, sizeof(name));
format(ReasonMsg, 128, "%s have been warned by Administrator %s Reason: %s warnings: %i/%i)",Name, PlayerName, Reason,APlayerData[id][Warnings], AutoKickWarnings);
SendClientMessage(id, 0xFF0000FF, ReasonMsg);
// Get the name of the warned player
GetPlayerName(id, Name, sizeof(Name));
// Automatically kick the player if he got 3 warnings (if autokick is enabled)
if ((APlayerData[id][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
Kick(id);
}
else
SendClientMessage(playerid, 0xFF0000FF, "ERROR: That player isn't online");
}
else
return 0;
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Re : error /warn command -
DaTa[X] - 13.05.2013
i suggust to use function like GetName(playerid) so no need to make new vars everytime
pawn Код:
stock GetName(playerid)
{
new Name[MAX_PLAYER_NAME]
GetPlayerName(playerid,Name,sizeof(Name));
return Name;
}
and the command should be fixed
pawn Код:
COMMAND:warn(playerid, params[])
{
new id, Reason[128], ReasonMsg[128], Name[24];
SendAdminText(playerid, "/warn", 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]", id, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /warn [id] [Reason]");
if (IsPlayerConnected(id)) // If the player is a valid playerid (he's connected)
{
// Increase the number of warnings
APlayerData[id][Warnings]++;
new Name[MAX_PLAYER_NAME];
// Get the name of the player who warned the player
GetPlayerName(id, Name, sizeof(Name));
// Send the warned player a message who warned him and why he's been warned
new PName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, PName, sizeof(PName));
format(ReasonMsg, 128, "%s have been warned by Administrator %s Reason: %s warnings: %i/%i)",Name, PlayerName, Reason,APlayerData[id][Warnings], AutoKickWarnings);
SendClientMessage(id, 0xFF0000FF, ReasonMsg);
// Get the name of the warned player
GetPlayerName(id, Name, sizeof(Name));
// Automatically kick the player if he got 3 warnings (if autokick is enabled)
if ((APlayerData[id][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
Kick(id);
}
else
SendClientMessage(playerid, 0xFF0000FF, "ERROR: That player isn't online");
}
else
return 0;
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}