29.03.2013, 07:56
hello everyone this is my setlevel cmd it works but when im in game only and when i relog/reconnect it sets my level back to 5 which is in file
its my file
and in that it looks like this
but that level does not change when i change level
pawn Код:
CMD:setlevel(playerid,params[]) {
if(gPlayerInfo[playerid][LoggedIn] == 1) {
if( IsPlayerAdmin(playerid)) {
new file[100], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), PlayerFile, name);
new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setlevel [playerid] [level]");
new player1, level, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(isnull(tmp2)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setlevel [playerid] [level]");
level = strval(tmp2);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
if(gPlayerInfo[player1][LoggedIn] == 1) {
if(level > MAX_ADMIN_LEVEL ) return SendClientMessage(playerid,COLOR_RED,"ERROR: Incorrect Level");
if(level == gPlayerInfo[player1][Level]) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is already this level");
// CMDMessageToAdmins(playerid,"SETLEVEL");
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
new year,month,day; getdate(year, month, day); new hour,minute,second; gettime(hour,minute,second);
if(level > 0) format(string,sizeof(string),"Administrator %s has set you to Administrator Status [level %d]",adminname, level);
else format(string,sizeof(string),"Administrator %s has set you to Player Status [level %d]",adminname, level);
SendClientMessage(player1,COLOR_BLUE,string);
if(level > gPlayerInfo[player1][Level]) GameTextForPlayer(player1,"Promoted", 2000, 3);
else GameTextForPlayer(player1,"Demoted", 2000, 3);
format(string,sizeof(string),"You have made %s Level %d on %d/%d/%d at %d:%d:%d", playername, level, day, month, year, hour, minute, second); SendClientMessage(playerid,COLOR_BLUE,string);
format(string,sizeof(string),"Administrator %s has made %s Level %d on %d/%d/%d at %d:%d:%d",adminname, playername, level, day, month, year, hour, minute, second);
SaveToFile("AdminLog",string);
gPlayerInfo[player1][Level] = dini_Int(file, "Level");//trying to add in file
// gPlayerInfo[player1][Level] = level;
return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
} else return SendClientMessage(playerid,COLOR_RED,"ERROR: Player must be registered and logged in to be admin");
} else return SendClientMessage(playerid, COLOR_RED, "Player is not connected");
} else return SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be rcon Administrator to use this command");
} else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be logged in to use this commands");
}
Код:
#define PlayerFile "CAdmin/Users/%s.ini"
pawn Код:
Name=cbcandyboy
Ip=127.0.0.1
Registered=1
Registered On:=29/3/2013
Password=147849867
Level=5
Money=0
Score=0
Last On:=29/3/2013