Страница 1 от 1
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 17 Сеп 2018, 01:01
от mar1anx
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,
Ranksystem request
Публикувано на: 17 Сеп 2018, 14:58
от OciXCrom
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.
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 17 Сеп 2018, 18:53
от mar1anx
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)
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 17 Сеп 2018, 20:40
от OciXCrom
I edited the code. Try now.
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 17 Сеп 2018, 23:39
от mar1anx
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)
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 18 Сеп 2018, 00:47
от OciXCrom
You didn't update the plugin. The error says the plugin version is 1.0, but the updated version is 1.0.1.
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 18 Сеп 2018, 08:43
от mar1anx
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?
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 18 Сеп 2018, 14:34
от OciXCrom
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.
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 19 Сеп 2018, 16:45
от mar1anx
Thanks now works, if I find any problem I'll come back with a reply.
Ranksystem subplugin request - give more XP on certain levels
Публикувано на: 20 Сеп 2018, 13:32
от OciXCrom
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.