SA-MP Forums Archive
Can i make admin commands with this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can i make admin commands with this? (/showthread.php?tid=137534)



Can i make admin commands with this? - -Rebel Son- - 29.03.2010

I need to find a way to make admin commands like kick, ban, ect. but everytime i try i fail misserably, here is my register and login code.

if i do get it, it wont save the admin level, so .. i cant make it right.
heres my code. i need a example of a admin code for this.
Код:
	if(strcmp(cmd, "/register", true) == 0)
	{
  if(MiniGame[playerid] == 1) return GameTextForPlayer(playerid,"You cant use this command because you are in a minigame",5000,4);
	new name[MAX_PLAYER_NAME];
	new IP[16];
	tmp = strtok(cmdtext, idx);
	GetPlayerName(playerid, name, sizeof(name));
  GetPlayerIp(playerid,IP,sizeof(IP));
	if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /register [password]");
	format(file,sizeof(file),"%s.ini",name);
	if(!fexist(file))
	{
  dini_Create(file);
  dini_IntSet(file, "Password", udb_hash(tmp));
	dini_IntSet(file,"Adminlevel", AdminLevel);
	dini_IntSet(file,"Cash", GetPlayerMoney(playerid));
  dini_IntSet(file,"Score", GetPlayerScore(playerid));
	dini_IntSet(file,"Skin", GetPlayerSkin(playerid));
  dini_IntSet(file,"Loc", GetPlayerPos(playerid, x, y, z));
	SendClientMessage(playerid, COLOR_LIME, "[System]: Account Created! you can now /login [Password]!");
	PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
	GetPlayerName(playerid, name, sizeof(name));
	printf("%s has registered a account!", name);
	}
	else
	{
  SendClientMessage(playerid, COLOR_RED, " Account Already Found In Database");
  PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
	}
  return 1;
  }
	if(strcmp(cmd, "/login", true) == 0)
	{
  if(MiniGame[playerid] == 1) return GameTextForPlayer(playerid,"You cant use this command because you are in a minigame",5000,4);
	new PlayerName[24];
	tmp = strtok(cmdtext, idx);
	if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_SG, "USAGE: /login [password]");
  new name[MAX_PLAYER_NAME];
	if(IsLogged[playerid] == 1)
	{
	SendClientMessage(playerid, COLOR_RED, "You already are logged in!");
	return 1;
	}
	else
	{
	GetPlayerName(playerid, name, sizeof(name));
	format(file,sizeof(file),"%s.ini",name);
	if(fexist(file))
	{
	tmp2 = dini_Get(file, "Password");
	if(udb_hash(tmp) != strval(tmp2))
	{
	SendClientMessage(playerid, COLOR_RED, "Login Failed!");
  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	printf("%s has failed to login", name);
	}
	else
	{
	IsLogged[playerid] = 1;
	SetPlayerMoney(playerid, dini_Int(file, "Cash"));
	SetPlayerScore(playerid, dini_Int(file, "Score"));
	SetPlayerSkin(playerid, dini_Int(file, "Skin"));
  dini_IntSet(file,"AdminLevel", AdminLevel);
	dini_IntSet(file,"Loc", SetPlayerPos(playerid, x, y, z+10));
	PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
	SendClientMessage(playerid, COLOR_LIME, "[System]: Logged in!");
	}
	}
	}
	return 1;
	}



Re: Can i make admin commands with this? - -Rebel Son- - 29.03.2010

***BUMP***

Anyone?


Re: Can i make admin commands with this? - Jonny_lockhart - 29.03.2010

I suggest using one already made as a guide.


Re: Can i make admin commands with this? - Nero_3D - 29.03.2010

I suggest a proper indentation

and where you set/create/define AdminLevel

pawn Код:
dini_IntSet(file, "Adminlevel", AdminLevel);
and why are you saving things to the file at login ?
shouldnt they be loaded ?


Re: Can i make admin commands with this? - -Rebel Son- - 29.03.2010

Its still not saving the level, i go in, /register /login, setmyself admin, and then /update (saves my account info) and it still doesnt


Re: Can i make admin commands with this? - Jay420 - 30.03.2010

Quote:
Originally Posted by ♣ Joker ♠
and why are you saving things to the file at login ?
shouldnt they be loaded ?
Read this comment too..


Re: Can i make admin commands with this? - -Rebel Son- - 30.03.2010

I did, i i fixed that i think..., but i may have did it rong,
Код:
	if(strcmp(cmd, "/login", true) == 0)
	{
  if(MiniGame[playerid] == 1) return GameTextForPlayer(playerid,"You cant use this command because you are in a minigame",5000,4);
	new PlayerName[24];
	tmp = strtok(cmdtext, idx);
	if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_SG, "USAGE: /login [password]");
  new name[MAX_PLAYER_NAME];
	if(IsLogged[playerid] == 1)
	{
	SendClientMessage(playerid, COLOR_RED, "You already are logged in!");
	return 1;
	}
	else
	{
	GetPlayerName(playerid, name, sizeof(name));
	format(file,sizeof(file),"%s.ini",name);
	if(fexist(file))
	{
	tmp2 = dini_Get(file, "Password");
	if(udb_hash(tmp) != strval(tmp2))
	{
	SendClientMessage(playerid, COLOR_RED, "Login Failed!");
  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	printf("%s has failed to login", name);
	}
	else
	{
	IsLogged[playerid] = 1;
	SetPlayerMoney(playerid, dini_Int(file, "Cash"));
	SetPlayerScore(playerid, dini_Int(file, "Score"));
	SetPlayerSkin(playerid, dini_Int(file, "Skin"));
	PlayerInfo[playerid][Level] = dini_Int(file, "level");
	SendClientMessage(playerid, COLOR_LIME, "[System]: Logged in!");
	}
	}
	}
	return 1;
	}