help dcmd_setadmin
#1

Hey i got a problem with my dudb..I dont know how to use the dcmd_setadmin ==> about how to save the players level and I need a hand here

enumaration..

Код:
enum PlayerInfo
{
	Level,
	Banned,
	Muted
};
new PlayerData[MAX_PLAYERS][PlayerInfo];
// dcmd

Код:
dcmd_setadmin(playerid,params[]) {
	if(PlayerData[playerid][Level] == 3)
  {
  new tmp[256],idx;
  tmp = strtok(params,idx);
  if(!strlen(tmp))
 	{
	  	return SystemMsg(playerid,"Usage: /setadmin <playerid> <level 1-3>");
  }
  new id = strval(tmp);
  if(!IsPlayerConnected(id))
  {
  	return SystemMsg(playerid,"Incorrect player !");
  }
  new level = strval(tmp);
  if(level > 4)
  {
  	return SystemMsg(playerid,"Error: Maximum level - 3");
  }
  new string[256], pname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
  GetPlayerName(playerid,pname,sizeof(pname));
  GetPlayerName(playerid,adminname,sizeof(adminname));
  format(string,sizeof(string),"[ ! ]===> %s has made you an administrator level %d)",adminname,level);
  SendClientMessage(id,COLOUR_RED,string);
  format(string,sizeof(string),"You made %s level admin %d",pname,level);
  SendClientMessage(playerid,COLOUR_RED,string);
  dUserSetINT(PlayerName(id)).("level",PlayerData[playerid][Level]);
  return true;
  }
  return 1;
}
// on disconnect

Код:
public OnPlayerDisconnect(playerid, reason)
{
	if (PLAYERLIST_authed[playerid]) {
  dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
 }
	PLAYERLIST_authed[playerid]=false;
 	return false;
}
Reply
#2

hmm i dunno about dubd tho but i can see that if u do
if(level > 4)
it will be maxlvl 4 :P
do
if(level >= 4) :P
this means if its qual to 4 and higher

urs means if its higher than four means every that equals5 and higher^^
Reply
#3

Try
pawn Код:
dUserSetINT(PlayerName(id)).("level",dUserINT(PlayerName(playerid)).PlayerData[playerid][Level]);
Also, use dini, It's easier
Reply
#4

ok I will try with dini,thanks
Reply
#5

If you want to try dudb again, just set the player's admin level via that command then save it OnPlayerDisconnect, like this:

Код:
dUserSetINT(PlayerName(playerid)).("AdminLevel", PlayerData[playerid][Level]);
Then make a /login command and load it there with:

Код:
PlayerData[playerid][Level] = (dUserINT(PlayerName(playerid)).("AdminLevel"));
Reply
#6

Fixed already,thx for the help anyway,Im using dini

PlayerData[playerid][Level] = dini_Int(file,"Level");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)