07.06.2016, 18:54
PHP код:
CMD:setlevel(playerid,params[])
{
if(pInfo[playerid][pLevel] >= 9 || IsPlayerAdmin(playerid))
{
new id,level,Jfile[100],year,month,day,hour,minute,second;
if(sscanf(params, "ui", id, level)) return
SendClientMessage(playerid, 0xFFFF00C8, "Usage: /Setlevel <PlayerID> <Level>") ;
if(level < 0) return SendClientMessage(playerid,red,"Invalid level(level must be greater than -1)");
if(IsPlayerConnected(id))
{
if(level == pInfo[id][pLevel])
return SendClientMessage(playerid,red,"Player is already in this level!");
if(level > MaxAdminLevel)
{
format(Jstring,sizeof(Jstring),"Error: Maximum admin level is %d",MaxAdminLevel); return SendClientMessage(playerid,red,Jstring);
}
if(pInfo[id][Logged] == 0) return SendClientMessage(playerid,red,"Error: This player is not loggedIn or not registered!");
CommandToAdmins(playerid,"setlevel");
getdate(year, month, day);
gettime(hour,minute,second);
/*switch(level)
{
case 0: LevelName = "Player Status";
case 1: LevelName = ADMIN_LEVEL_1;
case 2: LevelName = ADMIN_LEVEL_2;
case 3: LevelName = ADMIN_LEVEL_4;
case 4: LevelName = ADMIN_LEVEL_3;
case 5: LevelName = ADMIN_LEVEL_5;
default: LevelName = ADMIN_LEVEL_6;
}*/
format(Jstring,sizeof(Jstring),"You have given %s level: %d , Date: %d/%d/%d at %d:%d:%d",GetName(id), level, day, month, year ,hour, minute, second);
SendClientMessage(playerid,blue,Jstring);
if(level> pInfo[id][pLevel])
{
format(Jstring,sizeof(Jstring),"Administrator %s has enabled for you admin feuture level: %d <Promoted on %d/%d/%d at %d:%d:%d>",GetName(playerid), level,day, month, year,hour, minute, second),GameTextForPlayerEx(id,"~B~congratulations!~N~~G~Promoted", 2000, 3);
SendClientMessage(id,lighterblue,Jstring);
format(Jstring,sizeof(Jstring),"[PROMOTED] %s has changed %s's level from %d to %d",GetName(playerid),GetName(id),pInfo[id][pLevel], level);
WriteToLog(Jstring,"LevelChanges");
}
else
{
format(Jstring,sizeof(Jstring),"Administrator %s has set you level: %d <Demoted on %d/%d/%d at %d:%d:%d>",GetName(playerid), level,day, month, year,hour, minute, second),GameTextForPlayerEx(id,"~R~Demoted", 2000, 3);
SendClientMessage(id,red,Jstring);
format(Jstring,sizeof(Jstring),"[DEMOTED] %s has changed %s's level from %d to %d",GetName(playerid),GetName(id),pInfo[id][pLevel], level);
WriteToLog(Jstring,"LevelChanges");
}
pInfo[id][pLevel] = level;
format(Jfile, 100, ACCOUNTS_PATH, GetName(id));
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteInt(ACCOUNT, "Level", pInfo[id][pLevel]);
INI_Close(ACCOUNT);
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}