@@Fuhrer poftim:
YCMD:setadmin( playerid, params[], help ) {
if( PlayerInfo[ playerid ][ pAdmin ] < 6 )
return SCM( playerid, COLOR_WHITE, AdminOnly );
new userID, level;
if( sscanf( params, "ui", userID, level ) )
return SCM( playerid, COLOR_GREY, "Usage: {FFFFFF}/setadmin <playerid/name> <level>" );
if( !IsPlayerConnected( userID ) || userID == INVALID_PLAYER_ID )
return SCM( playerid, COLOR_GREY, "Eroare: Invalid playerid/name." );
if( level < 0 || level > 8 )
return SCM( playerid, COLOR_GREY, "Eroare: Invalid admin leve. ( 1 - 8, 0 = remove )" );
if( PlayerInfo[ userID ][ pAdmin ] > PlayerInfo[ playerid ][ pAdmin ] )
return SCM( playerid, COLOR_GREY, "Eroare: Acel jucator are un admin mai mare decat al tau." );
promotePlayerToAdmin( playerid, userID, level );
return true;
}
function promotePlayerToAdmin( playerid, userID, level ) {
if( level > PlayerInfo[ userID ][ pAdmin ] )
SCMF( userID, COLOR_YELLOW, "* Felicitari, ai fost promovat la admin nivel %d de catre administratorul %s.", level, GetName( playerid ) );
else if( level < PlayerInfo[ userID ][ pAdmin ] && level != 0 )
SCMF( userID, COLOR_YELLOW, "* Ai fost retrogradat din functia de admin nivel %d la admin nivel %d de catre administratorul %s.", PlayerInfo[ userID ][ pAdmin ], level, GetName( playerid ) );
else if( level == 0 )
SCMF( userID, COLOR_YELLOW, "* Ai fost exclus din Echipa Staff a server-ului Ryse de catre administratorul %s.", GetName( playerid ) );
if(level) Iter_Add( PlayerAdmins, userID );
else removePlayerAdmin( userID );
PlayerInfo[ userID ][ pAdmin ] = level;
finishAchievement( userID, 27 );
new string[ 128 ];
format( string, sizeof string, "(AdminInfo): {FFFFFF}%s a fost promovat la admin nivel %d de catre administratorul %s.", GetName( userID ), level, GetName( playerid ) );
SendAdminHelperMessage( COLOR_LOGS, string );
SCMF( playerid, COLOR_YELLOW, "* I-ai setat lui %s nivelul de admin la %d.", GetName( userID ), level);
new gQuery[ 128 ];
mysql_format( SQL, gQuery, sizeof gQuery, "UPDATE `users` SET `Admin` = '%d WHERE `ID` = '%d'", PlayerInfo[ userID ][ pAdmin ], PlayerInfo[ userID ][ pSQLID ] );
mysql_tquery( SQL, gQuery, "", "" );
format( string, sizeof string, "* Jucatorul %s a fost promovat la admin nivel %d de catre administratorul %s. ", GetName( userID ), level, GetName( playerid ) );
mysql_format( SQL, gQuery, sizeof gQuery, "INSERT INTO `server_staff_logs` (`Text`) VALUES ('%s')", string );
mysql_tquery( SQL, gQuery, "", "" );
return true;
}
function removePlayerAdmin( userID ) {
PlayerInfo[ userID ][pAW] = 0;
SpecFaction[ userID ] = 0;
StopFly( userID );
UsedFly[ userID ] = 0;
SetPlayerHealthEx( userID, 99.0 );
Iter_Remove( PlayerAdmins, userID );
new gQuery[ 128 ];
mysql_format( SQL, gQuery, sizeof gQuery, "UPDATE `users` SET `AW` = '%d WHERE `ID` = '%d'", PlayerInfo[ userID ][pAW], PlayerInfo[ userID ][ pSQLID ] );
mysql_tquery( SQL, gQuery, "", "" );
return true;
}