Problem with setting cmd's for admin
#1

After i do this on my player it don't set me as Level 1 admin ,could anyone help me?

Код:
CMD:setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] == 1 || IsPlayerAdmin(playerid))
    {
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"/setlevel / "#COL_SGREY#"[PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else if(lvl > 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE#"[ADMIN]"#COL_LRED#" Administrator level cannot be higher then 1!");
    else
	{
	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][Kills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][Deaths]);
    INI_WriteInt(File,"Adminlevel",PlayerInfo[playerid][Adminlevel]);
    INI_Close(File);
    PlayerInfo[id][Adminlevel] = lvl;
    }
    }
    return 1;
}
Reply
#2

kind of obvious:

pawn Код:
CMD:setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] == 1 || IsPlayerAdmin(playerid))
    {
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"/setlevel / "#COL_SGREY#"[PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else if(lvl > 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE#"[ADMIN]"#COL_LRED#" Administrator level cannot be higher then 1!");
    else
    {
    new INI:File = INI_Open(UserPath(playerid));
    PlayerInfo[id][Adminlevel] = lvl;
   INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][Kills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][Deaths]);
    INI_WriteInt(File,"Adminlevel",PlayerInfo[playerid][Adminlevel]);
    INI_Close(File);
    }
    }
    return 1;
}
Reply
#3

Now i made all as you stated and ingame im setting it for me ,and when i try use

Код:
CMD:freeze(playerid, params[])
{

	new targetid, string[128];
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"Only "#COL_SGREY#"Administrators can use this command");
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"/freeze"#COL_SGREY#"[PlayerID/PartOfName]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE#"[ERROR]"#COL_LRED#" Player not connected!");
	new pTargetName[24], pName[24];
	GetPlayerName(playerid,pName,24);
	GetPlayerName(targetid,pTargetName,24);
	format(string, sizeof(string), ""#COL_ORANGE#"[SERVER]"#COL_LRED#" %s has been frozen by Administrator %s.",pTargetName, pName);
	SendClientMessageToAll(COLOR_RED,string);
	TogglePlayerControllable(targetid, 0);

	return 1;
}
It shows me: Only Administrators can use this command
Reply
#4

my mistake:

pawn Код:
CMD:setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] == 1 || IsPlayerAdmin(playerid))
    {
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"/setlevel / "#COL_SGREY#"[PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else if(lvl > 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE#"[ADMIN]"#COL_LRED#" Administrator level cannot be higher then 1!");
    else
    {
    new INI:File = INI_Open(UserPath(id));
    PlayerInfo[id][Adminlevel] = lvl;
   INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(id));
    INI_WriteInt(File,"Kills",PlayerInfo[id][Kills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[id][Deaths]);
    INI_WriteInt(File,"Adminlevel",PlayerInfo[id][Adminlevel]);
    INI_Close(File);
    }
    }
    return 1;
}
u used playerid instead of id
Reply
#5

At that you have right ,got another prob with saving it on concrete player id in scriptfiles


Код:
[data]
Cash = 0
Kills = 0
Deaths = 0
Adminlevel = 1
It saved it as New account not on my player's nickname:

Код:
[data]
Password = 143983218
Cash = 100000
Kills = 2340
Deaths = 0
Adminlevel = 0
Reply
#6

Uhm for that I am not the best with Y_ini, Never used it actually.
So Sorry but I can't help you with that
Reply
#7

Quote:
Originally Posted by milanosie
Посмотреть сообщение
Uhm for that I am not the best with Y_ini, Never used it actually.
So Sorry but I can't help you with that
Okay thanks for helping me anyway I just will wait for other opinions in this case
Rep+
Reply
#8

pawn Код:
CMD:setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] == 1 || IsPlayerAdmin(playerid))
    {
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"/setlevel / "#COL_SGREY#"[PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else if(lvl > 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE#"[ADMIN]"#COL_LRED#" Administrator level cannot be higher then 1!");
    else
    {
    new INI:File = INI_Open(UserPath(id));
    PlayerInfo[id][Adminlevel] = lvl;
    INI_WriteInt(File,"Adminlevel",PlayerInfo[id][Adminlevel]);
    INI_Close(File);
    }
    }
    return 1;
}
When you're updating the admin level you're also updating other stats like money which is useless.
Reply
#9

Quote:
Originally Posted by FuTuяe
Посмотреть сообщение
pawn Код:
CMD:setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] == 1 || IsPlayerAdmin(playerid))
    {
    new id, lvl;
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY#"/setlevel / "#COL_SGREY#"[PlayerID/PartOfName] [Level]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
    else if(lvl > 1) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE#"[ADMIN]"#COL_LRED#" Administrator level cannot be higher then 1!");
    else
    {
    new INI:File = INI_Open(UserPath(id));
    PlayerInfo[id][Adminlevel] = lvl;
    INI_WriteInt(File,"Adminlevel",PlayerInfo[id][Adminlevel]);
    INI_Close(File);
    }
    }
    return 1;
}
When you're updating the admin level you're also updating other stats like money which is useless.
Every time when i use the command it's not creating it for player but only as new .txt document :/
Reply
#10

Quote:
Originally Posted by niere
Посмотреть сообщение
Every time when i use the command it's not creating it for player but only as new .txt document :/
Well don't expect people to help if you don't show proper code!

pawn Код:
INI_Open(UserPath(id));
there's your problem, you didn't post UserPath function here,
don't just copy paste code from anywhere, try to understand it first, probably will help ya in fixing the problem on your own.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)