Unban command with DCMD and y_ini file system. -
Jack_Leslie - 31.08.2011
So I had a problem before but then got it solved but now there's a completely different problem. The command now executes, and before I posted this I done a debug and the problem is that it replies "SERVER: Unknown command" but the debug says that it did what it was meant to (Open the players file, set the banned to 0 and the banreason to None and then close the file), but it doesn't do that, except the debug says it did. Here's the code:
pawn Код:
dcmd_unban(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new user[128], string[128];
if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", user);
if(INI_Exists(user))
{
new INI:File = INI_Open(user);
printf(user);
printf("User file opened");
INI_SetTag(File,"Main");
INI_WriteInt(File, "Banned", 0);
printf("User file unbanned");
format(string, sizeof(string), "None");
INI_WriteString(File, "BanReason", string);
printf("Banned reason changed");
INI_Close(File);
printf("File closed");
foreach(Player ,i)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user);
SendClientMessage(i, COLOR_LIGHTRED, string);
}
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
return 1;
}
return 1;
}
Re: Unban command with DCMD and y_ini file system. -
[MWR]Blood - 31.08.2011
Try this:
pawn Код:
dcmd_unban(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new user[128], string[128];
if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", user);
if(INI_Exists(user))
{
new INI:File = INI_Open(user);
printf(user);
printf("User file opened");
INI_SetTag(File,"Main");
INI_WriteInt(File, "Banned", 0);
printf("User file unbanned");
format(string, sizeof(string), "None");
INI_WriteString(File, "BanReason", string);
printf("Banned reason changed");
INI_Close(File);
printf("File closed");
format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user);
SendClientMessageToAll(COLOR_LIGHTRED, string);
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
}
return 1;
}
Re: Unban command with DCMD and y_ini file system. -
Jack_Leslie - 31.08.2011
Quote:
Originally Posted by Delux13
Try this:
pawn Код:
dcmd_unban(playerid, params[]) // Level 1 { if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!"); new user[128], string[128]; if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]"); format(user, sizeof(user), "%s.ini", user); if(INI_Exists(user)) { new INI:File = INI_Open(user); printf(user); printf("User file opened"); INI_SetTag(File,"Main"); INI_WriteInt(File, "Banned", 0); printf("User file unbanned"); format(string, sizeof(string), "None"); INI_WriteString(File, "BanReason", string); printf("Banned reason changed"); INI_Close(File); printf("File closed"); format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user); SendClientMessageToAll(COLOR_LIGHTRED, string); } else { SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!"); } return 1; }
|
No good, it sends me "Server: unknown command"
I looked at my debug, and the code stops before it tells it to close the file... so something wrong there.
Re: Unban command with DCMD and y_ini file system. -
FireCat - 31.08.2011
Quote:
Originally Posted by Jack_Leslie
So I had a problem before but then got it solved but now there's a completely different problem. The command now executes, and before I posted this I done a debug and the problem is that it replies "SERVER: Unknown command" but the debug says that it did what it was meant to (Open the players file, set the banned to 0 and the banreason to None and then close the file), but it doesn't do that, except the debug says it did. Here's the code:
pawn Код:
dcmd_unban(playerid, params[]) // Level 1 { if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!"); new user[128], string[128]; if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]"); format(user, sizeof(user), "%s.ini", user); if(INI_Exists(user)) { new INI:File = INI_Open(user); printf(user); printf("User file opened"); INI_SetTag(File,"Main"); INI_WriteInt(File, "Banned", 0); printf("User file unbanned"); format(string, sizeof(string), "None"); INI_WriteString(File, "BanReason", string); printf("Banned reason changed"); INI_Close(File); printf("File closed"); foreach(Player ,i) { if(PlayerInfo[i][pAdmin] >= 1) { format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user); SendClientMessage(i, COLOR_LIGHTRED, string); } } return 1; } else { SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!"); return 1; } return 1; }
|
Quote:
Originally Posted by Delux13
Try this:
pawn Код:
dcmd_unban(playerid, params[]) // Level 1 { if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!"); new user[128], string[128]; if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]"); format(user, sizeof(user), "%s.ini", user); if(INI_Exists(user)) { new INI:File = INI_Open(user); printf(user); printf("User file opened"); INI_SetTag(File,"Main"); INI_WriteInt(File, "Banned", 0); printf("User file unbanned"); format(string, sizeof(string), "None"); INI_WriteString(File, "BanReason", string); printf("Banned reason changed"); INI_Close(File); printf("File closed"); format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user); SendClientMessageToAll(COLOR_LIGHTRED, string); } else { SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!"); } return 1; }
|
He wants to send the message to all admins!
Not just everyone.
So try this
pawn Код:
dcmd_unban(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new user[128], string[128],PlayerName[24];
if(sscanf(params, "s[128]", PlayerName)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", PlayerName);
if(INI_Exists(user))
{
new INI:File = INI_Open(user);
printf(user);
printf("User file opened");
INI_SetTag(File,"Main");
INI_WriteInt(File, "Banned", 0);
printf("User file unbanned");
format(string, sizeof(string), "None");
INI_WriteString(File, "BanReason", string);
printf("Banned reason changed");
INI_Close(File);
printf("File closed");
foreach(Player ,i)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user);
SendClientMessage(i, COLOR_LIGHTRED, string);
}
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
return 1;
}
return 1;
}
Re: Unban command with DCMD and y_ini file system. -
Jack_Leslie - 31.08.2011
Quote:
Originally Posted by FireCat
He wants to send the message to all admins!
Not just everyone.
So try this
pawn Код:
dcmd_unban(playerid, params[]) // Level 1 { if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!"); new user[128], string[128],PlayerName[24]; if(sscanf(params, "s[128]", PlayerName)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]"); format(user, sizeof(user), "%s.ini", PlayerName); if(INI_Exists(user)) { new INI:File = INI_Open(user); printf(user); printf("User file opened"); INI_SetTag(File,"Main"); INI_WriteInt(File, "Banned", 0); printf("User file unbanned"); format(string, sizeof(string), "None"); INI_WriteString(File, "BanReason", string); printf("Banned reason changed"); INI_Close(File); printf("File closed"); foreach(Player ,i) { if(PlayerInfo[i][pAdmin] >= 1) { format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user); SendClientMessage(i, COLOR_LIGHTRED, string); } } return 1; } else { SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!"); return 1; } return 1; }
|
That gave me a few errors
Код:
(1209) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
(1229) : error 012: invalid function call, not a valid address
(1229) : warning 215: expression has no effect
(1229) : error 001: expected token: ";", but found ")"
(1229) : error 029: invalid expression, assumed zero
(1229) : fatal error 107: too many error messages on one line
Re: Unban command with DCMD and y_ini file system. -
FireCat - 31.08.2011
pawn Код:
dcmd_unban(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new user[128], string[128],PlayerName2[24];
if(sscanf(params, "s[128]", PlayerName2)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", PlayerName2);
if(INI_Exists(user))
{
new INI:File = INI_Open(user);
printf(user);
printf("User file opened");
INI_SetTag(File,"Main");
INI_WriteInt(File, "Banned", 0);
printf("User file unbanned");
format(string, sizeof(string), "None");
INI_WriteString(File, "BanReason", string);
printf("Banned reason changed");
INI_Close(File);
printf("File closed");
foreach(Player ,i)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), PlayerName2);
SendClientMessage(i, COLOR_LIGHTRED, string);
}
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
return 1;
}
return 1;
}
Re: Unban command with DCMD and y_ini file system. -
Jack_Leslie - 31.08.2011
The code still stops just before INI_Close(File); causing it to give me an unknown server command.
Re: Unban command with DCMD and y_ini file system. -
FireCat - 31.08.2011
Quote:
Originally Posted by Jack_Leslie
The code still stops just before INI_Close(File); causing it to give me an unknown server command.
|
But does it write to the file Banned = 0?
Re: Unban command with DCMD and y_ini file system. -
Jack_Leslie - 31.08.2011
Nope it doesn't because it doesn't close the file so it can't save it, I think, but however, no it doesn't.
Re: Unban command with DCMD and y_ini file system. -
FireCat - 31.08.2011
Quote:
Originally Posted by Jack_Leslie
Nope it doesn't because it doesn't close the file so it can't save it, I think, but however, no it doesn't.
|
Its y_ini right?