OciXCrom's Rank System [XP|Levels|Ranks]

Одобрените от нас плъгини. Моля, докладвайте ако забележите бъг с някой от плъгините в този раздел.
Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от OciXCrom » 12 Дек 2018, 22:18

Изображение
  • Добавена е MySQL поддръжка. Вече можете да ползвате MySQL за запазване на XP-то, вместо nVault.
  • При неуспешна връзка с MySQL сървъра, плъгинът автоматично ще се прехвърли да ползва nVault за запазване на XP-то, вместо напълно да спре да работи.
  • За да ъпдетйнете от версия 2.7.1 до най-новата версия 3.0 без да загубите настройките в RankSystem.ini, заместете всички останали файлове, а в конфигурационния файл добавете следните неща в раздела [Settings] под настройката SAVE_TYPE:

    Код за потвърждение: Избери целия код

    # If set to 1, player XP will be saved and loaded using MySQL rather than nVault.
    # If the MySQL connection fails, the plugin will automatically switch to using nVault.
    USE_MYSQL = 0
    
    # SQL information to use if USE_MYSQL is set to 1.
    SQL_HOST = 127.0.0.1
    SQL_USER = root
    SQL_PASSWORD = 
    SQL_DATABASE = amx
    SQL_TABLE = CRXRanks
  • Сложете настройката USE_MYSQL на 1 и настройте си данните за да ползвате MySQL опцията.
  • Интересна идея: можете да ползвате същите MySQL данни в повече от един сървър за играчите да имат същото XP във всички налични сървъри.
Благодаря на HueHue за написването на примерния SQL код който ползвах в плъгина.

Аватар
mar1anx
Извън линия
Foreigner
Foreigner
Мнения: 41
Регистриран на: 17 Сеп 2018, 00:56
Се отблагодари: 4 пъти
Получена благодарност: 2 пъти

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от mar1anx » 13 Дек 2018, 00:22

Can you make a plugin to transfer from nvault in mysql ?
Like this

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <sqlx>

new g_host, g_user, g_pass, g_db;
new Host[64], User[32], Pass[32], DB[128];
new Handle:g_SQLTuple, Handle:SqlConnection;
new g_error[512], errorcode;
new reg_file[256], text[128], name[32], pass[34], status[11], query[512], counter = 0;

public plugin_init()
{
	register_plugin("Register System Data Transferor", "1.0", "m0skVi4a ;]")

	g_host = get_cvar_pointer("rs_host")
	g_user = get_cvar_pointer("rs_user")
	g_pass = get_cvar_pointer("rs_pass")
	g_db = get_cvar_pointer("rs_db")

	register_srvcmd("file_to_mysql", "FileToMYSQL")
	register_srvcmd("mysql_to_file", "MYSQLToFile")

	new configs_dir[64];

	get_localinfo("amxx_configsdir", configs_dir, charsmax(configs_dir))	
	formatex(reg_file, charsmax(reg_file), "%s/regusers.ini", configs_dir)
}

public MYSQLToFile()
{
	server_print("Connecting to MYSQL...")

	get_pcvar_string(g_host, Host, charsmax(Host))
	get_pcvar_string(g_user, User, charsmax(User))
	get_pcvar_string(g_pass, Pass, charsmax(Pass))
	get_pcvar_string(g_db, DB, charsmax(DB))

	g_SQLTuple = SQL_MakeDbTuple(Host, User, Pass, DB)

	SqlConnection = SQL_Connect(g_SQLTuple, errorcode, g_error, charsmax(g_error))

	if(SqlConnection == Empty_Handle) 
	{
		server_print("MYSQL connection failed!")
		server_print(g_error)
		return PLUGIN_HANDLED
	}
	else
	{
		server_print("MYSQL connection succesful!")
	}

	server_print("Checking Register System file...")

	if(!file_exists(reg_file))
	{
		server_print("Register System file -  %s   not found! Creating new...", reg_file)
		write_file(reg_file,";Register System file^n;Modifying may cause the clients to can not Login!^n^n")
	}
	else
	{
		server_print("Register System file found!")
	}

	server_print("Starting to transfer!")

	formatex(query, charsmax(query), "SELECT * FROM `registersystem`;")
	SQL_ThreadQuery(g_SQLTuple, "QuerySelectData", query)

	return PLUGIN_CONTINUE	
}

public QuerySelectData(FailState, Handle:Query, error[], errorcode, data[], datasize, Float:fQueueTime)
{ 
	if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
	{
		server_print(error)
		return
	}
	else
	{
		new col_name = SQL_FieldNameToNum(Query, "Name")
		new col_pass = SQL_FieldNameToNum(Query, "Password")
		new col_status = SQL_FieldNameToNum(Query, "Status")

		new file_pointer = fopen(reg_file, "a")

		counter = 0

		while(SQL_MoreResults(Query)) 
		{
			SQL_ReadResult(Query, col_name, name, charsmax(name))
			SQL_ReadResult(Query, col_pass, pass, charsmax(pass))
			SQL_ReadResult(Query, col_status, status, charsmax(status))

			if(!equal(status, "LOGGED_IN"))
			{
				status = "LOGGED_OUT"
			}			

			formatex(text, charsmax(text), "^n^"%s^" ^"%s^" ^"%s^"", name, pass, status)
			fprintf(file_pointer, text)
			counter++
			server_print("%d. Transfering  %s  's registration, password hash: %s  Status: %s", counter, name, pass, status)
			SQL_NextRow(Query)
		}
		fclose(file_pointer)
		server_print("Transfer finished!  %d registration were transferred!", counter)
	}
}

public FileToMYSQL()
{
	server_print("Checking Register System file...")

	if(!file_exists(reg_file))
	{
		server_print("Register System file -  %s   not find!", reg_file)
		return PLUGIN_HANDLED
	}
	else
	{
		server_print("Register System file found!")
	}

	server_print("Connecting to MYSQL...")

	get_pcvar_string(g_host, Host, charsmax(Host))
	get_pcvar_string(g_user, User, charsmax(User))
	get_pcvar_string(g_pass, Pass, charsmax(Pass))
	get_pcvar_string(g_db, DB, charsmax(DB))

	g_SQLTuple = SQL_MakeDbTuple(Host, User, Pass, DB)

	SqlConnection = SQL_Connect(g_SQLTuple, errorcode, g_error, charsmax(g_error))

	if(SqlConnection == Empty_Handle) 
	{
		server_print("MYSQL connection failed!")
		server_print(g_error)
		return PLUGIN_HANDLED
	}
	else
	{
		server_print("MYSQL connection succesful!")
	}

	new Handle:Query

	Query = SQL_PrepareQuery(SqlConnection, "CREATE TABLE IF NOT EXISTS registersystem (Name VARCHAR(32), Password VARCHAR(34), Status VARCHAR(11))")

	if(!SQL_Execute(Query)) 
	{
		SQL_QueryError(Query, g_error, charsmax(g_error))
		server_print(g_error)
	}

	SQL_FreeHandle(Query)
	SQL_FreeHandle(SqlConnection)

	server_print("Starting to transfer!")

	new length, line = 0;
	counter = 0

	while(read_file(reg_file, line++ , text, charsmax(text), length))
	{
		if(!text[0] || text[0] == '^n' || text[0] == ';')
			continue

		parse(text, name, charsmax(name), pass, charsmax(pass), status, charsmax(status))

		if(!equal(status, "LOGGED_IN"))
		{
			status = "LOGGED_OUT"
		}

		formatex(query, charsmax(query), "INSERT INTO `registersystem` (`Name`, `Password`, `Status`) VALUES (^"%s^", ^"%s^", ^"%s^");", name, pass, status)
		SQL_ThreadQuery(g_SQLTuple, "QuerySetData", query)
		counter++
		server_print("%d. Transfering  %s  's registration, password hash: %s  Status: %s", counter, name, pass, status)
	}

	server_print("Transfer finished!  %d registration were transferred!", counter)

	return PLUGIN_CONTINUE
}

public QuerySetData(FailState, Handle:Query, error[],errcode, data[], datasize)
{
	if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
	{
		server_print(error)
		return
	}
}

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от OciXCrom » 14 Дек 2018, 14:34

I'll try to make a transfer plugin soon.

Аватар
esc-Fiv3
Извън линия
Foreigner
Foreigner
Мнения: 110
Регистриран на: 24 Ное 2018, 19:19
Се отблагодари: 16 пъти

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от esc-Fiv3 » 14 Дек 2018, 14:55

Updated? It works good the last one too. What is the difference between 2.7 to 3.0? Should I update it too? It works great the last one and I have amxx 1.8.2

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от OciXCrom » 14 Дек 2018, 14:59

Look at the changelog above. In 3.0 you can use MySQL to save the XP - this was a highly requested feature. In 2.7 you can only use nVault which doesn't allow any actions outside the server. With MySQL you can connect the XP with your website for example.

Аватар
esc-Fiv3
Извън линия
Foreigner
Foreigner
Мнения: 110
Регистриран на: 24 Ное 2018, 19:19
Се отблагодари: 16 пъти

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от esc-Fiv3 » 15 Дек 2018, 01:55

Then I don't need it. Thanks!

Can you tell me which files I have to save if I want to do a back-up of all players stats from xp plugin? CRXRanks.vault is empty, then I have Ranks.journal which is empty too and Ranks.vault which have some kilobytes. Only this one I have to save?

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от OciXCrom » 15 Дек 2018, 15:45

CRXRanks.vault when the server is offline.

Аватар
esc-Fiv3
Извън линия
Foreigner
Foreigner
Мнения: 110
Регистриран на: 24 Ное 2018, 19:19
Се отблагодари: 16 пъти

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от esc-Fiv3 » 19 Дек 2018, 22:50

Sry to say but I stopped my server and there is nothing in CRXRanks.vault. All I have is Ranks.vault which have some killos
This one is a linux server, the other server that I have on my pc (windows server) have that CRXRanks.vault with some kilos.
I mention that I did a back-up to my linux server like 2 weeks ago and I had my xp rank from the past but the file says:0 killos. Only that Ranks.vault have ranks saved

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от OciXCrom » 19 Дек 2018, 23:44

Check the name of the vault file that you have set in the configuration file (the VAULT_NAME setting). The default name is CRXRanks, you may have changed it to Ranks or something else - the data is saved in the file with that name.

Аватар
esc-Fiv3
Извън линия
Foreigner
Foreigner
Мнения: 110
Регистриран на: 24 Ное 2018, 19:19
Се отблагодари: 16 пъти

OciXCrom's Rank System [XP|Levels|Ranks]

Мнение от esc-Fiv3 » 20 Дек 2018, 00:22

Can you make a top10 or top15 for this one?

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Одобрени плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 24 госта