29.04.2014, 19:03
pawn Код:
YCMD:setadmin(playerid, params[], help)
{
if( pInfo[playerid][Adminlevel] >= 4 )
{
new
TargetID,
tLevel,
tReason[50],
AdmRank[128];
if( !sscanf(params, "uiS(No reason specified)[50]", TargetID, tLevel, tReason) )
{
if( tLevel > 6 ) return SendClientMessage( playerid, -1, "[SYSTEM]: Maximum Level: 6." );
if( pInfo[TargetID][Adminlevel] == tLevel ) return SendClientMessage( playerid, -1, "[SYSTEM]: This player is already this level." );
if( strlen( tReason ) > 50 ) return SendClientMessage( playerid, -1, "[SYSTEM]: Please use between 0-50 characters." );
if( !IsPlayerConnected(TargetID)) return SendClientMessage( playerid, -1, "[SYSTEM]: Invalid ID. Please try again." );
new
MyString[128],
TargetString[128];
if(pInfo[TargetID][Adminlevel] == 0) { AdmRank = "Regular Player"; }
else if(pInfo[TargetID][Adminlevel] == 1) { AdmRank = "Moderator"; }
else if(pInfo[TargetID][Adminlevel] == 2) { AdmRank = "Professional Moderator"; }
else if(pInfo[TargetID][Adminlevel] == 3) { AdmRank = "Administrator"; }
else if(pInfo[TargetID][Adminlevel] == 4) { AdmRank = "Head Administrator"; }
else if(pInfo[TargetID][Adminlevel] >= 5) { AdmRank = "Owner"; }
if( pInfo[TargetID][Adminlevel] < tLevel )
{
format( MyString, sizeof MyString, "[SYSTEM]: You promoted %s(ID:%d) to a %s. Level: (%i). Reason: %s", GetName(TargetID), TargetID, AdmRank, tLevel, tReason );
format( TargetString, sizeof TargetString, "[SYSTEM]: You have been promoted by %s(ID:%d) to a %s. Level: (%i). Reason: %s", GetName(playerid), playerid, AdmRank, tLevel, tReason );
SendClientMessage( TargetID, -1, TargetString );
}
else
{
format( MyString, sizeof MyString, "[SYSTEM]: You demoted %s(ID:%d) to a %s. Level: (%i). Reason: %s", GetName(TargetID), TargetID, AdmRank, tLevel, tReason );
format( TargetString, sizeof TargetString, "[SYSTEM]: You have been demoted by %s(ID:%d) to a %s. Level: (%i). Reason: %s", GetName(playerid), playerid, AdmRank, tLevel, tReason );
SendClientMessage( TargetID, -1, TargetString );
}
SendClientMessage( playerid, -1, MyString );
pInfo[TargetID][Adminlevel] = tLevel;
}
else
return SendClientMessage( playerid, -1, "[SYSTEM]: /setadmin <TargetID> <Level> <(OPTIONAL)Reason>" );
}
else
return SendClientMessage( playerid, -1, "[SYSTEM]: You have to be a moderator to use this command!" );
return 1;
}
i.e.
Owner - level 5 and 6
Head Admin - level 4
Admin - level 3
Pro Mod - level 2
Mod - level 1
but it displays incorrectly..
Owner - level 5 and 6
Owner - level 4
Head admin - level 3
Admin - level 2
Pro Mod - level 1
Mod - level 0