Can't edit a variable for disconnected players - 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: Can't edit a variable for disconnected players (
/showthread.php?tid=414572)
Can't edit a variable for disconnected players -
Saw® - 09.02.2013
Hi , I wanted to create /accountban [PLAYERNAME] [REASON] command but don't know how to ,
this is the /cban (to ban connected players ) to check the variables & way i'm working with.
pawn Code:
dcmd_cban(playerid, params[])
{
if (AdminLevel[playerid] < 3 ) {
SendClientMessage(playerid, COLOR_GREY, "You must be admin to use this command.");
}
else {
if (AdminLevel[playerid] >= 3) {
if(strlen(params) > 40) return SendClientMessage(playerid, COLOR_CERVENA, " Reason too long.");
new pos;
new string[150];
if(!params[0] || !(pos = chrfind(' ', params) + 1) || !params[pos]) return SendClientMessage(playerid, COLOR_GREY, "Usage: /cban [Playerid] [Reason]");
new CMD_ID = strval(params);
if(!IsPlayerConnected(CMD_ID)) return SendClientMessage(playerid, COLOR_CERVENA, "This player is not connected");
if(IsPlayerNPC(CMD_ID)) return SendClientMessage(playerid, COLOR_CERVENA, "You can't ban an NPC!");
new Admintext[128];
if(AdminLevel[playerid] >= 3) { Admintext = "[Administrator]"; }
format(string, sizeof(string), "[SERVER] : %s is account-banned by %s %s [Reason : %s]", PlayerName(CMD_ID),Admintext,PlayerName(playerid),params[pos]);
SendClientMessageToAll(COLOR_ORANGE, string);
format(string, sizeof(string), "[%s] %s has banned %s[Reason:%s]", Admintext,PlayerName(playerid), PlayerName(CMD_ID),params[pos]);
Banned[CMD_ID] = 1;
CodeUnban[CMD_ID] = 1648945654897 + random(900000000000000);
dini_Set(file[CMD_ID], "BanReason", params[pos]);
dini_Set(file[CMD_ID], "BanAdmin", PlayerName(playerid));
Kick(CMD_ID);
}
}
return 1;
}
Is there any way to change Banned variable for the 'PlayerName' to 1? like /accountban [Playername] [Reason] (for disconnected players)
Re: Can't edit a variable for disconnected players -
Scenario - 09.02.2013
No because if you use 1 as the default value for offline players, you won't ever be able to ban ID 1 from the server.
What you could do, though, is make it -1 or something. Obviously -1 == INVALID_PLAYER_ID but then you could do something like this:
pawn Code:
if(playername == INVALID_PLAYER_ID)
{
// check if the account name is online
// if not, check if the account name exists
// if it does, set the 'banned variable' to banned
}