23.08.2013, 09:47
How to make setadmin/setadminlevel cmd with this login register :
I forgot how to do
pawn Код:
//-------------------------------------------------------------------------
#include < a_samp >
#include < zcmd >
#include < sscanf2 >
#include < YSI\y_ini >
//-------------------------------------------------------------------------
native WP_Hash(buffer[],len,const str[]);
//-------------------------------------------------------------------------
#define DIRECTORY "/ACCOUNTS/%s.ini"
//-------------------------------------------------------------------------
#define FILTERSCRIPT
#define VERSION "v0.0"
#define WEBSITE "www.******.com"
#define SERVER_NAME "SAMP 0.3x Server"
//-------------------------------------------------------------------------
#define CMDS_ERROR "Command not available! Use /cmds for all command list!"
#define PLAYER_ERROR "Player is'nt connect!"
#define LEVEL_ERROR "You can't use this command!"
#define CASH_ERROR "You don't have enough money!"
//-------------------------------------------------------------------------
#define TEMPADMIN "Trainer Admin"
#define LVL1 "Moderator"
#define LVL2 "Administrator"
#define LVL3 "Master Administrator"
#define LVL4 "Holy Administrator"
#define LVL5 "Rcon Administrator"
#define LVL1000 "Owner"
//-------------------------------------------------------------------------
#define VIP1 "Bronze VIP"
#define VIP2 "Silver VIP"
#define VIP3 "Gold VIP"
//-------------------------------------------------------------------------
#define D_CREDITS 2000
#define D_CMDS 2001
#define D_RULES 2002
#define D_VIPINFO 2003
#define D_REGISTER 2004
#define D_LOGIN 2005
#define D_SUCCES_1 2006
#define D_SUCCES_2 2007
//-------------------------------------------------------------------------
#define YELLOW 0xFFFF00FF
#define RED 0xFF0000FF
#define GOLD 0xB8860BFF
//-------------------------------------------------------------------------
#define C_WHITE "{FFFFFF}"
#define C_GREEN "{33CC33}"
#define C_YELLOW "{E1E11E}"
#define C_RED "{FF0000}"
//-------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n-------------FILTERSCRIPT-------------");
print("21_8_2013 #VERSION loaded!");
print("-------------FILTERSCRIPT-------------\n");
SetTimer("SendMSG", 60000, true);
return 1;
}
//-------------------------------------------------------------------------
public OnFilterScriptExit()
{
print("\n-------------FILTERSCRIPT-------------");
print("21_8_2013 #VERSION unloaded!");
print("-------------FILTERSCRIPT-------------\n");
return 1;
}
//-------------------------------------------------------------------------
enum PlayerInfo
{
Pass[129],
Adminlevel,
VIPlevel,
Money,
Scores,
Kills,
Deaths
}
//-------------------------------------------------------------------------
new pInfo[MAX_PLAYERS][PlayerInfo];
new pname[MAX_PLAYER_NAME];
//-------------------------------------------------------------------------
new randmsgs[][] =
{
"Welcome to #SERVER_NAME, the best Free-Roam server!",
"Use /cmds to see all list of commands avalaible!",
"Go to our website to join us at #WEBSITE"
};
//-------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
new pIP[16];
GetPlayerIp(playerid, pIP, sizeof(pIP));
if(!strcmp(pIP, "127.0.0.1"))
SendClientMessage(playerid, GOLD, "Welcome Owner, have a nice day !");
SendClientMessage(playerid, GOLD, "For all Owner commands, use /ocmds !");
{
new str[22];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s has joined the server !", pname);
SendClientMessageToAll(YELLOW, str);
{
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid,D_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back,\n This account is "C_RED"registered !\nInsert your "C_GREEN"password "C_WHITE"to login to your "C_YELLOW"account","Login","Quit");
}
else
{
ShowPlayerDialog(playerid,D_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome,\n This account is not "C_RED"registered !\nEnter your own "C_GREEN"password "C_WHITE"to create a new "C_YELLOW"account !\nPlease enter the "C_GREEN"password !","Register","Quit");
}
}
}
return 1;
}
//-------------------------------------------------------------------------
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == D_REGISTER)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,D_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome,\n This account is not "C_RED"registered !\nEnter your own "C_GREEN"password "C_WHITE"to create a new "C_YELLOW"account !\nPlease enter the "C_GREEN"password !","Register","Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player_Database");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"Admin_Level",0);
INI_WriteInt(file,"VIP_Level",0);
INI_WriteInt(file,"Money",0);
INI_WriteInt(file,"Scores",0);
INI_WriteInt(file,"Kills",0);
INI_WriteInt(file,"Deaths",0);
INI_Close(file);
ShowPlayerDialog(playerid, D_SUCCES_1, DIALOG_STYLE_MSGBOX, "Success","You have succesfully "C_GREEN"registered !","Ok","");
}
}
//-------------------------------------------------------------------------
if(dialogid == D_LOGIN)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass,pInfo[playerid][Pass]))
{
INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
SetPlayerScore(playerid,pInfo[playerid][Scores]);
GivePlayerMoney(playerid,pInfo[playerid][Money]);
ShowPlayerDialog(playerid, D_SUCCES_2, DIALOG_STYLE_MSGBOX, "Notice","Welcome back,\nYou have successfully "C_GREEN"logged in !","Ok","");
}
else
{
ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_INPUT,"Login","Welcome back,\n"C_WHITE"This account was "C_RED"registered ! \nInsert your "C_GREEN"password "C_WHITE"to login to your "C_YELLOW"account !\n"C_RED"Incorrect password !","Login","Quit");
return 1;
}
}
}
return 1;
}
//-------------------------------------------------------------------------
public OnPlayerDisconnect(playerid, reason)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player_Database");
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_Close(file);
{
new str[39];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
case 0: format(str, sizeof(str), "%s has left the server. (Lost Connection)", pname);
case 1: format(str, sizeof(str), "%s has left the server. (Leaving)", pname);
case 2: format(str, sizeof(str), "%s has left the server. (Kicked)", pname);
}
SendClientMessageToAll(RED, str);
}
return 1;
}
//-------------------------------------------------------------------------
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129);
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);
INI_Int("Money",pInfo[playerid][Money]);
INI_Int("Scores",pInfo[playerid][Scores]);
INI_Int("Kills",pInfo[playerid][Kills]);
INI_Int("Deaths",pInfo[playerid][Deaths]);
return 1;
}
//-------------------------------------------------------------------------
stock Path(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),DIRECTORY,playername);
return string;
}
//-------------------------------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
pInfo[killerid][Kills]++;
pInfo[killerid][Scores]++;
pInfo[playerid][Deaths]++;
pInfo[playerid][Scores]--;
return 1;
}