12.04.2008, 10:57
pawn Код:
//OnGameModeInit()
if(!dini_Exists("Levels")) dini_Create("Levels");
pawn Код:
//OnPlayerConnect(playerid)
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,MAX_PLAYER_NAME);
if(!dini_Int("Levels",pname)) dini_IntSet("Levels",pname,0);
pawn Код:
//OnPlayerCommandText(playerid,cmdtext[])
new idx;
if(!strcmp("/setlevel",cmdtext,true))
{
new Player = strtok(cmdtext, idx);
if(!strlen(Player)) return SendClientMessage(playerid,COLOR,"/setlevel [playerid] [0-4]");
new PlayerID = strval(Player);
if(!IsPlayerConnected(PlayerID)) return SendClientMessage(playerid,COLOR,"Invalid playerid!");
new Level = strval(strtok(cmdtext, idx));
if((Level < 0) || (Level > 4)) return SendClientMessage(playerid,COLOR,"/setlevel [playerid] [0-4]");
new pname[MAX_PLAYER_NAME];
GetPlayerName(PlayerID,pname,MAX_PLAYER_NAME);
if(dini_Int("Levels",pname) == Level) return SendClientMessage(playerid,COLOR,"The player already have this level");
new string[128];
dini_IntSet("Levels",pname,Level);
format(string,sizeof(string),"%s(%d) got a new Level (%d)",pname,PlayerID,Level);
SendClientMessage(playerid,COLOR,string);
}