AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved speed issue (https://forums.alliedmods.net/showthread.php?t=339258)

Alahmoh 08-28-2022 15:50

speed issue
 
I have zombie plague 5.0.8, the problem is the speed of the zombie when I get infected goes up to 400.0 idk why, I could measure the speed using speedometer plugin
nothing seems to work I even changed the plugin of the zombie which is zp50_class_zombie
but still didnt work n here's my plugin :-
PHP Code:

/*================================================================================
    
    --------------------------
    -*- [ZP] Class: Zombie -*-
    --------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <amx_settings_api>
#include <cs_player_models_api>
#include <cs_weap_models_api>
#include <cs_maxspeed_api>
#include <cs_weap_restrict_api>
#include <zp50_core>
#include <zp50_colorchat>
#include <zp50_class_zombie_const>

// Zombie Classes file
new const ZP_ZOMBIECLASSES_FILE[] = "zp_zombieclasses.ini"

#define MAXPLAYERS 32

#define ZOMBIES_DEFAULT_NAME "Zombie"
#define ZOMBIES_DEFAULT_DESCRIPTION "Default"
#define ZOMBIES_DEFAULT_HEALTH 1800
#define ZOMBIES_DEFAULT_SPEED 0.75
#define ZOMBIES_DEFAULT_GRAVITY 1.0
#define ZOMBIES_DEFAULT_MODEL "zombie"
#define ZOMBIES_DEFAULT_CLAWMODEL "models/zombie_plague/v_knife_zombie.mdl"
#define ZOMBIES_DEFAULT_KNOCKBACK 1.0

// Allowed weapons for zombies
const ZOMBIE_ALLOWED_WEAPONS_BITSUM = (1<<CSW_KNIFE)|(1<<CSW_HEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_C4)
const 
ZOMBIE_DEFAULT_ALLOWED_WEAPON CSW_KNIFE

// CS Player PData Offsets (win32)
const OFFSET_CSMENUCODE 205

// For class list menu handlers
#define MENU_PAGE_CLASS g_menu_data[id]
new g_menu_data[MAXPLAYERS+1]

enum _:TOTAL_FORWARDS
{
    
FW_CLASS_SELECT_PRE 0,
    
FW_CLASS_SELECT_POST
}
new 
g_Forwards[TOTAL_FORWARDS]
new 
g_ForwardResult

new g_ZombieClassCount
new Array:g_ZombieClassRealName
new Array:g_ZombieClassName
new Array:g_ZombieClassDesc
new Array:g_ZombieClassHealth
new Array:g_ZombieClassSpeed
new Array:g_ZombieClassGravity
new Array:g_ZombieClassKnockbackFile
new Array:g_ZombieClassKnockback
new Array:g_ZombieClassModelsFile
new Array:g_ZombieClassModelsHandle
new Array:g_ZombieClassClawsFile
new Array:g_ZombieClassClawsHandle
new g_ZombieClass[MAXPLAYERS+1]
new 
g_ZombieClassNext[MAXPLAYERS+1]
new 
g_AdditionalMenuText[32]

public 
plugin_init()
{
    
register_plugin("[ZP] Class: Zombie"ZP_VERSION_STRING"ZP Dev Team")
    
    
register_clcmd("say /zclass""show_menu_zombieclass")
    
register_clcmd("say /class""show_class_menu")
    
    
g_Forwards[FW_CLASS_SELECT_PRE] = CreateMultiForward("zp_fw_class_zombie_select_pre"ET_CONTINUEFP_CELLFP_CELL)
    
g_Forwards[FW_CLASS_SELECT_POST] = CreateMultiForward("zp_fw_class_zombie_select_post"ET_CONTINUEFP_CELLFP_CELL)
}

public 
plugin_precache()
{
    new 
model_path[128]
    
formatex(model_pathcharsmax(model_path), "models/player/%s/%s.mdl"ZOMBIES_DEFAULT_MODELZOMBIES_DEFAULT_MODEL)
    
precache_model(model_path)
    
// Support modelT.mdl files
    
formatex(model_pathcharsmax(model_path), "models/player/%s/%sT.mdl"ZOMBIES_DEFAULT_MODELZOMBIES_DEFAULT_MODEL)
    if (
file_exists(model_path)) precache_model(model_path)
    
    
precache_model(ZOMBIES_DEFAULT_CLAWMODEL)
}

public 
plugin_cfg()
{
    
// No classes loaded, add default zombie class
    
if (g_ZombieClassCount 1)
    {
        
ArrayPushString(g_ZombieClassRealNameZOMBIES_DEFAULT_NAME)
        
ArrayPushString(g_ZombieClassNameZOMBIES_DEFAULT_NAME)
        
ArrayPushString(g_ZombieClassDescZOMBIES_DEFAULT_DESCRIPTION)
        
ArrayPushCell(g_ZombieClassHealthZOMBIES_DEFAULT_HEALTH)
        
ArrayPushCell(g_ZombieClassSpeedZOMBIES_DEFAULT_SPEED)
        
ArrayPushCell(g_ZombieClassGravityZOMBIES_DEFAULT_GRAVITY)
        
ArrayPushCell(g_ZombieClassKnockbackFilefalse)
        
ArrayPushCell(g_ZombieClassKnockbackZOMBIES_DEFAULT_KNOCKBACK)
        
ArrayPushCell(g_ZombieClassModelsFilefalse)
        
ArrayPushCell(g_ZombieClassModelsHandleInvalid_Array)
        
ArrayPushCell(g_ZombieClassClawsFilefalse)
        
ArrayPushCell(g_ZombieClassClawsHandleInvalid_Array)
        
g_ZombieClassCount++
    }
}

public 
plugin_natives()
{
    
register_library("zp50_class_zombie")
    
register_native("zp_class_zombie_get_current""native_class_zombie_get_current")
    
register_native("zp_class_zombie_get_next""native_class_zombie_get_next")
    
register_native("zp_class_zombie_set_next""native_class_zombie_set_next")
    
register_native("zp_class_zombie_get_max_health""_class_zombie_get_max_health")
    
register_native("zp_class_zombie_register""native_class_zombie_register")
    
register_native("zp_class_zombie_register_model""_class_zombie_register_model")
    
register_native("zp_class_zombie_register_claw""_class_zombie_register_claw")
    
register_native("zp_class_zombie_register_kb""native_class_zombie_register_kb")
    
register_native("zp_class_zombie_get_id""native_class_zombie_get_id")
    
register_native("zp_class_zombie_get_name""native_class_zombie_get_name")
    
register_native("zp_class_zombie_get_real_name""_class_zombie_get_real_name")
    
register_native("zp_class_zombie_get_desc""native_class_zombie_get_desc")
    
register_native("zp_class_zombie_get_kb""native_class_zombie_get_kb")
    
register_native("zp_class_zombie_get_count""native_class_zombie_get_count")
    
register_native("zp_class_zombie_show_menu""native_class_zombie_show_menu")
    
register_native("zp_class_zombie_menu_text_add""_class_zombie_menu_text_add")
    
    
// Initialize dynamic arrays
    
g_ZombieClassRealName ArrayCreate(321)
    
g_ZombieClassName ArrayCreate(321)
    
g_ZombieClassDesc ArrayCreate(321)
    
g_ZombieClassHealth ArrayCreate(11)
    
g_ZombieClassSpeed ArrayCreate(11)
    
g_ZombieClassGravity ArrayCreate(11)
    
g_ZombieClassKnockback ArrayCreate(11)
    
g_ZombieClassKnockbackFile ArrayCreate(11)
    
g_ZombieClassModelsHandle ArrayCreate(11)
    
g_ZombieClassModelsFile ArrayCreate(11)
    
g_ZombieClassClawsHandle ArrayCreate(11)
    
g_ZombieClassClawsFile ArrayCreate(11)
}

public 
client_putinserver(id)
{
    
g_ZombieClass[id] = ZP_INVALID_ZOMBIE_CLASS
    g_ZombieClassNext
[id] = ZP_INVALID_ZOMBIE_CLASS
}

public 
client_disconnected(id)
{
    
// Reset remembered menu pages
    
MENU_PAGE_CLASS 0
}

public 
show_class_menu(id)
{
    if (
zp_core_is_zombie(id))
        
show_menu_zombieclass(id)
}

public 
show_menu_zombieclass(id)
{
    static 
menu[128], name[32], description[32], transkey[64]
    new 
menuiditemdata[2], index
    
    formatex
(menucharsmax(menu), "%L\r"id"MENU_ZCLASS")
    
menuid menu_create(menu"menu_zombieclass")
    
    for (
index 0index g_ZombieClassCountindex++)
    {
        
// Additional text to display
        
g_AdditionalMenuText[0] = 0
        
        
// Execute class select attempt forward
        
ExecuteForward(g_Forwards[FW_CLASS_SELECT_PRE], g_ForwardResultidindex)
        
        
// Show class to player?
        
if (g_ForwardResult >= ZP_CLASS_DONT_SHOW)
            continue;
        
        
ArrayGetString(g_ZombieClassNameindexnamecharsmax(name))
        
ArrayGetString(g_ZombieClassDescindexdescriptioncharsmax(description))
        
        
// ML support for class name + description
        
formatex(transkeycharsmax(transkey), "ZOMBIEDESC %s"name)
        if (
GetLangTransKey(transkey) != TransKey_Badformatex(descriptioncharsmax(description), "%L"idtranskey)
        
formatex(transkeycharsmax(transkey), "ZOMBIENAME %s"name)
        if (
GetLangTransKey(transkey) != TransKey_Badformatex(namecharsmax(name), "%L"idtranskey)
        
        
// Class available to player?
        
if (g_ForwardResult >= ZP_CLASS_NOT_AVAILABLE)
            
formatex(menucharsmax(menu), "\d%s %s %s"namedescriptiong_AdditionalMenuText)
        
// Class is current class?
        
else if (index == g_ZombieClassNext[id])
            
formatex(menucharsmax(menu), "\r%s \y%s \w%s"namedescriptiong_AdditionalMenuText)
        else
            
formatex(menucharsmax(menu), "%s \y%s \w%s"namedescriptiong_AdditionalMenuText)
        
        
itemdata[0] = index
        itemdata
[1] = 0
        menu_additem
(menuidmenuitemdata)
    }
    
    
// No classes to display?
    
if (menu_items(menuid) <= 0)
    {
        
zp_colored_print(id"%L"id"NO_CLASSES")
        
menu_destroy(menuid)
        return;
    }
    
    
// Back - Next - Exit
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_BACKNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_NEXT")
    
menu_setprop(menuidMPROP_NEXTNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_EXIT")
    
menu_setprop(menuidMPROP_EXITNAMEmenu)
    
    
// If remembered page is greater than number of pages, clamp down the value
    
MENU_PAGE_CLASS min(MENU_PAGE_CLASSmenu_pages(menuid)-1)
    
    
// Fix for AMXX custom menus
    
set_pdata_int(idOFFSET_CSMENUCODE0)
    
menu_display(idmenuidMENU_PAGE_CLASS)
}

public 
menu_zombieclass(idmenuiditem)
{
    
// Menu was closed
    
if (item == MENU_EXIT)
    {
        
MENU_PAGE_CLASS 0
        menu_destroy
(menuid)
        return 
PLUGIN_HANDLED;
    }
    
    
// Remember class menu page
    
MENU_PAGE_CLASS item 7
    
    
// Retrieve class index
    
new itemdata[2], dummyindex
    menu_item_getinfo
(menuiditemdummyitemdatacharsmax(itemdata), __dummy)
    
index itemdata[0]
    
    
// Execute class select attempt forward
    
ExecuteForward(g_Forwards[FW_CLASS_SELECT_PRE], g_ForwardResultidindex)
    
    
// Class available to player?
    
if (g_ForwardResult >= ZP_CLASS_NOT_AVAILABLE)
    {
        
menu_destroy(menuid)
        return 
PLUGIN_HANDLED;
    }
    
    
// Make selected class next class for player
    
g_ZombieClassNext[id] = index
    
    
new name[32], transkey[64]
    new 
Float:maxspeed Float:ArrayGetCell(g_ZombieClassSpeedg_ZombieClassNext[id])
    
ArrayGetString(g_ZombieClassNameg_ZombieClassNext[id], namecharsmax(name))
    
// ML support for class name
    
formatex(transkeycharsmax(transkey), "ZOMBIENAME %s"name)
    if (
GetLangTransKey(transkey) != TransKey_Badformatex(namecharsmax(name), "%L"idtranskey)
    
    
// Show selected zombie class
    
zp_colored_print(id"%L: %s"id"ZOMBIE_SELECT"name)
    
zp_colored_print(id"%L: %d %L: %d %L: %.2fx %L %.2fx"id"ZOMBIE_ATTRIB1"ArrayGetCell(g_ZombieClassHealthg_ZombieClassNext[id]), id"ZOMBIE_ATTRIB2"cs_maxspeed_display_value(maxspeed), id"ZOMBIE_ATTRIB3"Float:ArrayGetCell(g_ZombieClassGravityg_ZombieClassNext[id]), id"ZOMBIE_ATTRIB4"Float:ArrayGetCell(g_ZombieClassKnockbackg_ZombieClassNext[id]))
    
    
// Execute class select post forward
    
ExecuteForward(g_Forwards[FW_CLASS_SELECT_POST], g_ForwardResultidindex)
    
    
menu_destroy(menuid)
    return 
PLUGIN_HANDLED;
}

public 
zp_fw_core_infect_post(idattacker)
{
    
// Show zombie class menu if they haven't chosen any (e.g. just connected)
    
if (g_ZombieClassNext[id] == ZP_INVALID_ZOMBIE_CLASS)
    {
        if (
g_ZombieClassCount 1)
            
show_menu_zombieclass(id)
        else 
// If only one class is registered, choose it automatically
            
g_ZombieClassNext[id] = 0
    
}
    
    
// Bots pick class automatically
    
if (is_user_bot(id))
    {
        
// Try choosing class
        
new indexstart_index random_num(0g_ZombieClassCount 1)
        for (
index start_index 1/* no condition */index++)
        {
            
// Start over when we reach the end
            
if (index >= g_ZombieClassCount)
                
index 0
            
            
// Execute class select attempt forward
            
ExecuteForward(g_Forwards[FW_CLASS_SELECT_PRE], g_ForwardResultidindex)
            
            
// Class available to player?
            
if (g_ForwardResult ZP_CLASS_NOT_AVAILABLE)
            {
                
g_ZombieClassNext[id] = index
                
break;
            }
            
            
// Loop completed, no class could be chosen
            
if (index == start_index)
                break;
        }
    }
    
    
// Set selected zombie class. If none selected yet, use the first one
    
g_ZombieClass[id] = g_ZombieClassNext[id]
    if (
g_ZombieClass[id] == ZP_INVALID_ZOMBIE_CLASSg_ZombieClass[id] = 0
    
    
// Apply zombie attributes
    
set_user_health(idArrayGetCell(g_ZombieClassHealthg_ZombieClass[id]))
    
set_user_gravity(idFloat:ArrayGetCell(g_ZombieClassGravityg_ZombieClass[id]))
    
cs_set_player_maxspeed_auto(idFloat:ArrayGetCell(g_ZombieClassSpeedg_ZombieClass[id]))
    
    
// Apply zombie player model
    
new Array:class_models ArrayGetCell(g_ZombieClassModelsHandleg_ZombieClass[id])
    if (
class_models != Invalid_Array)
    {
        new 
index random_num(0ArraySize(class_models) - 1)
        new 
player_model[32]
        
ArrayGetString(class_modelsindexplayer_modelcharsmax(player_model))
        
cs_set_player_model(idplayer_model)
    }
    else
    {
        
// No models registered for current class, use default model
        
cs_set_player_model(idZOMBIES_DEFAULT_MODEL)
    }
    
    
// Apply zombie claw model
    
new claw_model[64], Array:class_claws ArrayGetCell(g_ZombieClassClawsHandleg_ZombieClass[id])
    if (
class_claws != Invalid_Array)
    {
        new 
index random_num(0ArraySize(class_claws) - 1)
        
ArrayGetString(class_clawsindexclaw_modelcharsmax(claw_model))
        
cs_set_player_view_model(idCSW_KNIFEclaw_model)
    }
    else
    {
        
// No models registered for current class, use default model
        
cs_set_player_view_model(idCSW_KNIFEZOMBIES_DEFAULT_CLAWMODEL)
    }
    
cs_set_player_weap_model(idCSW_KNIFE"")
    
    
// Apply weapon restrictions for zombies
    
cs_set_player_weap_restrict(idtrueZOMBIE_ALLOWED_WEAPONS_BITSUMZOMBIE_DEFAULT_ALLOWED_WEAPON)
}

public 
zp_fw_core_cure(idattacker)
{
    
// Remove zombie claw models
    
cs_reset_player_view_model(idCSW_KNIFE)
    
cs_reset_player_weap_model(idCSW_KNIFE)
    
    
// Remove zombie weapon restrictions
    
cs_set_player_weap_restrict(idfalse)
}

public 
native_class_zombie_get_current(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
ZP_INVALID_ZOMBIE_CLASS;
    }
    
    return 
g_ZombieClass[id];
}

public 
native_class_zombie_get_next(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
ZP_INVALID_ZOMBIE_CLASS;
    }
    
    return 
g_ZombieClassNext[id];
}

public 
native_class_zombie_set_next(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
false;
    }
    
    new 
classid get_param(2)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    
g_ZombieClassNext[id] = classid
    
return true;
}

public 
_class_zombie_get_max_health(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return -
1;
    }
    
    new 
classid get_param(2)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return -
1;
    }
    
    return 
ArrayGetCell(g_ZombieClassHealthclassid);
}

public 
native_class_zombie_register(plugin_idnum_params)
{
    new 
name[32]
    
get_string(1namecharsmax(name))
    
    if (
strlen(name) < 1)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Can't register zombie class with an empty name")
        return 
ZP_INVALID_ZOMBIE_CLASS;
    }
    
    new 
indexzombieclass_name[32]
    for (
index 0index g_ZombieClassCountindex++)
    {
        
ArrayGetString(g_ZombieClassRealNameindexzombieclass_namecharsmax(zombieclass_name))
        if (
equali(namezombieclass_name))
        {
            
log_error(AMX_ERR_NATIVE"[ZP] Zombie class already registered (%s)"name)
            return 
ZP_INVALID_ZOMBIE_CLASS;
        }
    }
    
    new 
description[32]
    
get_string(2descriptioncharsmax(description))
    new 
health get_param(3)
    new 
Float:speed get_param_f(4)
    new 
Float:gravity get_param_f(5)
    
    
// Load settings from zombie classes file
    
new real_name[32]
    
copy(real_namecharsmax(real_name), name)
    
ArrayPushString(g_ZombieClassRealNamereal_name)
    
    
// Name
    
if (!amx_load_setting_string(ZP_ZOMBIECLASSES_FILEreal_name"NAME"namecharsmax(name)))
        
amx_save_setting_string(ZP_ZOMBIECLASSES_FILEreal_name"NAME"name)
    
ArrayPushString(g_ZombieClassNamename)
    
    
// Description
    
if (!amx_load_setting_string(ZP_ZOMBIECLASSES_FILEreal_name"INFO"descriptioncharsmax(description)))
        
amx_save_setting_string(ZP_ZOMBIECLASSES_FILEreal_name"INFO"description)
    
ArrayPushString(g_ZombieClassDescdescription)
    
    
// Models
    
new Array:class_models ArrayCreate(321)
    
amx_load_setting_string_arr(ZP_ZOMBIECLASSES_FILEreal_name"MODELS"class_models)
    if (
ArraySize(class_models) > 0)
    {
        
ArrayPushCell(g_ZombieClassModelsFiletrue)
        
        
// Precache player models
        
new indexplayer_model[32], model_path[128]
        for (
index 0index ArraySize(class_models); index++)
        {
            
ArrayGetString(class_modelsindexplayer_modelcharsmax(player_model))
            
formatex(model_pathcharsmax(model_path), "models/player/%s/%s.mdl"player_modelplayer_model)
            
precache_model(model_path)
            
// Support modelT.mdl files
            
formatex(model_pathcharsmax(model_path), "models/player/%s/%sT.mdl"player_modelplayer_model)
            if (
file_exists(model_path)) precache_model(model_path)
        }
    }
    else
    {
        
ArrayPushCell(g_ZombieClassModelsFilefalse)
        
ArrayDestroy(class_models)
        
amx_save_setting_string(ZP_ZOMBIECLASSES_FILEreal_name"MODELS"ZOMBIES_DEFAULT_MODEL)
    }
    
ArrayPushCell(g_ZombieClassModelsHandleclass_models)
    
    
// Claw models
    
new Array:class_claws ArrayCreate(641)
    
amx_load_setting_string_arr(ZP_ZOMBIECLASSES_FILEreal_name"CLAWMODEL"class_claws)
    if (
ArraySize(class_claws) > 0)
    {
        
ArrayPushCell(g_ZombieClassClawsFiletrue)
        
        
// Precache claw models
        
new indexclaw_model[64]
        for (
index 0index ArraySize(class_claws); index++)
        {
            
ArrayGetString(class_clawsindexclaw_modelcharsmax(claw_model))
            
precache_model(claw_model)
        }
    }
    else
    {
        
ArrayPushCell(g_ZombieClassClawsFilefalse)
        
ArrayDestroy(class_claws)
        
amx_save_setting_string(ZP_ZOMBIECLASSES_FILEreal_name"CLAWMODEL"ZOMBIES_DEFAULT_CLAWMODEL)
    }
    
ArrayPushCell(g_ZombieClassClawsHandleclass_claws)
    
    
// Health
    
if (!amx_load_setting_int(ZP_ZOMBIECLASSES_FILEreal_name"HEALTH"health))
        
amx_save_setting_int(ZP_ZOMBIECLASSES_FILEreal_name"HEALTH"health)
    
ArrayPushCell(g_ZombieClassHealthhealth)
    
    
// Speed
    
if (!amx_load_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"SPEED"speed))
        
amx_save_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"SPEED"speed)
    
ArrayPushCell(g_ZombieClassSpeedspeed)
    
    
// Gravity
    
if (!amx_load_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"GRAVITY"gravity))
        
amx_save_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"GRAVITY"gravity)
    
ArrayPushCell(g_ZombieClassGravitygravity)
    
    
// Knockback
    
new Float:knockback ZOMBIES_DEFAULT_KNOCKBACK
    
if (!amx_load_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"KNOCKBACK"knockback))
    {
        
ArrayPushCell(g_ZombieClassKnockbackFilefalse)
        
amx_save_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"KNOCKBACK"knockback)
    }
    else
        
ArrayPushCell(g_ZombieClassKnockbackFiletrue)
    
ArrayPushCell(g_ZombieClassKnockbackknockback)
    
    
g_ZombieClassCount++
    return 
g_ZombieClassCount 1;
}

public 
_class_zombie_register_model(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    
// Player models already loaded from file
    
if (ArrayGetCell(g_ZombieClassModelsFileclassid))
        return 
true;
    
    new 
player_model[32]
    
get_string(2player_modelcharsmax(player_model))
    
    new 
model_path[128]
    
formatex(model_pathcharsmax(model_path), "models/player/%s/%s.mdl"player_modelplayer_model)
    
    
precache_model(model_path)
    
    
// Support modelT.mdl files
    
formatex(model_pathcharsmax(model_path), "models/player/%s/%sT.mdl"player_modelplayer_model)
    if (
file_exists(model_path)) precache_model(model_path)
    
    new Array:
class_models ArrayGetCell(g_ZombieClassModelsHandleclassid)
    
    
// No models registered yet?
    
if (class_models == Invalid_Array)
    {
        
class_models ArrayCreate(321)
        
ArraySetCell(g_ZombieClassModelsHandleclassidclass_models)
    }
    
ArrayPushString(class_modelsplayer_model)
    
    
// Save models to file
    
new real_name[32]
    
ArrayGetString(g_ZombieClassRealNameclassidreal_namecharsmax(real_name))
    
amx_save_setting_string_arr(ZP_ZOMBIECLASSES_FILEreal_name"MODELS"class_models)
    
    return 
true;
}

public 
_class_zombie_register_claw(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    
// Claw models already loaded from file
    
if (ArrayGetCell(g_ZombieClassClawsFileclassid))
        return 
true;
    
    new 
claw_model[64]
    
get_string(2claw_modelcharsmax(claw_model))
    
    
precache_model(claw_model)
    
    new Array:
class_claws ArrayGetCell(g_ZombieClassClawsHandleclassid)
    
    
// No models registered yet?
    
if (class_claws == Invalid_Array)
    {
        
class_claws ArrayCreate(641)
        
ArraySetCell(g_ZombieClassClawsHandleclassidclass_claws)
    }
    
ArrayPushString(class_clawsclaw_model)
    
    
// Save models to file
    
new real_name[32]
    
ArrayGetString(g_ZombieClassRealNameclassidreal_namecharsmax(real_name))
    
amx_save_setting_string_arr(ZP_ZOMBIECLASSES_FILEreal_name"CLAWMODEL"class_claws)
    
    return 
true;
}

public 
native_class_zombie_register_kb(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    
// Knockback already loaded from file
    
if (ArrayGetCell(g_ZombieClassKnockbackFileclassid))
        return 
true;
    
    new 
Float:knockback get_param_f(2)
    
    
// Set zombie class knockback
    
ArraySetCell(g_ZombieClassKnockbackclassidknockback)
    
    
// Save to file
    
new real_name[32]
    
ArrayGetString(g_ZombieClassRealNameclassidreal_namecharsmax(real_name))
    
amx_save_setting_float(ZP_ZOMBIECLASSES_FILEreal_name"KNOCKBACK"knockback)
    
    return 
true;
}

public 
native_class_zombie_get_id(plugin_idnum_params)
{
    new 
real_name[32]
    
get_string(1real_namecharsmax(real_name))
    
    
// Loop through every class
    
new indexzombieclass_name[32]
    for (
index 0index g_ZombieClassCountindex++)
    {
        
ArrayGetString(g_ZombieClassRealNameindexzombieclass_namecharsmax(zombieclass_name))
        if (
equali(real_namezombieclass_name))
            return 
index;
    }
    
    return 
ZP_INVALID_ZOMBIE_CLASS;
}

public 
native_class_zombie_get_name(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    new 
name[32]
    
ArrayGetString(g_ZombieClassNameclassidnamecharsmax(name))
    
    new 
len get_param(3)
    
set_string(2namelen)
    return 
true;
}


public 
_class_zombie_get_real_name(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    new 
real_name[32]
    
ArrayGetString(g_ZombieClassRealNameclassidreal_namecharsmax(real_name))
    
    new 
len get_param(3)
    
set_string(2real_namelen)
    return 
true;
}

public 
native_class_zombie_get_desc(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
false;
    }
    
    new 
description[32]
    
ArrayGetString(g_ZombieClassDescclassiddescriptioncharsmax(description))
    
    new 
len get_param(3)
    
set_string(2descriptionlen)
    return 
true;
}

public 
Float:native_class_zombie_get_kb(plugin_idnum_params)
{
    new 
classid get_param(1)
    
    if (
classid || classid >= g_ZombieClassCount)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid zombie class id (%d)"classid)
        return 
ZOMBIES_DEFAULT_KNOCKBACK;
    }
    
    
// Return zombie class knockback)
    
return ArrayGetCell(g_ZombieClassKnockbackclassid);
}

public 
native_class_zombie_get_count(plugin_idnum_params)
{
    return 
g_ZombieClassCount;
}

public 
native_class_zombie_show_menu(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_connected(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
false;
    }
    
    
show_menu_zombieclass(id)
    return 
true;
}

public 
_class_zombie_menu_text_add(plugin_idnum_params)
{
    static 
text[32]
    
get_string(1textcharsmax(text))
    
format(g_AdditionalMenuTextcharsmax(g_AdditionalMenuText), "%s%s"g_AdditionalMenuTexttext)




All times are GMT -4. The time now is 15:41.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.