SA-MP Forums Archive
demote offline player using name[+rep] - 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: demote offline player using name[+rep] (/showthread.php?tid=630380)



demote offline player using name[+rep] - maaz - 13.03.2017

How can I demote or promote offline player using a CMD in the server?
For example : /apromote [name] [level].
All my users are saved in scriptfiles/Admin/users
There are .ini files for every user and it contains LEVEL = levelno.
Please help me, thank you!


Re: demote offline player using name[+rep] - Flamehaze7 - 13.03.2017

Quote:
Originally Posted by maaz
View Post
How can I demote or promote offline player using a CMD in the server?
For example : /apromote [name] [level].
All my users are saved in scriptfiles/Admin/users
There are .ini files for every user and it contains LEVEL = levelno.
Please help me, thank you!
You should try to open his .ini file and them format the string inside and save the file.
You can easily do this in SQL/MySQL but for INI i think that will be tricky to do


Re: demote offline player using name[+rep] - maaz - 13.03.2017

Quote:
Originally Posted by Flamehaze7
View Post
You should try to open his .ini file and them format the string inside and save the file.
You can easily do this in SQL/MySQL but for INI i think that will be tricky to do
if you could help me with it. I would be thankful.
Or anyone else can help me with this?
i use y_ini.


Re: demote offline player using name[+rep] - maaz - 13.03.2017

will this work?
Code:
CMD:osetlvl(playerid,params[])
{
    if(!(PlayerInfo[playerid][Level] >= 6)) return SendClientMessage(playerid, COLOR_LIGHTRED,"You are not authorized to use this command");
    new
		_name[ 24 ],
		_level
	;
	if(sscanf(params, "s[24]d", _name, _level)) return SendClientMessage(playerid, COLOR_LIGHTRED,"Usage: /osetlvl <Name> <level>");
	new
		string[ 32 ]
	;
	format(string,sizeof(string),"Admin/Users/%s.ini",_name);
    if(fexist(string))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Level", _level);
        INI_Close(File);
        // I don't really understand that message
    }
    else SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::..");
    return 1;
}



Re: demote offline player using name[+rep] - Flamehaze7 - 13.03.2017

Quote:
Originally Posted by maaz
View Post
will this work?
Code:
CMD:osetlvl(playerid,params[])
{
    if(!(PlayerInfo[playerid][Level] >= 6)) return SendClientMessage(playerid, COLOR_LIGHTRED,"You are not authorized to use this command");
    new
		_name[ 24 ],
		_level
	;
	if(sscanf(params, "s[24]d", _name, _level)) return SendClientMessage(playerid, COLOR_LIGHTRED,"Usage: /osetlvl <Name> <level>");
	new
		string[ 32 ]
	;
	format(string,sizeof(string),"Admin/Users/%s.ini",_name);
    if(fexist(string))
    {
        new INI:File = INI_Open(string);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Level", _level);
        INI_Close(File);
        // I don't really understand that message
    }
    else SendClientMessage(playerid,COLOR_YELLOW,"{FF0000}..::{FF6347}[Database]:Account not found{FF0000}::..");
    return 1;
}
Try it and let me know, by checking it, it should work.


Re: demote offline player using name[+rep] - maaz - 13.03.2017

Quote:
Originally Posted by Flamehaze7
View Post
Try it and let me know, by checking it, it should work.
It didn't work. i have no idea why :/