Problem with registration
#1

Hi all,in my server i use included gm registration system (with dudb)

I've a problem

All accounts are saved in "Scriptfiles"

I want the accounts are saved in "Scriptfiles/Accounts"

How?

Here is the currently dudb.inc but files are saved without extension. Only playername and stop.

Код:
/*
 *            DUDB functions
 *       © Copyright 2006-2007 by DracoBlue
 *
 * @version   : 2.4
 * @author    : DracoBlue (http://dracoblue.net)
 * @date      : 8th May 2006
 * @update    : 12th July 2007
 * @require   : DUtils 1.10
 * @require   : DINI 1.5
 *
 * This Unit is provided as is (no warranties).
 * Feel free to use it, a little message in 
 * about box is honouring thing, isn't it?
 *
 */

#if defined _dudb_included
  #endinput
#endif

#define _dudb_included
#pragma library dutils

#include <dutils>
#include <dini>
#define dUser(%1).( udb_User(%1,
#define dUserINT(%1).( udb_UserInt(%1,
#define dUserSet(%1).( udb_UserSet(%1,
#define dUserSetINT(%1).( udb_UserSetInt(%1,
#define dUserSetFLOAT(%1).( udb_UserSetFloat(%1,
#define dUserFLOAT(%1).( udb_UserFloat(%1,

stock udb_hash(buf[]) {
	new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

stock udb_encode(nickname[]) {
  new tmp[MAX_STRING];
  set(tmp,nickname);
  tmp=strreplace("_","_00",tmp);
  tmp=strreplace(";","_01",tmp);
  tmp=strreplace("!","_02",tmp);
  tmp=strreplace("/","_03",tmp);
  tmp=strreplace("\\","_04",tmp);
  tmp=strreplace("[","_05",tmp);
  tmp=strreplace("]","_06",tmp);
  tmp=strreplace("?","_07",tmp);
  tmp=strreplace(".","_08",tmp);
  tmp=strreplace("*","_09",tmp);
  tmp=strreplace("<","_10",tmp);
  tmp=strreplace(">","_11",tmp);
  tmp=strreplace("{","_12",tmp);
  tmp=strreplace("}","_13",tmp);
  tmp=strreplace(" ","_14",tmp);
  tmp=strreplace("\"","_15",tmp);
  tmp=strreplace(":","_16",tmp);
  tmp=strreplace("|","_17",tmp);
  tmp=strreplace("=","_18",tmp);
  return tmp;
}

stock udb_decode(nickname[]) {
  new tmp[MAX_STRING];
  set(tmp,nickname);
  tmp=strreplace("_01",";",tmp);
  tmp=strreplace("_02","!",tmp);
  tmp=strreplace("_03","/",tmp);
  tmp=strreplace("_04","\\",tmp);
  tmp=strreplace("_05","[",tmp);
  tmp=strreplace("_06","]",tmp);
  tmp=strreplace("_07","?",tmp);
  tmp=strreplace("_08",".",tmp);
  tmp=strreplace("_09","*",tmp);
  tmp=strreplace("_10","<",tmp);
  tmp=strreplace("_11",">",tmp);
  tmp=strreplace("_12","{",tmp);
  tmp=strreplace("_13","}",tmp);
  tmp=strreplace("_14"," ",tmp);
  tmp=strreplace("_15","\"",tmp);
  tmp=strreplace("_16",":",tmp);
  tmp=strreplace("_17","|",tmp);
  tmp=strreplace("_18","=",tmp);
  tmp=strreplace("_00","_",tmp);
  return tmp;
}


stock udb_Exists(nickname[]) {
  new tmp[MAX_STRING];
  format(tmp,sizeof(tmp),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return fexist(tmp);
}


stock udb_Remove(nickname[]) {
  new tmp[MAX_STRING];
  format(tmp,sizeof(tmp),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return dini_Remove(tmp);
}

stock udb_UserSetInt(nickname[],key[],value) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return dini_IntSet(fname,key,value);
}

stock udb_UserSetFloat(nickname[],key[],Float:value) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return dini_FloatSet(fname,key,value);
}

stock udb_UserSet(nickname[],key[],value[]) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return dini_Set(fname,key,value);
}

stock udb_User(nickname[],key[]) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  format(fname,sizeof(fname),dini_Get(fname,key));
  return fname;
}

stock Float:udb_UserFloat(nickname[],key[]) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return dini_Float(fname,key);
}

stock udb_UserInt(nickname[],key[]) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  return dini_Int(fname,key);
}

stock udb_CheckLogin(nickname[],pwd[]) {
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  if (udb_UserInt(nickname,"password_hash")==udb_hash(pwd)) return true;
  return false;
}


stock udb_Create(nickname[],pwd[]) {
  if (udb_Exists(nickname)) return false;
  new fname[MAX_STRING];
  format(fname,sizeof(fname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  dini_Create(fname);
  udb_UserSetInt(nickname,"password_hash",udb_hash(pwd));
  return true;
}

stock udb_RenameUser(nickname[],newnick[]) {
  new oldfname[MAX_STRING];
  new newfname[MAX_STRING];
  format(oldfname,sizeof(oldfname),"/Accounts/%s.dudb.sav",udb_encode(nickname));
  format(newfname,sizeof(newfname),"/Accounts/%s.dudb.sav",udb_encode(newnick));
  return frenametextfile(oldfname,newfname);
}
Reply
#2

BUMP....
Reply
#3

Register System using Dini + Dudb File saving too!
Reply
#4

I've already my registration system,i need only to move the accounts in the right folder
Reply
#5

please post a code of your login & register system (better if its with /login and /register and not dialog but it doesnt matter)
Reply
#6

Here is:

Register:

Код:
if(strcmp(cmd, "/register", true) == 0) //players ingame stats
	{
 		if (!dini_Exists(udb_encode(playername)))
   		{
     		GetPlayerName(playerid, sendername, sizeof(sendername));
        	ShowPlayerDialog(playerid,50,DIALOG_STYLE_INPUT,"Register","Welcome to the server\n\nPlease open a new account\n\nEnter a password:","Register","Quit");
        	new msg[128];
			format(msg,sizeof(msg),"1,9Player %s has registered an account here at COD:SAMP", sendername);
			IRC_GroupSay(IRC_Group,"PRIVATE CHAN",msg);
     	}
   		else
		{
        	SendClientMessage(playerid, COLOR_GREY, "You already have a registered account!");
		}
		return 1;
	}
Login:

Код:
   	if(strcmp(cmd, "/login", true) == 0) //players ingame stats
	{
	    if(logged[playerid] == 1)
	    {
	        SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
	        return 1;
	    }

     	if (dini_Exists(udb_encode(playername)))
   		{
        	ShowPlayerDialog(playerid,60,DIALOG_STYLE_INPUT,"Login","Welcome to the server\n\nPlease enter your server password\n\nEnter a password:","Login","Quit");
     	}
   		else
		{
        	SendClientMessage(playerid, COLOR_GREY, "You need to register an account before you can login to one!");
		}
		return 1;
	}
Reply
#7

BUMP...lol
Reply
#8

Bump,it's important please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)