HELP Register/login system[Need good scripters]
#1

Hi , i who can make a /register system ?

it save Name+password+admin+VIp+money+score(1kill=1score)


Please HELP i don't want a FS i would like a short Code of that ...
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=273088

Yabba Dabba Doo
Reply
#3

Код:
#include <a_samp>
#include <Dini>
#include <Dutils>
#include <DUDB>


enum PlayerInfo
{
	Username,		//0
	AdminLevel,		//1
	Money,			//2
	VIP,			//3
 	Score,			//4
}
new pInfo[MAX_PLAYERS][PlayerInfo];
new IsLogged[MAX_PLAYERS]=0;

#define D_REGISTER 	1000	//Register dialog
#define D_LOGIN     1001	//Login dialog

public OnPlayerConnect(playerid)
{
	IsLogged[playerid]=0;

	new
	    file[128],
    format(file,sizeof(file),"\\Users\\%s.ini", GetName(playerid));
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, D_REGISTER, DIALOG_STYLE_INPUT, "[System]: Username not found in database.", "Welcome, please write a password in the box below to register your account.", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_INPUT, "[Sysyem]: Username found in database.", "Please log in below.", "Login", "Leave");
    }
}

public OnPlayerDisconnect(playerid, reason)
{
	new
	    file[128];
    format(file,sizeof(file),"\\Users\\%s.ini", GetName(playerid));
    if(IsLogged[playerid] == 1)
    {
		SaveFile(playerid);
    }
    IsLogged[playerid]=0;

    new
        string[64];
    switch(reason)
    {
        case 0: format(string,sizeof string,"%s left the server. (Timed out)",GetName(playerid));
        case 1: format(string,sizeof string,"%s left the server. (Leaving)",GetName(playerid));
        case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",GetName(playerid));
    }
    SendClientMessageToAll(0xFFFFFFAA,string);

    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

////////////////////////////////////////////////////////////////////////////////Register
	if(dialogid == D_REGISTER)
	{
	    if (!response)
	    {
	        SendClientMessage(playerid, COLOR_RED, "[System]: You have been automatically disconnected!");
	        Kick(playerid);
			return 1;
		}

		if (isnull(inputtext) || strlen(inputtext) > 100) return ShowPlayerDialog(playerid, D_REGISTER, DIALOG_STYLE_INPUT, "[System]: Username not found in database.", "Welcome, please write a password in the box below to register your account.", "Register", "Leave");

		CreateFile(playerid, inputtext);

		SendClientMessage(playerid, COLOR_GREEN, "[System]: Account Created!");

		new
	  	    string[128];
		format(string,sizeof(string), "%s has registered a account!", GetName(playerid));
	  	SendClientMessageToAll(COLOR_RED, string);
	  	SendClientMessage(playerid, COLOR_GREEN, "[System]: You have been automatically logged in.");
	  	LoadFile(playerid);
	  	IsLogged[playerid]=1;

	}

////////////////////////////////////////////////////////////////////////////////Login
	if(dialogid == D_LOGIN)
	{
	    new
	        file[128];
	    format(file,sizeof(file),"\\Users\\%s.ini", GetName(playerid));
		if (!response)
	    {
			SendClientMessage(playerid, COLOR_RED, "[System]: You have been automatically disconnected!");
			Kick(playerid);
			return 1;
		}

		if (isnull(inputtext)) return ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_INPUT, "[Sysyem]: Username found in database.", "Please log in below.", "Login", "Leave");

		new
			tmp;
		tmp = dini_Int(file, "Password");

		if(udb_hash(inputtext) != tmp)
		{
  			new string[128];
			format(string, 256, "[System]: The password %s does not match %s's password.", inputtext, GetName(playerid));
			SendClientMessage(playerid, COLOR_RED, string);
			ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_INPUT, "[Sysyem]: Username found in database.", "Please log in below.", "Login", "Leave");

		}
		else
		{
	    	IsLogged[playerid]=1;
	    	LoadFile(playerid);
        	SendClientMessage(playerid, COLOR_GREEN, "[System]: You have succesfully logged in!");
		}


	}

	return 1;
}

stock CreateFile(id, inputtext[])
{
	new
 		file[128];
   	format(file,sizeof(file),"\\Users\\%s.ini", GetName(id));

	dini_Create(file);
	dini_Set(file,"Username",GetName(id));
	dini_IntSet(file,"Password", udb_hash(inputtext));
	dini_IntSet(file,"AdminLevel", 0);
	dini_IntSet(file,"Money", 1000);
	dini_IntSet(file,"VIP", fCiv);
	dini_IntSet(file,"Score", 0);
	return 1;
}

stock LoadFile(id)
{
	new
 		file[128];
   	format(file,sizeof(file),"\\Users\\%s.ini", GetName(id));

	pInfo[id][Username] = dini_Int(file, "Username");
	pInfo[id][AdminLevel] = dini_Int(file, "AdminLevel");
	pInfo[id][Money] = dini_Int(file, "Money");
	pInfo[id][VIP] = dini_Int(file, "VIP");
	new score1 = dini_Int(file, "Score");
	SetPlayerScore(playerid, score1);
 	SetPlayerMoney(id, dini_Int(file, "Money"));
 	return 1;
}

stock SaveFile(id)
{
		new
 			file[128];
   		format(file,sizeof(file),"\\Users\\%s.ini", GetName(id));

		dini_IntSet(file, "AdminLevel", pInfo[id][AdminLevel]);
        dini_IntSet(file, "Money", GetPlayerMoney(id));
        dini_IntSet(file, "Score", GetPlayerScore(playerid));
        dini_IntSet(file, "VIP", pInfo[id][VIP]);
        dini_IntSet(file, "Tutored", pInfo[id][Tutored]);
        return 1;
}

stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
Change the colors to the colors of your liking.
Reply
#4

I'm with Berlovan on this one > https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#5

Thanx all ! and thanx a lot Intoxicated fot your code
Reply
#6

Quote:
Originally Posted by ServerScripter
Посмотреть сообщение
Thanx all ! and thanx a lot Intoxicated fot your code
No no no. Do NOT use the code provided by Intoxicated.
Reply
#7

there are a problem with your code :

Код:
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(27) : warning 219: local variable "format" shadows a variable at a preceding level
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(27) : error 001: expected token: ";", but found "("
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(27) : warning 203: symbol is never used: "format"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(70) : error 017: undefined symbol "COLOR_RED"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(75) : error 017: undefined symbol "isnull"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(79) : error 017: undefined symbol "COLOR_GREEN"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(84) : error 017: undefined symbol "COLOR_RED"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(85) : error 017: undefined symbol "COLOR_GREEN"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(99) : error 017: undefined symbol "COLOR_RED"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(104) : error 017: undefined symbol "isnull"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(114) : error 017: undefined symbol "COLOR_RED"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(122) : error 017: undefined symbol "COLOR_GREEN"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(142) : error 017: undefined symbol "fCiv"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(158) : error 017: undefined symbol "playerid"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(171) : error 017: undefined symbol "playerid"
C:\Documents and Settings\mrich\Bureau\tyr\codmw2\filterscripts\Register.pwn(173) : error 017: undefined symbol "Tutored"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


14 Errors.
Reply
#8

Quote:
Originally Posted by Kush
Посмотреть сообщение
No no no. Do NOT use the code provided by Intoxicated.
ok but i found the tutorial very Hard with Y_INI ....(12 steps xD)
Reply
#9

here you go:
1.
2.
3.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)