error: invalid player / "set_user_rendering"

Въпроси и проблеми свързани с AMXModX.
Аватар
truex_88
Извън линия
Foreigner
Foreigner
Мнения: 33
Регистриран на: 18 Мар 2019, 18:33
Се отблагодари: 11 пъти

error: invalid player / "set_user_rendering"

Мнение от truex_88 » 23 Мар 2019, 10:23

can somebody help me, what's wrong? Thanks



L 03/23/2019 - 08:38:43: [FUN] Invalid player 1
L 03/23/2019 - 08:38:43: [AMXX] Displaying debug trace (plugin "zp_extra_speed_boost.amxx", version "1.2")
L 03/23/2019 - 08:38:43: [AMXX] Run time error 10: native error (native "set_user_rendering")
L 03/23/2019 - 08:38:43: [AMXX] [0] zp_extra_speed_boost.sma::client_disconnected (line 129)



SMA:

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

/*================================================================================
	
	----------------------------------------
	-*- [ZP] Extra Item: Speed Boost 1.2 -*-
	----------------------------------------
	
	~~~~~~~~~~~~~~~
	- Description -
	~~~~~~~~~~~~~~~
	
	This item gives humans/zombies a short speed boost, configurable
	by cvars: zp_boost_amount and zp_boost_duration.
	
	ZP 4.3 Fix 5 or later required.
	
	~~~~~~~~~~~~~
	- Changelog -
	~~~~~~~~~~~~~
	
	* v1.0: (Jun 21, 2011)
	   - First release
	
	* v1.1: (Jun 22, 2011)
	   - Fixed speed not properly restored if player gets frozen after
	      buying the speed boost (high zp_frost_duration settings)
	
	* v1.2: (Jul 02, 2011)
	   - Changed speed setting method to be compatible with ZP 4.3 Fix5
	
================================================================================*/

#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

const TASK_SPEED_BOOST = 100
#define ID_SPEED_BOOST (taskid - TASK_SPEED_BOOST)

// Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame

new g_itemid_boost
new cvar_boost_amount, cvar_boost_duration
new cvar_red, cvar_green, cvar_blue
new g_has_speed_boost[33]

public plugin_init()
{
	register_plugin("[ZP] Extra Item Speed Boost", "1.2", "MeRcyLeZZ")
	
	g_itemid_boost = zp_register_extra_item("Speed Boost", 5, ZP_TEAM_HUMAN | ZP_TEAM_ZOMBIE)
	cvar_boost_amount = register_cvar("zp_boost_amount", "100.0")
	cvar_boost_duration = register_cvar("zp_boost_duration", "45.0")
	cvar_red = register_cvar("zp_red_color", "230")
	cvar_green = register_cvar("zp_green_color", "100")
	cvar_blue = register_cvar("zp_blue_color", "19")
	
	RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_ResetMaxSpeed_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}

public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_itemid_boost)
	{
		// Player frozen (or CS freezetime)
		if (pev(player, pev_maxspeed) <= 1)
		{
			client_print(player, print_chat, " You can't use this item when frozen.")
			return ZP_PLUGIN_HANDLED;
		}
		
		// Already using speed boost
		if (g_has_speed_boost[player])
		{
			client_print(player, print_chat, " You already have the speed boost.")
			return ZP_PLUGIN_HANDLED;
		}
		
		// Enable speed boost
		g_has_speed_boost[player] = true
		client_print(player, print_chat, " Speed boost enabled!")
		
		set_user_rendering(player, kRenderFxGlowShell, get_pcvar_num(cvar_red), get_pcvar_num(cvar_green), get_pcvar_num(cvar_blue), kRenderNormal, 255)
		// Set the restore speed task
		set_task(get_pcvar_float(cvar_boost_duration), "restore_maxspeed", player+TASK_SPEED_BOOST)
		
		// Update player's maxspeed
		ExecuteHamB(Ham_Player_ResetMaxSpeed, player)
	}
	return PLUGIN_CONTINUE;
}

public restore_maxspeed(taskid)
{
	// Disable speed boost
	g_has_speed_boost[ID_SPEED_BOOST] = false
	client_print(ID_SPEED_BOOST, print_chat, "SpeedBoost: OFF")
	
	// Update player's maxspeed
	ExecuteHamB(Ham_Player_ResetMaxSpeed, ID_SPEED_BOOST)
}

// Remove speed boost task when infected, humanized, killed, or disconnected
public zp_user_infected_pre(id, infector, nemesis)
{
	g_has_speed_boost[id] = false
	set_user_rendering(id)
	remove_task(id+TASK_SPEED_BOOST)
}
public zp_user_humanized_pre(id, survivor)
{
	g_has_speed_boost[id] = false
	set_user_rendering(id)
	remove_task(id+TASK_SPEED_BOOST)
}
public fw_PlayerKilled(victim)
{
	g_has_speed_boost[victim] = false
	set_user_rendering(victim)
	remove_task(victim+TASK_SPEED_BOOST)
}
public client_disconnect(id)
{
	g_has_speed_boost[id] = false
	set_user_rendering(id)
	remove_task(id+TASK_SPEED_BOOST)
}

// Remove speed boost at round start
public event_round_start()
{
	new id
	for (id = 1; id <= get_maxplayers(); id++)
	{
		g_has_speed_boost[id] = false
		set_user_rendering(id)
		remove_task(id+TASK_SPEED_BOOST)
	}
}

public fw_ResetMaxSpeed_Post(id)
{
	if (!is_user_alive(id) || !g_has_speed_boost[id])
		return;
	
	// Apply speed boost
	new Float:current_maxspeed
	pev(id, pev_maxspeed, current_maxspeed)
	set_pev(id, pev_maxspeed, current_maxspeed + get_pcvar_float(cvar_boost_amount))
}
Последно промяна от OciXCrom на 23 Мар 2019, 15:28, променено общо 1 път.
Причина: Moved to help section.

Аватар
<VeCo>
Извън линия
Потребител
Потребител
Мнения: 145
Регистриран на: 28 Яну 2019, 19:01
Се отблагодари: 11 пъти
Получена благодарност: 80 пъти
Обратна връзка:

error: invalid player / "set_user_rendering"

Мнение от <VeCo> » 23 Мар 2019, 10:40

Remove "set_user_rendering(id)" from client_disconnect function. There's no point for it to be there, lol.
:pepo_think3:

Аватар
truex_88
Извън линия
Foreigner
Foreigner
Мнения: 33
Регистриран на: 18 Мар 2019, 18:33
Се отблагодари: 11 пъти

error: invalid player / "set_user_rendering"

Мнение от truex_88 » 23 Мар 2019, 11:39

thank you again Veco :)

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

Обратно към “Поддръжка / Помощ”

Кой е на линия

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