|
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 |
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;
}
|
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;
}
|