Skip to content

Commit

Permalink
Adding some natives
Browse files Browse the repository at this point in the history
  • Loading branch information
PerfectScrash committed Feb 9, 2022
1 parent d5a3edd commit 72b129b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/amxmodx/configs/zpsp_gamemodes.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
; GAMEMODE NAME = Assassin vs Snipers // Game mod Name
; GAMEMODE ENABLE = 1 // Enable Game mod ? (0 - Disable | 1 - Enable)
; GAMEMODE ENABLE ON ESCAPE MAP = 0 // Enable Game Mod On Zombie Escape Map ? (0 - Disable by default | 1 - Enable)
; GAMEMODE FLAGS = a // Flag acess for start a gamemode
; GAMEMODE CHANCE = 50 // Chance of mod in 1 to x
; GAMEMODE RESPAWN MODE = 4 // Respawn Mode (0 - Don´t Respawn | 1 - Respawn as Human | 2 - Respawn as Zombie | 3 - Respawn Randonly | 4 - Balanced)
; GAMEMODE RESPAWN LIMIT = 0 // Respawn Limit (0 - Unlimited)
Expand Down
2 changes: 2 additions & 0 deletions addons/amxmodx/configs/zpsp_special_classes.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
; ALLOW RESPAWN = 1 // Allow Respawn? (0 - Disable | 1 - Enable)
; PAINFREE = 0 // Allow Painfree? (0 - Disable | 1 - Enable)
; ENABLE = 1 // Enable special class (0 - Disable | 1 - Enable | 2 - Enable in Normal ZM Maps Only | 3 - Enable in ZE Maps Only)
; FLAGS = a // Flag acess to make class
; NAME BY LANG = 0 // Name by Lang?
; LANG KEY = ITEM_LANG_DEFAULT_KEY // Lang Key

Expand Down Expand Up @@ -67,5 +68,6 @@
; ALLOW BURN = 0 // Allow Burn? (0 - Disable | 1 - Enable)
; ALLOW FROST = 0 // Allow Frozen? (0 - Disable | 1 - Enable)
; ENABLE = 1 // Enable special class (0 - Disable | 1 - Enable | 2 - Enable in Normal ZM Maps Only | 3 - Enable in ZE Maps Only)
; FLAGS = a // Flag acess to make class
; NAME BY LANG = 0 // Name by Lang?
; LANG KEY = ITEM_LANG_DEFAULT_KEY // Lang Key
30 changes: 30 additions & 0 deletions addons/amxmodx/scripting/include/zombie_plague_special.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,36 @@ native zp_set_human_class_name(class, newname[]);
*/
native zp_add_hud_text(const text[]);

/**
* Register Zombie Class custom pain sound
*
* @param classid Zombie Class index
* @param sound Pain sound
* @return True if sucess, false otherwise
* @error If Zombie Class index are invalid
*/
native zp_register_zclass_painsnd(classid, const sound[]);

/**
* Register Zombie Class custom death sound
*
* @param classid Zombie Class index
* @param sound Death sound
* @return True if sucess, false otherwise
* @error If Zombie Class index are invalid
*/
native zp_register_zclass_deathsnd(classid, const sound[]);

/**
* Register Custom Special Zombie custom death sound
*
* @param classid Special Zombie Class index
* @param sound Death sound
* @return True if sucess, false otherwise
* @error If Custom Special Zombie index are invalid
*/
native zp_register_zmspecial_deathsnd(classid, const sound[]);

/***************************************************
-------------------- Forwards ----------------------
****************************************************/
Expand Down
72 changes: 72 additions & 0 deletions addons/amxmodx/scripting/zombie_plague_special_45.sma
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@
- Added Native: zp_add_hud_text(const text[]);
- Added Native: zp_get_user_hud_type(id);
- Now all natives are using "style 0"
- Added Native: zp_register_zclass_painsnd(classid, const sound[])
- Added Native: zp_register_zclass_deathsnd(classid, const sound[])
- Added Native: zp_register_zmspecial_deathsnd(classid, const sound[])


============================================================================================================================*/
Expand Down Expand Up @@ -1021,6 +1024,9 @@ public plugin_natives() {
register_native("zp_set_human_class_info", "native_set_human_class_info");
register_native("zp_set_human_class_name", "native_set_human_class_name");
register_native("zp_get_human_class_realname", "native_get_hclass_realname");
register_native("zp_register_zclass_painsnd", "native_register_zclass_painsnd");
register_native("zp_register_zclass_deathsnd", "native_register_zclass_deathsnd");
register_native("zp_register_zmspecial_deathsnd", "native_register_zmspecial_deathsnd");
}
public plugin_precache() {
register_plugin(PLUGIN, VERSION, AUTHOR) // Register earlier to show up in plugins list properly after plugin disable/error at loading
Expand Down Expand Up @@ -10644,6 +10650,72 @@ public native_register_zombie_class(plugin_id, num_params) {
g_zclass_i++ // Increase registered classes counter
return (g_zclass_i-1); // Return id under which we registered the class
}

// Native: zp_register_zclass_painsnd(classid, const sound[])
public native_register_zclass_painsnd(plugin_id, num_params) {
static classid, sound[64];
classid = get_param(1);
get_string(2, sound, charsmax(sound))
return register_zclass_sounds(0, classid, "PAIN SOUND", g_zclass_real_name, g_zclass_use_painsnd, g_zclass_painsnd_handle, sound)
}

// Native: zp_register_zclass_deathsnd(classid, const sound[])
public native_register_zclass_deathsnd(plugin_id, num_params) {
static classid, sound[64];
classid = get_param(1);
get_string(2, sound, charsmax(sound))
return register_zclass_sounds(0, classid, "DEATH SOUND", g_zclass_real_name, g_zclass_use_deathsnd, g_zclass_deathsnd_handle, sound)
}

// Native: zp_register_zmspecial_deathsnd(classid, const sound[])
public native_register_zmspecial_deathsnd(plugin_id, num_params) {
static classid, sound[64];
classid = get_param(1);
get_string(2, sound, charsmax(sound))
return register_zclass_sounds(1, classid, "DEATH SOUND", g_zm_sp_realname, g_zm_sp_use_deathsnd, g_zm_sp_deathsnd_handle, sound)
}

public register_zclass_sounds(is_sp, classid, key[], Array:realname, Array:enable_array, Array:handle_array, sound[]) {
if(is_sp) {
if(classid < MAX_SPECIALS_ZOMBIES || classid >= g_zm_specials_i) {
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Custom Special class id (%d)", classid)
return false;
}
}
else {
if (classid < 0 || classid >= g_zclass_i) {
log_error(AMX_ERR_NATIVE, "[ZP] Invalid zombie class id (%d)", classid)
return false;
}
}

// Sound alterady enable
if (ArrayGetCell(enable_array, classid))
return true;

engfunc(EngFunc_PrecacheSound, sound);

static Array:ArrSoundTemp
ArrSoundTemp = ArrayGetCell(handle_array, classid)

// No sounds registered
if (ArrSoundTemp == Invalid_Array) {
ArrSoundTemp = ArrayCreate(64, 1)
ArraySetCell(handle_array, classid, ArrSoundTemp)
}
ArrayPushString(ArrSoundTemp, sound)

// Save models to file
static real_name[32]
ArrayGetString(realname, classid, real_name, charsmax(real_name))
if(is_sp)
amx_save_setting_string_arr(ZP_ZOMBIECLASSES_FILE, real_name, key, ArrSoundTemp)
else
amx_save_setting_string_arr(ZP_SPECIAL_CLASSES_FILE, fmt("Z:%s", real_name), key, ArrSoundTemp)

return true;
}

public native_get_extra_item_id(plugin_id, num_params) { // Native: zp_get_extra_item_id
if(!g_pluginenabled) return -1; // ZP Special disabled

Expand Down

0 comments on commit 72b129b

Please sign in to comment.