Преработка на плъгин Custom Models / Помощ

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

Преработка на плъгин Custom Models / Помощ

Мнение от YankoNL » 28 Окт 2018, 16:49

Здравейте!
От вчера се мъча да си направя плъгин за смяна моделите на играчите с привилегии в ZP 4.3. Успях до определена степен и реших да се обърна отново към вас за помощ. Главния проблем е че като Human избера даден скин, след инфекцията пак съм със скина. Има и един миниатюрен проблем и той е следния: Когато избера скина бих желал след това като отворя менюто да е в блед цвят или да пише [ Selected ], но това не е толкова важно. Ако може да се направи със zmvip.inc защото бих желал 1 или 2 скина да са само за админи, а останалите за випове.
Благодаря предварително!

Ето и кода:

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

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <colorchat>
#include <zombieplague>
#include <zmvip>
#include <fun>

#define PLUGIN "Custom ZP Models"
#define VERSION "test"
#define AUTHOR "YankoNL"

new g_ent_playermodel[33];
new g_ent_weaponmodel[33]
new g_currentweapon[33];
new g_pcvar_active;

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /models", "models_menu")
    register_message(get_user_msgid("CurWeapon"), "message_current_weapon")
    g_pcvar_active = register_cvar("zp_models_allow", "1")
}

public plugin_precache() 
{
	precache_model("models/player/Hummer_Human1/Hummer_Human1.mdl")
	precache_model("models/player/vip/vip.mdl")
	precache_model("models/player/Hummer_PantherAdmin/Hummer_PantherAdmin.mdl")
	precache_model("models/player/Hummer_THEADMIN/Hummer_THEADMIN.mdl")
	precache_model("models/player/Hummer_Admin/Hummer_Admin.mdl")
	precache_model("models/player/zombie_source/zombie_source.mdl")
}
		
public message_current_weapon(msg_id, msg_dest, msg_entity)
{
	if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
		return;
	
	static weapon
	weapon = get_msg_arg_int(2)
	
	g_currentweapon[msg_entity] = weapon
	
	fm_set_weaponmodel_ent(msg_entity)
}

public zp_user_infected_post(id, infector)
{
	set_user_rendering(id, kRenderFxNone, 0,0,0,kRenderNormal, 255)
	
	fm_remove_model_ents(id)
}

public models_menu(id)
{
	if(zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id))
	{
		ColorChat(id, GREEN, "[Server name] ^3Zombies can't change models! They change classes.")
	}
	else if(!is_user_alive(id))
	{
		ColorChat(id, GREEN, "[Server name] ^1You must be alive in order to change your model.")
	}
	else if(!get_pcvar_num(g_pcvar_active))
	{
		ColorChat(id, GREEN, "[Server name] ^1Plugin is currently ^2Disabled.");
	}
	else if(get_user_flags(id) & ADMIN_LEVEL_E)
		{
			model_menu(id)
		}
	else
        {
               ColorChat(id, GREEN, "[Server name] ^1Access denied. ^4V.I.P ^1users only.")
        }
	
}

public model_menu(id)
{
    new menu = menu_create("\rChoose Your Model", "menu_selector")
    
    menu_additem(menu, "\wModel \ySHuman1", "1", 0)
    menu_additem(menu, "\wModel \yVIP", "2", 0)
    menu_additem(menu, "\wModel \yPantera", "3", 0)
    menu_additem(menu, "\wModel \yMarijuana", "4", 0)
    menu_additem(menu, "\wModel \yBanana", "5", 0)
    menu_additem(menu, "\wModel \yZombie", "6", 0)

    
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, 0)
}

public menu_selector(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new acces, callback
    menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)
    
    new key = str_to_num(data)
    
    switch(key)
    { 
       case 1 : cs_set_user_model(id, "Hummer_Human1")
       case 2 : cs_set_user_model(id, "vip")
       case 3 : cs_set_user_model(id, "Hummer_PantherAdmin")
       case 4 :	cs_set_user_model(id, "Hummer_THEADMIN")
       case 5 : cs_set_user_model(id, "Hummer_Admin")
       case 6 : cs_set_user_model(id, "zombie_source")
    }
    menu_destroy(menu)
    return PLUGIN_HANDLED
}

stock fm_remove_model_ents(id)
{
	if (pev_valid(g_ent_playermodel[id]))
	{
		engfunc(EngFunc_RemoveEntity, g_ent_playermodel[id])
		g_ent_playermodel[id] = 0
	}
	if (pev_valid(g_ent_weaponmodel[id]))
	{
		engfunc(EngFunc_RemoveEntity, g_ent_weaponmodel[id])
		g_ent_weaponmodel[id] = 0
	}
}

stock fm_set_weaponmodel_ent(id)
{
	static model[100]
	pev(id, pev_weaponmodel2, model, sizeof model - 1)
	
	if (!pev_valid(g_ent_weaponmodel[id]))
	{
		g_ent_weaponmodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
		if (!pev_valid(g_ent_weaponmodel[id])) return;
		
		set_pev(g_ent_weaponmodel[id], pev_classname, "weapon_model")
		set_pev(g_ent_weaponmodel[id], pev_movetype, MOVETYPE_FOLLOW)
		set_pev(g_ent_weaponmodel[id], pev_aiment, id)
		set_pev(g_ent_weaponmodel[id], pev_owner, id)
	}
	
	engfunc(EngFunc_SetModel, g_ent_weaponmodel[id], model)
}

Аватар
TheRedShoko
Извън линия
Модератор
Модератор
Мнения: 1016
Регистриран на: 06 Окт 2016, 07:42
Местоположение: Бургас
Се отблагодари: 5 пъти
Получена благодарност: 84 пъти

Преработка на плъгин Custom Models / Помощ

Мнение от TheRedShoko » 29 Окт 2018, 07:53

Днес по-късно ще пусна версия на моя плъгин, който работи със zp. Изчакай да го пусна, ако искаш.

Edit: Сега видях, че единствено в ZP advanced може да стане. В другите версии на ZP няма изнесени natives.

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

Преработка на плъгин Custom Models / Помощ

Мнение от YankoNL » 29 Окт 2018, 12:04

Ще съм доволен да получа за zp advanced. Все пак винаги може да се ъпгрейдне сървъра.

Аватар
TryAgain
Извън линия
Потребител
Потребител
Мнения: 182
Регистриран на: 25 Яну 2017, 16:59
Се отблагодари: 1 път
Получена благодарност: 26 пъти

Преработка на плъгин Custom Models / Помощ

Мнение от TryAgain » 30 Окт 2018, 14:03

Има си native и за тази версия просто ползваш твърде стар код.

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

register_native("zp_get_user_model", "native_get_user_model", 0)
register_native("zp_set_user_model", "native_set_user_model", 1)

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

// Native: zp_get_user_model
public native_get_user_model(plugin_id, param_nums)
{
	// ZP disabled
	if (!g_pluginenabled)
		return -1;
	
	// Insufficient number of arguments
	if (param_nums != 3)
		return -1;
	
	// Retrieve the player's index
	static id; id = get_param(1)
	
	// Not an alive player or invalid player
	if (!is_user_valid_alive(id))
		return 0;
	
	// Retrieve the player's current model
	static current_model[32]
	fm_cs_get_user_model(id, current_model, charsmax(current_model))
	
	// Copy the model name into the array passed
	set_string(2, current_model, get_param(3))
	
	return 1;
}
// Native: zp_set_user_model
public native_set_user_model(id, const model[])
{
	// ZP disabled
	if (!g_pluginenabled)
		return -1;
	
	// Not an alive player or invalid player
	if (!is_user_valid_alive(id))
		return -1;
	
	// Strings passed byref
	param_convert(2)
	
	// Retrieve the player's current model
	static current_model[32]
	fm_cs_get_user_model(id, current_model, charsmax(current_model))
	
	// Check whether we already have the model set on the player
	if (equal(current_model, model))
		return 0;
	
	// Update player's model
	copy(g_playermodel[id], charsmax(g_playermodel[]), model)
	
	// Set the right model for the player
	if (g_handle_models_on_separate_ent) fm_set_playermodel_ent(id)
	else fm_user_model_update(id+TASK_MODEL)
	
	return 1;
}

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

Преработка на плъгин Custom Models / Помощ

Мнение от YankoNL » 31 Окт 2018, 02:27

Ще го пробвам и ще ъпдейтна коментара си. Благодаря.

Аватар
YankoNL
Извън линия
Потребител
Потребител
Мнения: 163
Регистриран на: 06 Апр 2017, 09:07
Местоположение: Варна
Се отблагодари: 22 пъти
Получена благодарност: 9 пъти

Преработка на плъгин Custom Models / Помощ

Мнение от YankoNL » 03 Ное 2018, 19:00

Не се получава за зп. Няма проблеми ще се справя все някога с този проблем. Блягодаря че се опитахте да помогнете.
:lock: :lock: :lock:

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

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

Кой е на линия

Потребители разглеждащи този форум: Bing [Bot], Google [Bot] и 26 госта