AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help on Scripting (https://forums.alliedmods.net/showthread.php?t=337354)

mohanad_2022 04-15-2022 13:43

Help on Scripting
 
1 Attachment(s)
hello guys .. i have this sma code for nemesis mod and when i try compile it by the zombieplauge.inc ,, it give me some errors .. so .. i hope someone help me to fix it

PHP Code:

#include <zombieplague>

// Definitions
#define MODEL_MAX_LENGTH 64

#define Task_SetModel 1100

// Enums Colors
enum any:COLORS {
    
RED 0GREENBLUE
};

// Setting file.
new const ZE_SETTING_RESOURCES[] = {"zombie_escape.ini"};

// Default nemesis model.
new const szNemesisModel[][MODEL_MAX_LENGTH] = {
    
"ze_nemesis"
};

// Default nemesis claw.
new const szNemesisClaw[][MODEL_MAX_LENGTH] = {
    
"models/zombie_escape/ze_knife_nemesis.mdl"
};

// Default access flags.
new g_szAccessFlags[] = {"d"};

// Cvars Variables
new g_pCvarHealth,
        
g_pCvarBaseHealth,
        
g_pCvarSpeed,
        
g_pCvarGravity,
        
g_pCvarKnockback,
        
g_pCvarGlow,
        
g_pCvarGlowColors[COLORS],
        
g_pCvarDamage,
        
g_pCvarFrostNade,
        
g_pCvarFireNade;

// Global Variables
new g_iMaxPlayers,
        
g_iTaskIndex[MAX_CLIENTS+1],
        
bool:g_bIsNemesis[MAX_CLIENTS+1],
        
bool:g_bHasChosen;
        
// Dynamic Arrays
new Array:g_szNemesisModel,
        Array:
g_szNemesisClaw;

// Forward called after server activation.
public plugin_init() {
    
// Load plugin
    
register_plugin("[ZE] Class: Nemesis""1.3""z0h1r-LK");
    
    
// Hook Chain
    
RegisterHookChain(RG_CBasePlayer_TakeDamage"TakeDamagePlayer_Post"1);
    
    
// Cvars
    
g_pCvarHealth register_cvar("ze_nemesis_health""10000");
    
g_pCvarBaseHealth register_cvar("ze_nemesis_base_hp""1000");
    
g_pCvarSpeed register_cvar("ze_nemesis_speed""320");
    
g_pCvarGravity register_cvar("ze_nemesis_gravity""500");
    
g_pCvarKnockback register_cvar("ze_nemesis_knockback""160");
    
g_pCvarGlow register_cvar("ze_nemesis_glow""1");
    
g_pCvarGlowColors[RED] = register_cvar("ze_nemesis_glow_r""255");
    
g_pCvarGlowColors[GREEN] = register_cvar("ze_nemesis_glow_g""0");
    
g_pCvarGlowColors[BLUE] = register_cvar("ze_nemesis_glow_b""0");
    
g_pCvarDamage register_cvar("ze_nemesis_damage""2");
    
g_pCvarFrostNade register_cvar("ze_nemesis_frostnade""1");
    
g_pCvarFireNade register_cvar("ze_nemesis_firenade""1");
    
    
// Console commands
    
register_concmd("ze_nemesis""concmd_SetNemesis", -1"<Make player nemesis>");
    
    
// Default Values
    
g_iMaxPlayers get_member_game(m_nMaxPlayers);
}

// Forward allows register natives.
public plugin_natives() {
    
// New natives.
    
register_native("ze_is_user_nemesis""_native_ze_is_user_nemesis"1);
    
register_native("ze_set_user_nemesis""_native_ze_set_user_nemesis"1);
    
register_native("ze_remove_user_nemesis""_native_ze_remove_user_nemesis"1);
}

// Forward allows precaching game files (models, sounds, generic files)
public plugin_precache() {
    
// Initialize arrays
    
g_szNemesisModel ArrayCreate(64);
    
g_szNemesisClaw ArrayCreate(64);
    
    
// Load file path from externel file.
    
amx_load_setting_string_arr(ZE_SETTING_RESOURCES"Player Models""NEMESIS"g_szNemesisModel);
    
amx_load_setting_string_arr(ZE_SETTING_RESOURCES"Weapon Models""V_KNIFE NEMESIS"g_szNemesisClaw);
    
    
// Save default resource's.
    
new iIndex;
    if (
ArraySize(g_szNemesisModel) == 0) {
        for (
iIndex 0iIndex sizeof (szNemesisModel); iIndex++)
            
ArrayPushString(g_szNemesisModelszNemesisModel[iIndex]);

        
// Save model name in external file.
        
amx_save_setting_string_arr(ZE_SETTING_RESOURCES"Player Models""NEMESIS"g_szNemesisModel);
    }
    
    if (
ArraySize(g_szNemesisClaw) == 0) {
        for (
iIndex 0iIndex sizeof (g_szNemesisClaw); iIndex++)
            
ArrayPushString(g_szNemesisClawszNemesisClaw[iIndex]);
            
        
// Save model name in external file.
        
amx_save_setting_string_arr(ZE_SETTING_RESOURCES"Weapon Models""V_KNIFE NEMESIS"g_szNemesisClaw);
    }
    
    
// Precache models.
    
new szModel[64], szPathModel[128];
    for (
iIndex 0iIndex ArraySize(g_szNemesisModel); iIndex++) {
        
// Get model name from dynamic array.
        
ArrayGetString(g_szNemesisModeliIndexszModelcharsmax(szModel));
        
formatex(szPathModelcharsmax(szPathModel), "models/player/%s/%s.mdl"szModelszModel// Get model path.
        
precache_model(szPathModel); // Precache model's.
    
}
    
    for (
iIndex 0iIndex ArraySize(g_szNemesisClaw); iIndex++) {
        
// Get model path from dynamic arrays.
        
ArrayGetString(g_szNemesisClawiIndexszModelcharsmax(szModel));
        
precache_model(szModel); // Precache model's.
    
}
    
    
// Load access flags from external file.
    
if (amx_load_setting_string(ZE_SETTING_RESOURCES"Access Flags""Make Nemesis"g_szAccessFlagscharsmax(g_szAccessFlags)))
        
amx_save_setting_string(ZE_SETTING_RESOURCES"Access Flags""Make Nemesis"g_szAccessFlags);
}

// Function called when execute command in console
public concmd_SetNemesis(iIndex) {
    
// Is don't have access.
    
if (!(get_user_flags(iIndex) & read_flags(g_szAccessFlags))) {
        
console_print(iIndex"%L"LANG_PLAYER"CMD_NOT_ACCESS");
        return;
    }
    
    
// Zombies has chosen.
    
if (!g_bHasChosen) {
        
console_print(iIndex"%L"LANG_PLAYER"ZOMBIE_NOT_CHOSEN");
        return;
    }
    
    
// Get target name.
    
new szName[MAX_NAME_LENGTH], szAdminName[MAX_NAME_LENGTH], iTarget;
    
read_argv(1szNamecharsmax(szName));
    
iTarget cmd_target(iIndexszName, (CMDTARGET_ONLY_ALIVE CMDTARGET_ALLOW_SELF));
    
    
// Is not found.
    
if (!is_user_connected(iTarget)) {
        
console_print(iIndex"%L"LANG_PLAYER"CMD_NOT_FOUND");
        return;
    }
    
    
// Him is already nemesis.
    
if (g_bIsNemesis[iTarget]) {
        
console_print(iIndex"%L"LANG_PLAYER"ALREADY_NEMESIS");
        return;        
    }    
    
    
// Don't make the last human to nemesis.
    
if (ze_get_humans_number() == && !ze_is_user_zombie(iTarget)) {
        
console_print(iIndex"%L"LANG_PLAYER"CMD_LAST_HUMAN");
        return;        
    }    
    
    
// Set client nemesis.
    
Set_User_Nemesis(iTarget);
    
    
// Get admin name.
    
get_user_name(iIndexszAdminNamecharsmax(szAdminName));
    
    
// Get target name.
    
get_user_name(iTargetszNamecharsmax(szName));
    
    
// Sent message in chat.
    
ze_colored_print(0"%L"LANG_PLAYER"CHAT_MAKE_NEMESIS"szAdminNameszName);
}

// Forward called when zombies chosen.
public ze_zombie_appear() {
    
// Zombies has chosen.
    
g_bHasChosen true;
}

// Forward called before frostnade freeze zombie.
public ze_frost_pre(iVictim) {
    
// Block freezing the nemesis.
    
if (get_pcvar_num(g_pCvarFrostNade) && g_bIsNemesis[iVictim])
        return 
PLUGIN_HANDLED;
    return 
PLUGIN_CONTINUE;
}

// Forward called before firenade burn zombie.
public ze_fire_pre(iVictim) {
    
// Block burning the nemesis.
    
if (get_pcvar_num(g_pCvarFireNade) && g_bIsNemesis[iVictim])
        return 
PLUGIN_HANDLED;
    return 
PLUGIN_CONTINUE;
}

// Forward called every round.
public ze_game_started_pre() {
    
// Remove tasks (Set model).
    
new iIndex;
    for (
iIndex 1iIndex <= g_iMaxPlayersiIndex++)
        
remove_task(g_iTaskIndex[iIndex]); // Remove all tasks (Set model).
}

// Forward called when set human.
public ze_user_humanized(iIndex) {
    
// Player is a nemesis
    
if (g_bIsNemesis[iIndex])
        
Remove_User_Nemesis(iIndex)
}

// Forward called before infect player.
public ze_user_infected_pre(iVictimiInfectoriDamage) {
    
// Is not a nemesis.
    
if (!g_bIsNemesis[iInfector])
        return 
PLUGIN_CONTINUE;
        
    
// Damage Human.
    
if (get_pcvar_float(g_pCvarDamage) > 0)    
        
rg_multidmg_add(iInfectoriVictimfloat(iDamage) * get_pcvar_float(g_pCvarDamage), DMG_GENERIC);
    else 
        
rg_multidmg_add(iInfectoriVictimfloat(iDamage), DMG_GENERIC);
    
    
// Block infect human.
    
return PLUGIN_HANDLED;
}

// Hook called when player damaged.
public TakeDamagePlayer_Post(iVictimiInflectoriAttackerFloat:flDamagebitsDamageType) {
    
// Invalid player.
    
if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
        return;
        
    
// Attacker is not a nemesis.
    
if (!g_bIsNemesis[iAttacker])
        return;
        
    
// Remove Pain Shock.
    
set_member(iVictimm_flVelocityModifier1.0);
}

public 
Set_User_Nemesis(iIndex) {
    
// Set him zombie, If not.
    
if (!ze_is_user_zombie(iIndex))
        
ze_set_user_zombie(iIndex);
    
    
// Is already Nemesis.
    
if (!g_bIsNemesis[iIndex])
        
g_bIsNemesis[iIndex] = true;
    
    
// Set nemesis a some attributes.
    
if (get_pcvar_num(g_pCvarHealth) > 0) {
        
set_entvar(iIndexvar_healthget_pcvar_float(g_pCvarHealth));
    } else {
        if (
get_pcvar_num(g_pCvarBaseHealth) > && GetAllAlivePlayersNum() > 5) {
            
set_entvar(iIndexvar_health, (get_pcvar_float(g_pCvarBaseHealth) * GetAllAlivePlayersNum()));
        } else {
            
set_entvar(iIndexvar_healthget_pcvar_float(g_pCvarHealth));
        }
    }
    
    if (
get_pcvar_num(g_pCvarSpeed) > 0ze_set_zombie_speed(iIndexget_pcvar_num(g_pCvarSpeed)); // Set nemesis custom speed.
    
if (get_pcvar_num(g_pCvarGravity) > 0ze_set_user_gravity(iIndexget_pcvar_num(g_pCvarGravity)); // Set nemesis custom gravity.
    
if (get_pcvar_num(g_pCvarKnockback) > 0ze_set_user_knockback(iIndexget_pcvar_float(g_pCvarKnockback)); // Set nemesis custom knockback.
    
    // Set nemesis rendering "Glow Shell"
    
if (get_pcvar_num(g_pCvarGlow) > 0)
        
Set_Rendering(iIndexkRenderFxGlowShellget_pcvar_num(g_pCvarGlowColors[RED]), get_pcvar_num(g_pCvarGlowColors[GREEN]), get_pcvar_num(g_pCvarGlowColors[BLUE]), kRenderNormal20);

    
/* 
    * New Task, Delay before set nemesis model and claw nemesis.
    * When ze_resource.amxx set zombies model, After 0.1s remove old zombie model and set nemesis model.
    */
    
g_iTaskIndex[iIndex] = iIndex+Task_SetModel;
    
set_task(0.1"Set_Nemesis_Model"g_iTaskIndex[iIndex]);
}

public 
Set_Nemesis_Model(iTask) {
    new 
szModel[64], szClawModel[64], iIndex;
    
    
// Change task id to client index.
    
iIndex iTask-Task_SetModel;

    
// Get model name and claw model path from dynamic arrays
    
ArrayGetString(g_szNemesisModelrandom_num(0ArraySize(g_szNemesisModel) - 1), szModelcharsmax(szModel));
    
ArrayGetString(g_szNemesisClawrandom_num(0ArraySize(g_szNemesisClaw) - 1), szClawModelcharsmax(szClawModel));
    
    
// Set a nemesis model.
    
rg_set_user_model(iIndexszModel);
    
    
// Set a nemesis claw.
    
cs_set_player_view_model(iIndexCSW_KNIFEszClawModel);
    
cs_set_player_weap_model(iIndexCSW_KNIFE"");
}

public 
Remove_User_Nemesis(iIndex) {
    
// Is a Nemesis.
    
if (g_bIsNemesis[iIndex])
        
g_bIsNemesis[iIndex] = false;
        
    
// Remove nemesis.
    
ze_reset_zombie_speed(iIndex// Reset speed to zombie speed.
    
ze_reset_user_gravity(iIndex// Reset gravity to zombie gravity.
    
ze_reset_user_knockback(iIndex// Reset knockback to default knockback.
    
Set_Rendering(iIndex// Remove rendering (Glow Shell).
}

// Forward called when round end.
public ze_roundend(iWinTeam) {
    
g_bHasChosen false;
}

/**
 * Functions of natives
 */ 
public _native_ze_is_user_nemesis(const id) {
    
// Return true if client is nemesis, false otherwise.
    
return g_bIsNemesis[id];
}

public 
_native_ze_set_user_nemesis(const id) {
    
// Is not found.
    
if (!is_user_connected(id)) {
        
log_error(AMX_ERR_NATIVE"[ZE] Invalid player (%d)"id);
        return 
0;
    }
    
    
// Set client nemesis.
    
Set_User_Nemesis(id);
    return 
1;
}

public 
_native_ze_remove_user_nemesis(const id) {
    
// Is not found.
    
if (!is_user_connected(id)) {
        
log_error(AMX_ERR_NATIVE"[ZE] Invalid player (%d)"id);
        return 
0;
    }
    
    
// Set client nemesis.
    
Remove_User_Nemesis(id);
    return 
1;



i will attach the zombieplague.inc which i used

OciXCrom 04-15-2022 14:32

Re: Help on Scripting
 
That's because you deleted the #include lines.

mohanad_2022 04-15-2022 15:12

Re: Help on Scripting
 
Quote:

Originally Posted by OciXCrom (Post 2776915)
That's because you deleted the #include lines.

could you fix it sir ?
plz

hellmonja 04-15-2022 15:38

Re: Help on Scripting
 
Quote:

Originally Posted by mohanad_2022 (Post 2776920)
could you fix it sir ?
plz

You posted in the wrong section then. Scripting Help is for helping you to script, not have someone do the work for you. I think that is for Plugin Requests.

What OciXCrom suggest is very easy really. An include is the very first line of your code. For a plugin of this size there's usually several of them, including amxmodx. What you need is to type them in again. You can get clues from other plugins on which includes are there...


All times are GMT -4. The time now is 21:19.

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