Offline edit playerinfo
#1

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;
}
Reply
#2

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.
Reply
#3

Well you need to tell us if you're using MySQL or ini.
Reply
#4

I'm using ini.
Reply
#5

If you are using Y_INI

https://sampforum.blast.hk/showthread.php?tid=388612
Reply
#6

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.
Reply
#7

Quote:
Originally Posted by Tamer T
Посмотреть сообщение
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)