Модели для привилегий ZP 5.0.8

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
418
Реакции
-7
Ребят, добавил модели для Owner'a и Creator'a (Владельца и Создателя), для создателя стоят все флаги доступа (abcdefghijklmnopqrstu) а владельцу (abcdefijrst) но мне на создателя выдаёт модель Владельца... что тут не так?

C++:
#include <amxmodx>
#include <amx_settings_api>
#include <cs_player_models_api>
#include <cs_weap_models_api>
#include <zp50_core>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

// Default Priveleges models
new const models_creator_human_player[][] = { "vip" }
new const models_creator_human_knife[][] = { "models/v_knife.mdl" }
new const models_owner_human_player[][] = { "owner" }
new const models_owner_human_knife[][] = { "models/v_knife.mdl" }

#define PLAYERMODEL_MAX_LENGTH 32
#define MODEL_MAX_LENGTH 64
#define ACCESSFLAG_MAX_LENGTH 2

// Access flags
new g_access_creator_models[ACCESSFLAG_MAX_LENGTH] = "u"
new g_access_owner_models[ACCESSFLAG_MAX_LENGTH] = "s"

// Custom models
new Array:g_models_creator_human_player
new Array:g_models_creator_human_knife
new Array:g_models_owner_human_player
new Array:g_models_owner_human_knife

new cvar_creator_models_human_player, cvar_creator_models_human_knife, cvar_owner_models_human_player, cvar_owner_models_human_knife

public plugin_init()
{
    register_plugin("[ZP] Admin Models", ZP_VERSION_STRING, "ZP Dev Team")
    
    cvar_creator_models_human_player = register_cvar("zp_creator_models_human_player", "1")
    cvar_creator_models_human_knife = register_cvar("zp_creator_models_human_knife", "1")
    cvar_owner_models_human_player = register_cvar("zp_owner_models_human_player", "1")
    cvar_owner_models_human_knife = register_cvar("zp_owner_models_human_knife", "1")
}

public plugin_precache()
{
    // Initialize arrays
    g_models_creator_human_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
    g_models_creator_human_knife = ArrayCreate(MODEL_MAX_LENGTH, 1)
    g_models_owner_human_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
    g_models_owner_human_knife = ArrayCreate(MODEL_MAX_LENGTH, 1)
    
    // Load from external file
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "CREATOR HUMAN", g_models_creator_human_player)
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE CREATOR HUMAN", g_models_creator_human_knife)
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "OWNER HUMAN", g_models_owner_human_player)
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE OWNER HUMAN", g_models_owner_human_knife)
    
    // If we couldn't load from file, use and save default ones
    new index
    if (ArraySize(g_models_creator_human_player) == 0)
    {
        for (index = 0; index < sizeof models_creator_human_player; index++)
            ArrayPushString(g_models_creator_human_player, models_creator_human_player[index])
        
        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "CREATOR HUMAN", g_models_creator_human_player)
    }
    if (ArraySize(g_models_owner_human_player) == 0)
    {
        for (index = 0; index < sizeof models_owner_human_player; index++)
            ArrayPushString(g_models_owner_human_player, models_owner_human_player[index])
        
        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "OWNER HUMAN", g_models_owner_human_player)
    }
    if (ArraySize(g_models_creator_human_knife) == 0)
    {
        for (index = 0; index < sizeof models_creator_human_knife; index++)
            ArrayPushString(g_models_creator_human_knife, models_creator_human_knife[index])
        
        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE CREATOR HUMAN", g_models_creator_human_knife)
    }
    if (ArraySize(g_models_owner_human_knife) == 0)
    {
        for (index = 0; index < sizeof models_owner_human_knife; index++)
            ArrayPushString(g_models_owner_human_knife, models_owner_human_knife[index])

        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE OWNER HUMAN", g_models_owner_human_knife)
    }
    
    // Load from external file, save if not found
    if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Access Flags", "CREATOR MODELS", g_access_creator_models, charsmax(g_access_creator_models)))
        amx_save_setting_string(ZP_SETTINGS_FILE, "Access Flags", "CREATOR MODELS", g_access_creator_models)

    if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Access Flags", "OWNER MODELS", g_access_owner_models, charsmax(g_access_owner_models)))
        amx_save_setting_string(ZP_SETTINGS_FILE, "Access Flags", "OWNER MODELS", g_access_owner_models)
    
    // Precache models
    new player_model[PLAYERMODEL_MAX_LENGTH], model[MODEL_MAX_LENGTH], model_path[128]
    for (index = 0; index < ArraySize(g_models_creator_human_player); index++)
    {
        ArrayGetString(g_models_creator_human_player, index, player_model, charsmax(player_model))
        formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
        precache_model(model_path)
        // Support modelT.mdl files
        formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
        if (file_exists(model_path)) precache_model(model_path)
    }
    for (index = 0; index < ArraySize(g_models_creator_human_knife); index++)
    {
        ArrayGetString(g_models_creator_human_knife, index, model, charsmax(model))
        precache_model(model)
    }

    for (index = 0; index < ArraySize(g_models_owner_human_player); index++)
    {
        ArrayGetString(g_models_owner_human_player, index, player_model, charsmax(player_model))
        formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
        precache_model(model_path)
        // Support modelT.mdl files
        formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
        if (file_exists(model_path)) precache_model(model_path)
    }
    for (index = 0; index < ArraySize(g_models_owner_human_knife); index++)
    {
        ArrayGetString(g_models_owner_human_knife, index, model, charsmax(model))
        precache_model(model)
    }
}

public plugin_natives()
{
    set_module_filter("module_filter")
    set_native_filter("native_filter")
}
public module_filter(const module[])
{
    if (equal(module, LIBRARY_SURVIVOR))
        return PLUGIN_HANDLED;
    
    return PLUGIN_CONTINUE;
}
public native_filter(const name[], index, trap)
{
    if (!trap)
        return PLUGIN_HANDLED;
        
    return PLUGIN_CONTINUE;
}

public zp_fw_core_cure_post(id, attacker)
{
    // Skip if player doesn't have required creator flags
    if (!(get_user_flags(id) & read_flags(g_access_creator_models)))
        return;

    if (!(get_user_flags(id) & read_flags(g_access_owner_models)))
        return;
    
    // Skip for Survivor
    if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && zp_class_survivor_get(id))
        return;
    
    // Apply creator human player model?
    if (get_pcvar_num(cvar_creator_models_human_player) && (get_user_flags(id) & read_flags(g_access_creator_models)))
    {
        new player_model[PLAYERMODEL_MAX_LENGTH]
        ArrayGetString(g_models_creator_human_player, random_num(0, ArraySize(g_models_creator_human_player) - 1), player_model, charsmax(player_model))
        cs_set_player_model(id, player_model)
    }

    // Apply owner human player model?
    if (get_pcvar_num(cvar_owner_models_human_player) && (get_user_flags(id) & read_flags(g_access_owner_models)))
    {
        new player_model[PLAYERMODEL_MAX_LENGTH]
        ArrayGetString(g_models_owner_human_player, random_num(0, ArraySize(g_models_owner_human_player) - 1), player_model, charsmax(player_model))
        cs_set_player_model(id, player_model)
    }
    
    // Apply creator human knife model?
    if (get_pcvar_num(cvar_creator_models_human_knife) && (get_user_flags(id) & read_flags(g_access_creator_models)))
    {
        new model[MODEL_MAX_LENGTH]
        ArrayGetString(g_models_creator_human_knife, random_num(0, ArraySize(g_models_creator_human_knife) - 1), model, charsmax(model))
        cs_set_player_view_model(id, CSW_KNIFE, model)
    }

    // Apply owner human knife model?
    if (get_pcvar_num(cvar_owner_models_human_knife) && (get_user_flags(id) & read_flags(g_access_owner_models)))
    {
        new model[MODEL_MAX_LENGTH]
        ArrayGetString(g_models_owner_human_knife, random_num(0, ArraySize(g_models_owner_human_knife) - 1), model, charsmax(model))
        cs_set_player_view_model(id, CSW_KNIFE, model)
    }
}
 
Последнее редактирование:
Сообщения
418
Реакции
-7
Ну теперь выдаёт модель создателя.. но исчезла модель владельца, что делать?? Подскажите!

C++:
#include <amxmodx>
#include <amx_settings_api>
#include <cs_player_models_api>
#include <cs_weap_models_api>
#include <zp50_core>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

// Default Priveleges models
new const models_owner_human_player[][] = { "owner" }
new const models_owner_human_knife[][] = { "models/v_knife.mdl" }
new const models_creator_human_player[][] = { "vip" }
new const models_creator_human_knife[][] = { "models/v_knife.mdl" }

#define PLAYERMODEL_MAX_LENGTH 32
#define MODEL_MAX_LENGTH 64
#define ACCESSFLAG_MAX_LENGTH 2

// Access flags
new g_access_owner_models[ACCESSFLAG_MAX_LENGTH] = "s"
new g_access_creator_models[ACCESSFLAG_MAX_LENGTH] = "u"

// Custom models
new Array:g_models_owner_human_player
new Array:g_models_owner_human_knife
new Array:g_models_creator_human_player
new Array:g_models_creator_human_knife

new cvar_owner_models_human_player, cvar_owner_models_human_knife, cvar_creator_models_human_player, cvar_creator_models_human_knife

public plugin_init()
{
    register_plugin("[ZP] Admin Models", ZP_VERSION_STRING, "ZP Dev Team")
    
    cvar_owner_models_human_player = register_cvar("zp_owner_models_human_player", "1")
    cvar_owner_models_human_knife = register_cvar("zp_owner_models_human_knife", "1")
    cvar_creator_models_human_player = register_cvar("zp_creator_models_human_player", "1")
    cvar_creator_models_human_knife = register_cvar("zp_creator_models_human_knife", "1")
}

public plugin_precache()
{
    // Initialize arrays
    g_models_owner_human_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
    g_models_owner_human_knife = ArrayCreate(MODEL_MAX_LENGTH, 1)
    g_models_creator_human_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
    g_models_creator_human_knife = ArrayCreate(MODEL_MAX_LENGTH, 1)
    
    // Load from external file
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "OWNER HUMAN", g_models_owner_human_player)
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE OWNER HUMAN", g_models_owner_human_knife)
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "CREATOR HUMAN", g_models_creator_human_player)
    amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE CREATOR HUMAN", g_models_creator_human_knife)
    
    // If we couldn't load from file, use and save default ones
    new index
    if (ArraySize(g_models_owner_human_player) == 0)
    {
        for (index = 0; index < sizeof models_owner_human_player; index++)
            ArrayPushString(g_models_owner_human_player, models_owner_human_player[index])
        
        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "OWNER HUMAN", g_models_owner_human_player)
    }
    if (ArraySize(g_models_owner_human_knife) == 0)
    {
        for (index = 0; index < sizeof models_owner_human_knife; index++)
            ArrayPushString(g_models_owner_human_knife, models_owner_human_knife[index])

        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE OWNER HUMAN", g_models_owner_human_knife)
    }
    if (ArraySize(g_models_creator_human_player) == 0)
    {
        for (index = 0; index < sizeof models_creator_human_player; index++)
            ArrayPushString(g_models_creator_human_player, models_creator_human_player[index])
        
        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "CREATOR HUMAN", g_models_creator_human_player)
    }
    if (ArraySize(g_models_creator_human_knife) == 0)
    {
        for (index = 0; index < sizeof models_creator_human_knife; index++)
            ArrayPushString(g_models_creator_human_knife, models_creator_human_knife[index])
        
        // Save to external file
        amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE CREATOR HUMAN", g_models_creator_human_knife)
    }
    
    // Load from external file, save if not found
    if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Access Flags", "OWNER MODELS", g_access_owner_models, charsmax(g_access_owner_models)))
        amx_save_setting_string(ZP_SETTINGS_FILE, "Access Flags", "OWNER MODELS", g_access_owner_models)

    if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Access Flags", "CREATOR MODELS", g_access_creator_models, charsmax(g_access_creator_models)))
        amx_save_setting_string(ZP_SETTINGS_FILE, "Access Flags", "CREATOR MODELS", g_access_creator_models)

    // Precache models
    new player_model[PLAYERMODEL_MAX_LENGTH], model[MODEL_MAX_LENGTH], model_path[128]
    for (index = 0; index < ArraySize(g_models_owner_human_player); index++)
    {
        ArrayGetString(g_models_owner_human_player, index, player_model, charsmax(player_model))
        formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
        precache_model(model_path)
        // Support modelT.mdl files
        formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
        if (file_exists(model_path)) precache_model(model_path)
    }
    for (index = 0; index < ArraySize(g_models_owner_human_knife); index++)
    {
        ArrayGetString(g_models_owner_human_knife, index, model, charsmax(model))
        precache_model(model)
    }
    
    for (index = 0; index < ArraySize(g_models_creator_human_player); index++)
    {
        ArrayGetString(g_models_creator_human_player, index, player_model, charsmax(player_model))
        formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
        precache_model(model_path)
        // Support modelT.mdl files
        formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
        if (file_exists(model_path)) precache_model(model_path)
    }
    for (index = 0; index < ArraySize(g_models_creator_human_knife); index++)
    {
        ArrayGetString(g_models_creator_human_knife, index, model, charsmax(model))
        precache_model(model)
    }
}

public plugin_natives()
{
    set_module_filter("module_filter")
    set_native_filter("native_filter")
}
public module_filter(const module[])
{
    if (equal(module, LIBRARY_SURVIVOR))
        return PLUGIN_HANDLED;
    
    return PLUGIN_CONTINUE;
}
public native_filter(const name[], index, trap)
{
    if (!trap)
        return PLUGIN_HANDLED;
        
    return PLUGIN_CONTINUE;
}

public zp_fw_core_cure_post(id, attacker)
{
    // Skip if player doesn't have required creator flags
    if (!(get_user_flags(id) & read_flags(g_access_creator_models)))
        return;

    if (!(get_user_flags(id) & read_flags(g_access_owner_models)))
        return;
    
    // Skip for Survivor
    if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && zp_class_survivor_get(id))
        return;
    

    // Apply owner human player model?
    if (get_pcvar_num(cvar_owner_models_human_player) && (get_user_flags(id) & read_flags(g_access_owner_models)))
    {
        new player_model[PLAYERMODEL_MAX_LENGTH]
        ArrayGetString(g_models_owner_human_player, random_num(0, ArraySize(g_models_owner_human_player) - 1), player_model, charsmax(player_model))
        cs_set_player_model(id, player_model)
    }

    // Apply owner human knife model?
    if (get_pcvar_num(cvar_owner_models_human_knife) && (get_user_flags(id) & read_flags(g_access_owner_models)))
    {
        new model[MODEL_MAX_LENGTH]
        ArrayGetString(g_models_owner_human_knife, random_num(0, ArraySize(g_models_owner_human_knife) - 1), model, charsmax(model))
        cs_set_player_view_model(id, CSW_KNIFE, model)
    }

    // Apply creator human player model?
    if (get_pcvar_num(cvar_creator_models_human_player) && (get_user_flags(id) & read_flags(g_access_creator_models)))
    {
        new player_model[PLAYERMODEL_MAX_LENGTH]
        ArrayGetString(g_models_creator_human_player, random_num(0, ArraySize(g_models_creator_human_player) - 1), player_model, charsmax(player_model))
        cs_set_player_model(id, player_model)
    }

    // Apply creator human knife model?
    if (get_pcvar_num(cvar_creator_models_human_knife) && (get_user_flags(id) & read_flags(g_access_creator_models)))
    {
        new model[MODEL_MAX_LENGTH]
        ArrayGetString(g_models_creator_human_knife, random_num(0, ArraySize(g_models_creator_human_knife) - 1), model, charsmax(model))
        cs_set_player_view_model(id, CSW_KNIFE, model)
    }
}
 
Сообщения
418
Реакции
-7
Подскажите пожалуйста, что не так, целый день не мог поставить нормально модели.. Кто-нибудь, пожалуйста, инфу для ZP 4.3 я нашел, но ZP 5.0 (5.0.8) я не нашёл (
 
Сообщения
674
Реакции
242
Помог
11 раз(а)
ставить порядок от высшего к низшему и в каждой проверку прекращать действии (возвращать return) в проверке (get_user_flags(id) & read_flags(g_access_creator_models)) и (get_user_flags(id) & read_flags(g_access_creator_models))

что за мода пошла? не понимаю флагов подобие Создатель\Владелец\Спонсор, это типа такой подход по выдергивание денег?
 
Сообщения
418
Реакции
-7
@Limbooc,от высшего к низшему поставил, модель владельца перестала работать, вот return после ArrayString возвращать?
30 Мар 2023
ставить порядок от высшего к низшему и в каждой проверку прекращать действии (возвращать return) в проверке (get_user_flags(id) & read_flags(g_access_creator_models)) и (get_user_flags(id) & read_flags(g_access_creator_models))

что за мода пошла? не понимаю флагов подобие Создатель\Владелец\Спонсор, это типа такой подход по выдергивание денег?
Если это сработает, я не знаю, насколько сильно тебя отблагодарить))
 
Сообщения
418
Реакции
-7
Мб здесь какая никакая ошибка?

[Access Flags]
MAKE ZOMBIE = u
MAKE HUMAN = u
MAKE NEMESIS = u
MAKE SURVIVOR = u
RESPAWN PLAYERS = u
START GAME MODE = u
CREATOR MODELS = u
OWNER MODELS = d

[Player Models] (Случайный выбор моделей, если вы ввели больше одной модели)
NEMESIS = nemesis
SURVIVOR = survivor
CREATOR HUMAN = vip
OWNER HUMAN = owner
30 Мар 2023
@Limbooc,для меня это не подход для денег, имеешь больше возможностей прост)
 
Сообщения
418
Реакции
-7
Решил..
Убрал это..

C++:
// Skip if player doesn't have required creator flags
if (!(get_user_flags(id) & read_flags(g_access_creator_models)))
    return;

if (!(get_user_flags(id) & read_flags(g_access_owner_models)))
    return;
 
Сообщения
3,593
Реакции
1,577
Помог
141 раз(а)
RedGamer, естественно это мешало, ведь у тебя если нет флагов, до второй проверки даже не доходило. Плюс ко всему, ниже по коду ещё раз зачем-то флаги проверяются
 
Сообщения
3,593
Реакции
1,577
Помог
141 раз(а)
RedGamer, я разве сказал их убрать? Убрать надо было проверки вверху с return
 
Сообщения
418
Реакции
-7
RedGamer, естественно это мешало, ведь у тебя если нет флагов, до второй проверки даже не доходило. Плюс ко всему, ниже по коду ещё раз зачем-то флаги проверяются
Плюс ко всему, ниже по коду ещё раз зачем-то флаги проверяются
30 Мар 2023
Благодарю за помощь какой раз уже)) Закройте тему, админы)
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу