AlliedModders

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

hhhhhhhh @ WCS 10-05-2020 14:32

compiler error
 
hello every one , i try to compile this plugin , but this give me this :

https://imgur.com/RJVQcuV.png

can you help me to find to solve it ?

Code:


#include <amxmodx>
#include <hamsandwich>
#include <csdm>


#define IsPlayer(%1)                                (1 <= (%1) <= g_iMaxPlayers)

const HideWeapon_Flags = 1        // "HideWeapon" msg argument

new const g_szWeaponList[][] =
{
        "weapon_m4a1",
        "weapon_usp",
        "weapon_famas",
        "weapon_glock18"
}

new HamHook:g_hSecondaryAttack[sizeof(g_szWeaponList)], HamHook:g_hAddToPlayer[sizeof(g_szWeaponList)]

new g_bWeaponState[MAX_CLIENTS + 1][CSW_P90 + 1]
new g_iMaxPlayers

new bool:g_bWeaponStateRemember = true, g_bitHideHudFlags, g_iRefillClip = 1


public plugin_init()
{
        register_plugin("CSDM Misc", CSDM_VERSION_STRING, "wopox1337\Vaqtincha")

        for(new i = 0; i < sizeof(g_szWeaponList); i++)
        {
                DisableHamForward(g_hAddToPlayer[i] = RegisterHam(Ham_Item_AddToPlayer, g_szWeaponList[i], "CBasePlayerItem_AddToPlayer", .Post = true))
                DisableHamForward(g_hSecondaryAttack[i] = RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponList[i], "CBasePlayerItem_SecAttack", .Post = true))
        }

        g_iMaxPlayers = get_maxplayers()
}

public plugin_cfg()
{
        CheckForwards()
}

public client_putinserver(pPlayer)
{
        g_bWeaponState[pPlayer][CSW_M4A1] = g_bWeaponState[pPlayer][CSW_USP] = g_bWeaponState[pPlayer][CSW_FAMAS] = g_bWeaponState[pPlayer][CSW_GLOCK18] = 0;
}


public CSDM_Initialized(const szVersion[])
{
        if(!szVersion[0])
                pause("ad")
}

public CSDM_ConfigurationLoad(const ReadTypes:iReadAction)
{
        CSDM_RegisterConfig("misc", "ReadCfg")
}

public CSDM_PlayerKilled(const pVictim, const pKiller, const HitBoxGroup:iLastHitGroup)
{
        if(!g_iRefillClip || !pKiller)
                return

        if(pVictim != pKiller && is_user_alive(pKiller))
        {
                switch(g_iRefillClip)
                {
                        case 1:
                        {
                                new pActiveWeapon = get_member(pKiller, m_pActiveItem)
                                if(pActiveWeapon > 0) {
                                        rg_instant_reload_weapons(pKiller, pActiveWeapon)
                                }
                        }
                        case 2:        rg_instant_reload_weapons(pKiller) // all
                }
        }
}

public CBasePlayerItem_SecAttack(const pWeapon)
{
        if(pWeapon <= 0)
                return HAM_IGNORED

        new pPlayer = get_member(pWeapon, m_pPlayer)
        if(IsPlayer(pPlayer)) {
                g_bWeaponState[pPlayer][get_member(pWeapon, m_iId)] = get_member(pWeapon, m_Weapon_iWeaponState)
        }

        return HAM_IGNORED
}

public CBasePlayerItem_AddToPlayer(const pWeapon, const pPlayer)
{
        if(pWeapon > 0 && IsPlayer(pPlayer)) {
                set_member(pWeapon, m_Weapon_iWeaponState, g_bWeaponState[pPlayer][get_member(pWeapon, m_iId)])
        }

        return HAM_IGNORED
}

public Message_HideWeapon(const iMsgId, const iMsgDest, const iMsgEntity)
{
        if(g_bitHideHudFlags) {
                set_msg_arg_int(HideWeapon_Flags, ARG_BYTE, get_msg_arg_int(HideWeapon_Flags) | g_bitHideHudFlags)
        }
}

public ReadCfg(const szLineData[], const iSectionID)
{
        new szKey[MAX_KEY_LEN], szValue[MAX_VALUE_LEN], szSign[2]
        if(!ParseConfigKey(szLineData, szKey, szSign, szValue))
                return

        if(equali(szKey, "weaponstate_remember"))
        {
                g_bWeaponStateRemember = bool:(str_to_num(szValue))
        }
        else if(equali(szKey, "refill_clip_weapons"))
        {
                g_iRefillClip = clamp(str_to_num(szValue), 0, 2)
        }
        else if(equali(szKey, "hide_hud_flags"))
        {
                if(ContainFlag(szValue, "c"))
                        g_bitHideHudFlags |= HIDEHUD_CROSSHAIR
                if(ContainFlag(szValue, "f"))
                        g_bitHideHudFlags |= HIDEHUD_FLASHLIGHT
                if(ContainFlag(szValue, "m"))
                        g_bitHideHudFlags |= HIDEHUD_MONEY
                if(ContainFlag(szValue, "h"))
                        g_bitHideHudFlags |= HIDEHUD_HEALTH
                if(ContainFlag(szValue, "t"))
                        g_bitHideHudFlags |= HIDEHUD_TIMER
        }
}

CheckForwards()
{
        static iMsgIdHideWeapon, iMsgHookHideWeapon
        if(!iMsgIdHideWeapon) {
                iMsgIdHideWeapon = get_user_msgid("HideWeapon")
        }

        for(new i = 0; i < sizeof(g_szWeaponList); i++)
        {
                if(g_bWeaponStateRemember)
                {
                        EnableHamForward(g_hAddToPlayer[i])
                        EnableHamForward(g_hSecondaryAttack[i])
                }
                else
                {
                        DisableHamForward(g_hAddToPlayer[i])
                        DisableHamForward(g_hSecondaryAttack[i])
                }       
        }

        if(g_bitHideHudFlags && !iMsgHookHideWeapon)
        {
                iMsgHookHideWeapon = register_message(iMsgIdHideWeapon, "Message_HideWeapon")
        }
        else if(!g_bitHideHudFlags && iMsgHookHideWeapon)
        {
                unregister_message(iMsgIdHideWeapon, iMsgHookHideWeapon)
                iMsgHookHideWeapon = 0
        }
}


and this too



Code:

#include <amxmodx>
#include <csdm>


#define IsPlayer(%1)                                (1 <= (%1) <= g_iMaxPlayers)
#define PlayerTask(%1)                                (%1 + PROTECTION_TASK_ID)
#define GetPlayerByTaskID(%1)                (%1 - PROTECTION_TASK_ID)

const PROTECTION_TASK_ID = 216897

enum color_e { Float:R, Float:G, Float:B }

enum
{
        STATUSICON_HIDE,
        STATUSICON_SHOW,
        STATUSICON_FLASH
}

new bool:g_bIsProtected[MAX_CLIENTS + 1]
new g_iMaxPlayers

new g_szSpriteName[18] = "suithelmet_full" // max lenght = 16
new Float:g_flRenderAlpha = 10.0, bool:g_bBlockDamage = true, Float: g_fImmunityTime;
new Float:g_flTeamColors[TeamName][color_e] =
{
        {0.0, 0.0, 0.0},
        {235.0, 0.0, 0.0}, // TEAM_TERRORIST
        {0.0, 0.0, 235.0}, // TEAM_CT
        {0.0, 0.0, 0.0}
}

public OnConfigsExecuted()
{
        set_cvar_float("mp_respawn_immunitytime", g_fImmunityTime)
}

public plugin_init()
{
        register_plugin("CSDM Protection", CSDM_VERSION_STRING, "wopox1337\Vaqtincha")

        if(g_fImmunityTime > 0.0) {
                if(g_bBlockDamage)
                        RegisterHookChain(RG_CSGameRules_FPlayerCanTakeDamage, "CSGameRules_FPlayerCanTakeDmg", .post = false)

                RegisterHookChain(RG_CBasePlayer_SetSpawnProtection, "CBasePlayer_SetSpawnProtection", .post = true)
                RegisterHookChain(RG_CBasePlayer_RemoveSpawnProtection, "CBasePlayer_RemoveSpawnProtection", .post = true)

        }
       
        g_iMaxPlayers = get_maxplayers()
}

public CSDM_Initialized(const szVersion[])
{
        if(!szVersion[0])
                pause("ad")
}

public CSDM_ConfigurationLoad(const ReadTypes:iReadAction)
{
        CSDM_RegisterConfig("protection", "ReadCfg")
}

public CBasePlayer_SetSpawnProtection(const pPlayer, Float: time)
{
        SetEffects(pPlayer, time)
}

public CBasePlayer_RemoveSpawnProtection(const pPlayer)
{
        RemoveEffects(pPlayer)
}

public CSGameRules_FPlayerCanTakeDmg(const pPlayer, const pAttacker)
{
        if(pPlayer == pAttacker || !IsPlayer(pAttacker))
                return HC_CONTINUE

        if(g_bIsProtected[pAttacker]) // protected attacker can't take damage
        {
                SetHookChainReturn(ATYPE_INTEGER, false)
                return HC_SUPERCEDE
        }

        return HC_CONTINUE
}

public ReadCfg(const szLineData[], const iSectionID)
{
        new szKey[MAX_KEY_LEN], szValue[MAX_VALUE_LEN], szSign[2]
        if(!ParseConfigKey(szLineData, szKey, szSign, szValue))
                return

        if(equali(szKey, "protection_time"))
        {
                g_fImmunityTime = str_to_float(szValue)
        }
        else if(equali(szKey, "block_damage"))
        {
                g_bBlockDamage = bool:(str_to_num(szValue))
        }
        else if(equali(szKey, "sprite_name"))
        {
                copy(g_szSpriteName, charsmax(g_szSpriteName), szValue)
                strtolower(g_szSpriteName)
        }
        else if(equali(szKey, "render_color_", 13))
        {
                new szRed[4], szGreen[4], szBlue[4]
                strtolower(szKey) // render_color_C or render_color_c
                new TeamName:iTeam = szKey[13] == 'c' ? TEAM_CT : szKey[13] == 't' ? TEAM_TERRORIST : TEAM_UNASSIGNED // invalid team

                if(parse(szValue, szRed, charsmax(szRed), szGreen, charsmax(szGreen), szBlue, charsmax(szBlue)) == 3)
                {
                        g_flTeamColors[iTeam][R] = floatclamp(str_to_float(szRed), 1.0, 255.0)
                        g_flTeamColors[iTeam][G] = floatclamp(str_to_float(szGreen), 1.0, 255.0)
                        g_flTeamColors[iTeam][B] = floatclamp(str_to_float(szBlue), 1.0, 255.0)       
                }
                else if(equali(szValue, "random"))
                {
                        g_flTeamColors[iTeam][R] = g_flTeamColors[iTeam][G] = g_flTeamColors[iTeam][B] = 0.0
                }
        }
        else if(equali(szKey, "render_alpha"))
        {
                g_flRenderAlpha = str_to_float(szValue)
        }
}

SetEffects(const pPlayer, Float: time)
{
// https://github.com/s1lentq/ReGameDLL_CS/blob/bc2c3176e46e2c32ebc0110e7df879ea7ddbfafa/regamedll/dlls/player.cpp#L9532
        set_entvar(pPlayer, var_rendermode, kRenderFxNone)

        new TeamName:iTeam = get_member(pPlayer, m_iTeam)
        if(!g_flTeamColors[iTeam][R] && !g_flTeamColors[iTeam][G] && !g_flTeamColors[iTeam][B])
        {
                new Float:flColor[color_e]
                flColor[R] = random_float(1.0, 255.0)
                flColor[G] = random_float(1.0, 255.0)
                flColor[B] = random_float(1.0, 255.0)

                rg_set_rendering(pPlayer, kRenderFxGlowShell, flColor, g_flRenderAlpha)
        }
        else rg_set_rendering(pPlayer, kRenderFxGlowShell, g_flTeamColors[iTeam], g_flRenderAlpha)

        if(g_szSpriteName[0] && time >= 1.5) {
                SendStatusIcon(pPlayer, STATUSICON_FLASH)
        }
}

RemoveEffects(const pPlayer)
{
        if(is_user_connected(pPlayer))
        {
                rg_set_rendering(pPlayer)

                if(g_szSpriteName[0]) {
                        SendStatusIcon(pPlayer)
                }
        }
}

stock SendStatusIcon(const pPlayer, iStatus = STATUSICON_HIDE, red = 0, green = 160, blue = 0)
{
        static iMsgIdStatusIcon
        if(iMsgIdStatusIcon || (iMsgIdStatusIcon = get_user_msgid("StatusIcon")))
        {
                message_begin(MSG_ONE_UNRELIABLE, iMsgIdStatusIcon, .player = pPlayer)
                write_byte(iStatus)                        // status: 0 - off, 1 - on, 2 - flash
                write_string(g_szSpriteName)       
                write_byte(red)
                write_byte(green)
                write_byte(blue)
                message_end()
        }
}


OciXCrom 10-05-2020 17:20

Re: compiler error
 
If that's all it says, the problem is not in the code, it's in your compiler's permissions. Make sure the .sma file and compiler are on the same disk or try moving them outisde of C.

hhhhhhhh @ WCS 10-05-2020 17:36

Re: compiler error
 
i moved it to D and still the same

https://imgur.com/h5dIM5h.png

OciXCrom 10-05-2020 19:02

Re: compiler error
 
It's not the same, is it? Why didn't you show the full error the first time?
The error itself is telling you what to do. You're missing "reapi.inc" in "scripting/include".

hhhhhhhh @ WCS 10-06-2020 07:16

Re: compiler error
 
yes yes, you are right , i added it and everything is fine , thank you !


All times are GMT -4. The time now is 13:53.

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