Giving something to an offline user

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

Giving something to an offline user

Мнение от OciXCrom » 02 Яну 2019, 15:38

I don't plan to add such a feature in the main plugin, but a sub-plugin can be made to do it. You can post a request if you decide to use it.

Аватар
X3.!
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 30 Ное 2018, 20:46
Се отблагодари: 1 път

Giving something to an offline user

Мнение от X3.! » 12 Яну 2019, 04:32

I decided to use the plugin, can you please make an external plugin for the request?
About giving xp to an offline user.


PS# A small question about your plugin, do I can give xp by using give_user_xp(id,10) instead of set_user_xp(id, get_user_xp(id) + 10) ? I just removed the prefix to show an example

Аватар
JackEyedJones
Извън линия
Потребител
Потребител
Мнения: 399
Регистриран на: 10 Сеп 2018, 17:26
Местоположение: Plovdiv, Bulgaria, Europe, Entire World
Се отблагодари: 4 пъти
Получена благодарност: 69 пъти
Обратна връзка:

Giving something to an offline user

Мнение от JackEyedJones » 12 Яну 2019, 09:51

There must be such native which adds XP on the top of the current user's one XP which contains the 2nd argument itself so you dont have to type get_user_xp(id). Or the current one to be reworked.

give_user_xp(id, 10) in this case the #10 must be 3rd argument in the native structure i think.

Аватар
X3.!
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 30 Ное 2018, 20:46
Се отблагодари: 1 път

Giving something to an offline user

Мнение от X3.! » 12 Яну 2019, 11:54

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

 /** 
 * Gives a specific amount of XP to the client.
 * 
 * @note If the "reward" parameter is set, the plugin will ignore the amount set
 *       in the "amount" parameter and will attempt to give the XP set in the
 *		 configuration file by the specific keyword set in the "reward" parameter.
 *
 * @param id		 	Client index.
 * @param amount		XP amount.
 * @param reward		Reward keyword.
 * @param source		XP source.
 * @return				Amount of XP given.
 */
native crxranks_give_user_xp(id, amount = 0, reward[] = "", CRXRanks_XPSources:source = CRXRANKS_XPS_PLUGIN)
So shouldnt it be like that? crxranks_give_user_xp(id, 10) ?

the set_user_xp

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

/** 
 * Sets the exact amount of XP that th client has.
 *
 * @param id		 	Client index.
 * @param amount		XP amount.
 * @param source		XP source.
 * @return				Amount of XP given.
 */
native crxranks_set_user_xp(id, amount, CRXRanks_XPSources:source = CRXRANKS_XPS_PLUGIN)

Аватар
JackEyedJones
Извън линия
Потребител
Потребител
Мнения: 399
Регистриран на: 10 Сеп 2018, 17:26
Местоположение: Plovdiv, Bulgaria, Europe, Entire World
Се отблагодари: 4 пъти
Получена благодарност: 69 пъти
Обратна връзка:

Giving something to an offline user

Мнение от JackEyedJones » 12 Яну 2019, 13:48

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

#define crxranks_give_user_xp(%0, %1) crxranks_set_user_exp(%0, crxranks_get_user_exp(%0) + %1)
Source: Huehue's PM to me regarding my previous post.

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

Giving something to an offline user

Мнение от OciXCrom » 13 Яну 2019, 00:54

My plugin already has such a native, so yes, you can simply do crxranks_give_user_xp(id, 10) instead of using two functions. Don't do what JackEyedJones said in the post above - the native is already there.

About the command to give XP to offline players, try this:

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

#include <amxmodx>
#include <amxmisc>
#include <cromchat>
#include <crxranks>
#include <nvault>

new g_iVault

public plugin_init()
{
	register_plugin("CRXRanks: Give Offline XP", "1.0", "OciXCrom")
	register_concmd("crxranks_give_offline_xp", "Cmd_GiveXP", ADMIN_RCON, "<player> <xp to give>")
}

public plugin_end()
{
	if(g_iVault)
		nvault_close(g_iVault)
}

public Cmd_GiveXP(id, iLevel, iCid)
{
	if(!cmd_access(id, iLevel, iCid, 3))
		return PLUGIN_HANDLED

	if(!g_iVault)
	{
		new szVault[32]
		crxranks_get_setting("VAULT_NAME", szVault, charsmax(szVault))
		g_iVault = nvault_open(szVault)
	}

	new szPlayer[CRXRANKS_MAX_PLAYER_INFO_LENGTH], szXP[CRXRANKS_MAX_XP_LENGTH]
	read_argv(1, szPlayer, charsmax(szPlayer))
	read_argv(2, szXP, charsmax(szXP))

	new szCurrentXP[CRXRANKS_MAX_XP_LENGTH], szNewXP[CRXRANKS_MAX_XP_LENGTH], szName[32]
	get_user_name(id, szName, charsmax(szName))

	if(nvault_get(g_iVault, szPlayer, szCurrentXP, charsmax(szCurrentXP)))
		num_to_str(str_to_num(szCurrentXP) + str_to_num(szXP), szNewXP, charsmax(szNewXP))
	else
		copy(szNewXP, charsmax(szNewXP), szXP)

	nvault_set(g_iVault, szPlayer, szNewXP)
	CC_SendMessage(0, "ADMIN &x03%s &x01gave &x04%s XP &x01to offline user &x03%s", szName, szXP, szPlayer)
	return PLUGIN_HANDLED
}
The command is crxranks_give_offline_xp <player> <xp>. It works with nVault. If you're using MySQL, let me know.

Аватар
X3.!
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 30 Ное 2018, 20:46
Се отблагодари: 1 път

Giving something to an offline user

Мнение от X3.! » 13 Яну 2019, 05:20

Will this work with SteamID saving method?
Edit: Also if I gave him the XP and in the same map he connects, will it load? Or map needs to be changed?


Tested it, and it worked! thanks man

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

Giving something to an offline user

Мнение от OciXCrom » 14 Яну 2019, 02:11

It will work with any method and no, the map doesn't need to change. If everything's good, shall I lock the thread?

Аватар
WanTap
Извън линия
Foreigner
Foreigner
Мнения: 1
Регистриран на: 15 Яну 2019, 14:39

Giving something to an offline user

Мнение от WanTap » 15 Яну 2019, 15:07

Hi. I would appreciate if you make it for MySQL

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

Обратно към “Помощ в скриптирането”

Кой е на линия

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