Offline edit playerinfo - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Offline edit playerinfo (
/showthread.php?tid=528787)
Offline edit playerinfo -
jackx3rx - 29.07.2014
I made a command which blocks access from a specific account (/abanaccount). It works fine.
However my question is how would I edit his PlayerInfo[playerid][pAccountBanned] whilst hes offline?
1 = Banned.
0 = Not banned.
Here is the command I scripted which bans the account:
Код:
CMD:abanaccount(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} Only administrators may use this command.");
{
new targetid, reason[128], string[128], string2[128];
if(sscanf(params,"us[128]",targetid,reason)) return SendClientMessage(playerid,-1,"{AA3333}USAGE:{FFFFFF} /abanaccount (id) (reason)");
format(string,128,"{AA3333}AdminWARNING:{FFFFFF} %s attempted to ban your account, for reason: %s.",RemoveUnderScore(playerid),reason);
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[targetid][pAdmin] || PlayerInfo[targetid][pAdmin] == 6) return SendClientMessage(targetid,-1,string) && SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} You cannot ban that players account.");
{
PlayerInfo[targetid][pAccountBanned] = 1;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] > 1)
{
format(string2,128,"{AA3333}AdminWARNING:{FFFFFF} %s has banned %s's account, for reason: %s",RemoveUnderScore(playerid),RemoveUnderScore(targetid),reason);
SendClientMessage(i,-1,string2);
Kick(targetid);
}
}
}
}
}
return 1;
}
Re: Offline edit playerinfo -
Isolated - 29.07.2014
What saving system do you use? If it's MySQL/SQLite would you just use a query, "UPDATE .. WHERE `Username`='%s'". If it's a file based system, check if the named file exists. So, "%s.ini". %s = username. Then open it, and set the value.
Re: Offline edit playerinfo -
Abagail - 29.07.2014
Well you need to tell us if you're using MySQL or ini.
Re: Offline edit playerinfo -
jackx3rx - 30.07.2014
I'm using ini.
Re: Offline edit playerinfo -
Tamer - 30.07.2014
If you are using Y_INI
https://sampforum.blast.hk/showthread.php?tid=388612
Re: Offline edit playerinfo -
coole210 - 30.07.2014
Well first of all I don't think it's wise to continuously kick the targetid in your for loop, cause then it'll kick them for every admin online in the server. If you save your ban information on disconnect it should work to save their info, then when they login you'll see that they're banned and you can kick/ban them again. Otherwise to do basically anything with an offline player you make a parameter for their name in your command and see if the file exists. If it does, then check to see if the player is banned and if so unban them and their IP.
Re: Offline edit playerinfo -
jackx3rx - 30.07.2014
Quote:
Originally Posted by Tamer T
|
Thanks.