25.01.2014, 11:00
use sscanf2 and ZCMD
#include <sscanf2>
#include <ZCMD>
#include <sscanf2>
#include <ZCMD>
PHP код:
cmd:setlevel(playerid,params[])
{
if(!AdminCommandCheck(playerid,"/setlevel"))
return 1;
new id,level;
if(sscanf(params,"ui",id,level))
return SendSyntaxWarning(playerid,"/setLevel <ID/Name> <Level>");
if(!IsValidPlayer(id) || level<0)
return SendSyntaxWarning(playerid,"/setlevel <ID/Name> <Level>");
if(PlayerInfo[pLoggedIn][id])
{
if(PlayerInfo[pAdminLevel][id]<PlayerInfo[pAdminLevel][playerid] || IsPlayerAdmin(playerid))
{
new string[128],string_en[128];
if(id!=playerid)
{
format(string,sizeof(string),"<$> -Admininfo-<#> Admin %s hat %s auf Adminlevel %d gestuft!",GetPlayerString(playerid),GetPlayerString(id),level);
format(string_en,sizeof(string_en),"<$> -Admininfo-<#> Admin %s has leveled %s to adminlevel %d!",GetPlayerString(playerid),GetPlayerString(id),level);
SendAdminMessage(COLOR_ADMIN,string,string_en,1,id);
if(GetPlayerLanguage(id)==LANG_DE)
format(string,sizeof(string),"<$> -Admininfo-<#> Du wurdest von Admin %s auf Adminlevel %d gestuft!",GetPlayerString(playerid),level);
else
format(string,sizeof(string),"<$> -Admininfo-<#> Admin %s has leveled you to adminlevel %d!",GetPlayerString(playerid),level);
SendClientMessageEx(id,COLOR_ADMIN,string);
}
else
{
format(string,sizeof(string),"<$> -Admininfo-<#> Admin %s hat sich auf Adminlevel %d gestuft!",GetPlayerString(playerid),level);
format(string_en,sizeof(string_en),"<$> -Admininfo-<#> Admin %s has leveled himself to adminlevel %d!",GetPlayerString(playerid),level);
SendAdminMessage(COLOR_ADMIN,string,string_en,1,INVALID_PLAYER_ID);
}
printf("[Level] %s hat %s auf Level %d gestuft!",PlayerName[playerid],PlayerName[id],level);
PlayerInfo[pAdminLevel][id]=level;
DOF_SetInt(DOF_File(PlayerName[id]),"level",level);
}
else
SendLanguageMessage(playerid,COLOR_WARNING,"<$> -Warnung-<#> Du kannst das Adminlevel dieses Admins nicht veraendern!","<$> -Warning-<#> You can't change the adminlevel of this admin!");
}
else
SendLanguageMessage(playerid,COLOR_WARNING,"<$> -Warnung-<#> Dieser Spieler ist entweder nicht registriert oder nicht eingeloggt!","<$> -Warning-<#> This player is not registered or logged in!");
return 1;
}