Ranksystem subplugin request - give more XP on certain levels

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от mar1anx » 17 Сеп 2018, 01:01

Hi,

I also have an idea for OciXCrom's ranksystem plugin.
Either a sub plug or a plugin edit to increase the drop to xp at a certain level.

Example:
From level 1 to 30 give the xp that is placed in RankSystem.ini and then give it more by 10-20, then at level 50 to get the total from level 30 another 10-20 xp.
But be compatible with happyhour.

Thanks,
Последно промяна от OciXCrom на 17 Сеп 2018, 15:16, променено общо 1 път.
Причина: Edited title! Please use more descriptive titles.

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

Ranksystem request

Мнение от OciXCrom » 17 Сеп 2018, 14:58

crxranks_xp_per_level.sma

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

#include <amxmodx>
#include <amxmisc>
#include <crxranks>

#define PLUGIN_VERSION "1.0.2"

new Trie:g_tXP
new g_szXP[33][16]

public plugin_init()
{
	register_plugin("CRXRanks: XP Per Level", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXRanksXPL", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	g_tXP = TrieCreate()
	ReadFile()
}

public plugin_end()
	TrieDestroy(g_tXP)
	
ReadFile()
{
	new szFilename[256]
	get_configsdir(szFilename, charsmax(szFilename))
	add(szFilename, charsmax(szFilename), "/RankSystemXPL.ini")
	
	new iFilePointer = fopen(szFilename, "rt")
	
	if(iFilePointer)
	{
		new szData[64], szValue[32], szMap[32], szKey[32], bool:bRead = true, iSize
		get_mapname(szMap, charsmax(szMap))
		
		while(!feof(iFilePointer))
		{
			fgets(iFilePointer, szData, charsmax(szData))
			trim(szData)
			
			switch(szData[0])
			{
				case EOS, '#', ';': continue
				case '-':
				{
					iSize = strlen(szData)
					
					if(szData[iSize - 1] == '-')
					{
						szData[0] = ' '
						szData[iSize - 1] = ' '
						trim(szData)
						
						if(contain(szData, "*") != -1)
						{
							strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '*')
							copy(szValue, strlen(szKey), szMap)
							bRead = equal(szValue, szKey) ? true : false
						}
						else
						{
							static const szAll[] = "#all"
							bRead = equal(szData, szAll) || equali(szData, szMap)
						}
					}
					else continue
				}
				default:
				{
					if(!bRead)
						continue
						
					strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
					trim(szKey); trim(szValue)
							
					if(!szValue[0])
						continue
						
					TrieSetString(g_tXP, szKey, szValue)
				}
			}
		}
		
		fclose(iFilePointer)
	}
}

public client_putinserver(id)
{
	g_szXP[id][0] = EOS
	check_level(id, crxranks_get_user_level(id))
}

public crxranks_user_receive_xp(id, iXP, CRXRanks_XPSources:iSource)
{
	if(!g_szXP[id][0] || iSource == CRXRANKS_XPS_ADMIN)
		return CRXRANKS_CONTINUE

	return floatround(math_add_f(float(iXP), g_szXP[id]))
}

public crxranks_user_level_updated(id, iLevel)
	check_level(id, iLevel)

check_level(id, iLevel)
{
	for(new szLevel[8], i = iLevel; i > 0; i--)
	{
		num_to_str(i, szLevel, charsmax(szLevel))

		if(TrieKeyExists(g_tXP, szLevel))
		{
			TrieGetString(g_tXP, szLevel, g_szXP[id], charsmax(g_szXP[]))
			break
		}
	}
}

Float:math_add_f(Float:fNum, const szMath[])
{
	static szNewMath[16], Float:fMath, bool:bPercent, cOperator
   
	copy(szNewMath, charsmax(szNewMath), szMath)
	bPercent = szNewMath[strlen(szNewMath) - 1] == '%'
	cOperator = szNewMath[0]
   
	if(!isdigit(szNewMath[0]))
		szNewMath[0] = ' '
   
	if(bPercent)
		replace(szNewMath, charsmax(szNewMath), "%", "")
	   
	trim(szNewMath)
	fMath = str_to_float(szNewMath)
   
	if(bPercent)
		fMath *= fNum / 100
	   
	switch(cOperator)
	{
		case '+': fNum += fMath
		case '-': fNum -= fMath
		case '/': fNum /= fMath
		case '*': fNum *= fMath
		default: fNum = fMath
	}
   
	return fNum
}
Create a new file in your configs folder named RankSystemXPL.ini and add the following content inside it:

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

#======================================================#
# CRXRanks: XP Per Level Configuration file            #
#======================================================#
# This plugin requires OciXCrom's Rank System to work  #
#======================================================#

# Add each amount of bonus XP on a new line following the format:
# <level number> = <amount of bonus XP>

30 = +10
50 = +20
As you can see from the settings I added:
  • 30 = +10 means that when a player reaches level 30, he will get +10 XP every time he receives XP
  • 50 = +20 means that when a player reaches level 50, he will get +20 XP every time he receives XP
You can setup the file any way you want. You can even use percentages, multiplication, etc. For example, you can make players receive +25% XP on level 10 like this: 10 = +25%. If you want to make double XP, write 10 = *2.

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от mar1anx » 17 Сеп 2018, 18:53

L 09/17/2018 - 19:29:35: [AMXX] Run time error 4: index out of bounds
L 09/17/2018 - 19:29:35: [AMXX] [0] crx_increasexp.txt::math_add (line 124)
L 09/17/2018 - 19:29:35: [AMXX] [1] crx_increasexp.txt::crxranks_user_receive_xp (line 107)
L 09/17/2018 - 19:29:46: Invalid map handle provided (0)
L 09/17/2018 - 19:29:46: [AMXX] Displaying debug trace (plugin "crx_increasexp.amxx", version "1.0")
L 09/17/2018 - 19:29:46: [AMXX] Run time error 10: native error (native "TrieKeyExists")
L 09/17/2018 - 19:29:46: [AMXX] [0] crx_increasexp.txt::crxranks_user_level_updated (line 115)

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от OciXCrom » 17 Сеп 2018, 20:40

I edited the code. Try now.

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от mar1anx » 17 Сеп 2018, 23:39

L 09/17/2018 - 23:48:48: Invalid map handle provided (0)
L 09/17/2018 - 23:48:48: [AMXX] Displaying debug trace (plugin "crx_increasexp.amxx", version "1.0")
L 09/17/2018 - 23:48:48: [AMXX] Run time error 10: native error (native "TrieKeyExists")
L 09/17/2018 - 23:48:48: [AMXX] [0] crx_increasexp.txt::crxranks_user_level_updated (line 115)

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от OciXCrom » 18 Сеп 2018, 00:47

You didn't update the plugin. The error says the plugin version is 1.0, but the updated version is 1.0.1.

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от mar1anx » 18 Сеп 2018, 08:43

L 09/18/2018 - 09:13:35: [AMXX] Displaying debug trace (plugin "crx_increasexp.amxx", version "1.0.1")
L 09/18/2018 - 09:13:35: [AMXX] Run time error 4: index out of bounds
L 09/18/2018 - 09:13:35: [AMXX] [0] crx_increasexp.txt::math_add (line 125)
L 09/18/2018 - 09:13:35: [AMXX] [1] crx_increasexp.txt::crxranks_user_receive_xp (line 108)
L 09/18/2018 - 09:13:43: [AMXX] Displaying debug trace (plugin "crx_increasexp.amxx", version "1.0.1")
L 09/18/2018 - 09:13:43: [AMXX] Run time error 4: index out of bounds
L 09/18/2018 - 09:13:43: [AMXX] [0] crx_increasexp.txt::math_add (line 125)
L 09/18/2018 - 09:13:43: [AMXX] [1] crx_increasexp.txt::crxranks_user_receive_xp (line 108)



there is a possibility to set from level 30 to 40 (31/32/33 / etc) to give + 20% and after 40 to 50 to give + 25% and so, or I have to put each level to give more xp?

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от OciXCrom » 18 Сеп 2018, 14:34

I edited the code again, now I tested and it's working.

You don't have to put each level, you can skip them. The player will receive the XP bonus from the last level added in the .ini file that he has.

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от mar1anx » 19 Сеп 2018, 16:45

Thanks now works, if I find any problem I'll come back with a reply.

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

Ranksystem subplugin request - give more XP on certain levels

Мнение от OciXCrom » 20 Сеп 2018, 13:32

I'll lock the thread. If you have any problems or questions, use the orange Report button to let us know you want it to be unlocked.

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

Обратно към “Заявки за плъгини”

Кой е на линия

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