EventScripts Forums
Mattie's EventScripts and Source Forums
Mattie recommends...
Premier Sponsor:Platinum Sponsor:
 
Script Categories
16000 (15) abilities (15) addon (71) addons (17) admin (348) admins (23) advert (27) adverts (26) afk (17) alerts (12) ammo (25) anti (20) armor (11) auth (16) automatic (15) awp (29) ban (24) ba_jail (34) bhop (45) block (27) bomb (47) bonus (25) boost (21) bot (35) bot-management (20) bots (24) bullet (13) bunnyhop (18) Buy (27) buymenu (13) c4 (12) cash (76) Change (14) chat (75) cheat (15) clan (17) classes (24) color (30) colors (20) command (23) commands (20) config (28) configurable (11) connect (54) counter (11) Counter-Strike-Source (18) CS:S (20) css (3313) custom (13) Damage (48) database (14) dead (19) Deagle (11) death (19) deathmatch (79) deathrun (17) deutsch (13) dice (11) disconnect (24) Dissolve (12) dm (24) dod:s (11) dods (494) download (12) easy (26) effect (14) effects (125) English (16) entity (24) est (12) es_tools (14) Eventscript (12) exploit (11) flashbang (27) français (104) french (36) fun (312) funny (18) Gabeee (11) game (12) gamemode (11) gameplay (175) German (11) give (20) gravity (15) grenade (28) grenades (32) gun (15) GunGame (31) GunGame5 (11) guns (20) Hack (16) headshot (37) health (70) hegrenade (15) help (11) hit (13) hl2dm (432) HP (25) hudhint (11) hungarian (22) info (52) information (17) invisible (11) IP (13) jail (79) jailbreak (14) join (44) jump (19) kick (25) kill (50) kills (23) knife (65) leveling (38) LnD (14) lol (11) magyar (32) management (14) manager (11) mani (16) map (31) map-management (26) maps (17) match (21) Memphis-84 (13) menu (139) message (30) messaging (52) minecraft (12) mod (121) model (18) models (32) modye (16) money (50) motd (13) music (32) mute (20) nades (20) name (15) new (13) noblock (53) orangebox (23) player (46) player-management (31) player-tracking (28) popup (70) prop (13) propmenu (14) props (34) protect (11) protection (31) punish (11) punishment (51) python (79) quake (32) QuakeSounds (12) race (13) races (20) radio (29) random (47) rank (41) rates (15) rcon (12) realism (22) Regeln (22) respawn (67) restrict (40) round (26) rpg (32) rules (60) say (16) score (15) scout (29) Script (25) script-helper (25) scriptpack (33) sdk (171) server (60) server-tools (42) shop (12) showdamage (19) silly (31) simple (31) skin (17) skins (34) slay (13) soccer (14) sound (63) sounds (106) source (13) spanish (18) spawn (81) speed (25) statistics (13) stats (55) status (15) Steam (11) STEAMID (29) Superhero (15) surf (41) Team (29) team-balance (14) teleport (16) text (17) TF2 (142) time (22) timer (15) tools (15) tracers (19) triggers (11) uedi (17) uses_auth (18) vip (23) vote (39) voting (22) war (25) Warcraft (12) warcraft-source (20) wc3 (14) wcs (47) wcs:Python (32) weapon (87) weapons (116) web (16) welcome (12) wuerfeln (11) zm (26) zombie (99) zombiemod (55) zombies (12)
Script Authors
*XYZ*SaYnt (12) .:MiB:. (20) .:modye:. (14) .eMko* (6) 101satoon101 (12) 3R10N (24) 4u571n91 (5) 7355608 (9) Absolute (9) Ace Rimmer (40) adminc (5) Adz (8) AgathaKnuppelkuh (8) aidden (8) ajax (5) ak_47 (6) Al3c Tr3v3lyan (6) allstareng (5) ashbash1987 (9) ATAMAH (7) Ayuto (5) aznone (5) B00M (5) BackRaw (41) BFH_RedBull (8) bigfabi (8) Bioko (10) blackshoxx (9) Blade (10) bladesback (13) bobdole (11) bodzsar1 (8) bonbon (36) Brainsucker (32) cagemonkey (8) capo azzlack (7) captain master (6) carbon-14 (10) CaskioUTF (5) cbirou (15) CbRRR (16) ChaCaLz2psy4 (5) CharlesT (5) Chrisber (5) chrismrulz (10) Chun (6) cladiron (10) clipz934 (8) Colster (21) Cookieman8 (7) CrAzD (6) craziest (11) dani12356 (12) DanielB (19) Darkness123 (8) Dave (9) dbozan99 (7) deathx9 (5) Deathyy (16) dhack (17) Di[M]aN (12) DJ Fire-Black prod (8) DoCky (31) Don (15) dordtcore (9) DragonFreddo (8) Drassil (5) dretax14 (11) Einlanzers (47) EmbouT (10) emilplov (7) Errant (10) Eun (6) Fantole (10) FMIS (5) Franc1sco (17) freddukes (18) Frequency (6) Fugi91 (6) Fulmine (5) G4ME (5) GAMEREN2 (8) german9114 (13) GODJonez (40) GoodfellaDeal (5) Hansi (6) Hisoka (6) HitThePipe (7) HOLLDIDAY (24) Icetouch (6) ichthys (25) Im the new guy (14) iNexus (13) infamous1 (9) isivisi (13) ispaine (7) Jackmaster (9) Jeff91 (45) JoeyT2006 (30) Juba_PornBorn (12) jxl180 (11) KDBFame (6) L'In20Cible (11) L.P.H (8) Largo Usagi (10) LnD (14) Lobe (11) loKkdoKk (8) lolo-le-haricot (7) LosNir (5) Lumpi@Work (9) M4rc3L-XCN (7) macshot (7) magyar-oneill (9) Matth (7) Mattie (21) mave1993 (5) MBchrono (15) McFly (20) Medda (5) Memphis-84 (15) Messiah93 (19) Mickyy (5) micmacx (6) Mitchell (5) Mixer57 (5) modye (6) Monster_Bitch1 (9) Mordavolt (7) motomoto (10) MrScriptaz (6) mryoung (6) MyTechZone.de (8) Nicolous (23) ojii (31) oliVier (10) Omega68 (6) Omega_K2 (11) Owned|Myself (8) P3N (7) pand3mic (6) parsimba (5) Pascal257 (9) PatPeter (7) PDrop (10) Phaedrus (18) PhantOm Fury (7) phoenix131 (9) pinkyyy -.- (5) pitbull0993 (7) PixelGamer (7) randomknifer (9) Raptor150 (31) Ratzee (6) ReaCtioN2oo9 (6) RedCliff (5) Rennnyyy (17) revolutionfighters (8) RideGuy (12) Rio (9) Roeliekt (6) roof (16) runamagic (13) Ryezin (5) sandking220 (6) Sarcasm_Poisoning (10) saRs| Johnny-5 (13) Schubaal (10) sea212 (5) sega74rus (15) sgt.angel (6) Shad0w (11) ShoTaXx# (7) sicilia (7) sicman_adrian (22) skillz92 (7) sn4k3 (18) Snake12 (7) snake38 (10) sonicsight (7) SpeedFreak (9) spoonman184 (10) stabby (22) stas (27) Stirni (6) stonedegg (7) Strontium Dog (30) SumGuy14 (25) SuperDave (49) surfteam (5) TaCo (5) TanaToS (17) Tealk (6) teowow (16) TheCheeTaH (27) TheDonFather (5) theresthatguy (6) Tiny Tod (7) tooshkan4uk (8) Totyahun (9) uedi (38) ultimatebuster (6) Undead (25) usernamesaretaken (15) wanted241 (9) Warren (13) westham (6) WhiteAvenger (7) Wonder (14) Wundermaxe (5) X-Mania (5) XE_ManUp (14) xfalcon61 (5) zSweetXz (5) ZZMatty (6) [Cs]Lord_Inferno2 (11) [DAP]Kickbutt (5) [NATO]Hunter (28) ||Wolf|| (10)
Search

Post new topic Reply to topic
Author Message
User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2012-04-25, 1:18 pm 
   Post subject: [Metamod Source 1.8.7] coding question [half-SOLVED]

Hi,

I'm currently trying to compile a little plugin off of the NativeTools (MetaMod version) sources, just to learn it. I fixed some errors, but there are still two to fix:

Code:
ecs.cpp: In member function âvirtual bool CECS::Unload(char*, size_t)â:
ecs.cpp:120: error: âpECSâ was not declared in this scope
ecs.cpp: In member function âvirtual void CECS::OnVSPListening(IServerPluginCallbacks*)â:
ecs.cpp:251: error: âpECSâ was not declared in this scope
make[1]: *** [Release.orangeboxvalve/ecs.o] Error 1
make[1]: Leaving directory `/home/srcds/plugin/dev/project'
make: *** [all] Error 2


** don't ask me where those "â" come from, guess that's Putty (SSH tool)..., yes, I'm compiling on my linux server.
--> it's about those "ECS" values in HOOK_ADD and HOOK_REMOVE

I've copied the macros and much more out of NativeTools, so it looks - basically - the same:

ecs.h
CPP:
    /*
     * My first Plugin!
     */

    #ifndef _CECS_H_
    #define _CECS_H_

    #define ECS_VERSION "1.0"

    /* INCLUDES */

    #include <ISmmAPI.h>
    #include <vector>
    #include <map>

    using namespace std;

    /* MACROS */

    /* Hooks */

    #define HOOK_ADD(interfacename, functionname, interfaceinstance, hooktarget, post) \
            SH_ADD_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_REMOVE(interfacename, functionname, interfaceinstance, hooktarget, post) \
            SH_REMOVE_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_ADD_NAME(interfacename, functionname, interfaceinstance, hooktarget, hookfunctionname, post) \
            SH_ADD_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: hookfunctionname), post);

    #define HOOK_REMOVE_NAME(interfacename, functionname, interfaceinstance, hooktarget, hookfunctionname, post) \
            SH_REMOVE_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: hookfunctionname), post);

    #define HOOK_VFUNC_ADD(functionname, interfaceinstance, hooktarget, post) \
            SH_ADD_MANUALHOOK(NT_##hooktarget##_##functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_VFUNC_REMOVE(functionname, interfaceinstance, hooktarget, post) \
            SH_REMOVE_MANUALHOOK(NT_##hooktarget##_##functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_VFUNC_REFRESH(functionname, hooktarget, vfuncoffset) \
            SH_MANUALHOOK_RECONFIGURE(NT_##hooktarget##_##functionname, vfuncoffset, 0, 0);

    /* IFACE */

    #define IFACE_INIT(variable, classname) \
            classname *p##variable = NULL;

    #define IFACE_CHECK(type, variable, classname) \
            if (!p##variable) \
            { \
                    Msg("[NativeTools] ERROR: ("type"-)Interface '"#classname"' failed, aborting...\n"); \
                    return false; \
            }

    #define IFACE_SERVER(variable, classname, interfaceversion) \
            GET_V_IFACE_ANY(GetServerFactory, p##variable, classname, interfaceversion); \
            IFACE_CHECK("Server", variable, classname);

    #define IFACE_SERVER_CUR(variable, classname, interfaceversion) \
            GET_V_IFACE_CURRENT(GetServerFactory, p##variable, classname, interfaceversion); \
            IFACE_CHECK("Server", variable, classname);

    #define IFACE_ENGINE(variable, classname, interfaceversion) \
            GET_V_IFACE_ANY(GetEngineFactory, p##variable, classname, interfaceversion); \
            IFACE_CHECK("Engine", variable, classname);

    #define IFACE_ENGINE_CUR(variable, classname, interfaceversion) \
            GET_V_IFACE_CURRENT(GetEngineFactory, p##variable, classname, interfaceversion); \
            IFACE_CHECK("Engine", variable, classname);

    #define IFACE_FILESYS(variable, classname, interfaceversion) \
            GET_V_IFACE_ANY(GetFileSystemFactory, p##variable, classname, interfaceversion); \
            IFACE_CHECK("FileSystem", variable, classname);

    #define IFACE_FILESYS_CUR(variable, classname, interfaceversion) \
            GET_V_IFACE_CURRENT(GetFileSystemFactory, p##variable, classname, interfaceversion); \
            IFACE_CHECK("FileSystem", variable, classname);


    /* Start Code */

    class CECS : public ISmmPlugin, public IMetamodListener
    {
    private:
        int iClientCommandIndex;

    public:
        CECS();
        ~CECS();

        bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
        bool Unload(char *error, size_t maxlen);
        void AllPluginsLoaded();
        bool LevelInit(const char *pMapName, const char *pMapEntities, const char *pOldLevel, const char *pLandmarkName, bool loadGame, bool background);
        void LevelShutdown();
        void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
        bool ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
        void ClientPutInServer(edict_t *pEntity, char const *playername);
        void ClientActive(edict_t *pEntity, bool bLoadGame);
        void ClientDisconnect(edict_t *pEntity);
        void ClientCommand(edict_t *pEntity, const CCommand &args);
        void ClientSettingsChanged(edict_t *pEdict);
        void SetCommandClient(int index);
        void GameFrame(bool simulating);
        void OnVSPListening(IServerPluginCallbacks *iface);
        void OnUnlinkConCommandBase(PluginId id, ConCommandBase *base);

    public:
        const char *GetAuthor();
        const char *GetName();
        const char *GetDescription();
        const char *GetURL();
        const char *GetLicense();
        const char *GetVersion();
        const char *GetDate();
        const char *GetLogTag();

    public:
        int GetClientCommandIndex();
    };

    void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);

    extern CECS *g_ECS;

    PLUGIN_GLOBALVARS();

    #endif // _MYPLUGIN_H_


ecs.cpp
CPP:
    /*
     * My first Plugin!
     */

    #include <stdio.h>

    #include "ecs.h"

    CECS *g_ECS = new CECS;

    IServerGameDLL *pServer = NULL;
    IServerGameClients *pClients = NULL;
    IServerGameEnts *pEnts = NULL;
    IServerPluginHelpers *pHelpers = NULL;
    IServerPluginCallbacks *pCallbacks = NULL;
    IVEngineServer *pEngine = NULL;
    ICvar *pCvar = NULL;
    ISpatialPartition *pPartition = NULL;
    IVModelInfo *pModelInfo = NULL;
    CGlobalVars *pGlobals = NULL;

    /*IPlayerInfoManager *pPlayerInfo = NULL;
    IEngineSound *pEngineSound = NULL;
    IEngineTrace *pEngineTrace = NULL;
    IBotManager *pBotManager = NULL;
    IGameEventManager2 *pEventManager = NULL;
    IUniformRandomStream *pRandom = NULL;
    IVoiceServer *pVoiceServer = NULL;
    IFileSystem *pFileSystem = NULL;
    INetworkStringTableContainer *pStringTable = NULL;
    IStaticPropMgrServer *pStaticProp = NULL;
    IDataCache *pDataCache = NULL;
    IEffects *pEffects = NULL;
    ISoundEmitterSystemBase *pSoundEmitter = NULL;
    IGameMovement *pGameMovement = NULL;
    ITempEntsSystem *pTempEnts = NULL;
    CGameRules *pGameRules = NULL;*/

    // Base Accessor

    class BaseAccessor : public IConCommandBaseAccessor
    {
        bool RegisterConCommandBase(ConCommandBase *pCommandBase)
        {
            return META_REGCVAR(pCommandBase);
        }
    } gBaseAccessor;

    // Event registration

    SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, char const*, char const*, char const*, char const*, bool, bool);
    SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, 0);
    SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t*, int, int);
    SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t*, const char*, const char*, char*, int);
    SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t*, char const*);
    SH_DECL_HOOK2_void(IServerGameClients, ClientActive, SH_NOATTRIB, 0, edict_t*, bool);
    SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t*);
    SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t*, const CCommand &);
    SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t*);
    SH_DECL_HOOK1_void(IServerGameClients, SetCommandClient, SH_NOATTRIB, 0, int);
    SH_DECL_HOOK1_void(IServerGameDLL, GameFrame, SH_NOATTRIB, 0, bool);

    PLUGIN_EXPOSE(CECS, g_ECS);

    // Method definition

    CECS::CECS() : iClientCommandIndex(0)
    {
    }

    bool CECS::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
    {
        PLUGIN_SAVEVARS();

        IFACE_SERVER(Server, IServerGameDLL, /*INTERFACEVERSION_SERVERGAMEDLL*/"ServerGameDLL006");
        IFACE_SERVER(Clients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
        IFACE_SERVER(Ents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS);
        IFACE_ENGINE_CUR(Helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
        IFACE_ENGINE_CUR(Engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
        IFACE_ENGINE_CUR(Cvar, ICvar, CVAR_INTERFACE_VERSION);
        IFACE_ENGINE(Partition, ISpatialPartition, INTERFACEVERSION_SPATIALPARTITION);
        IFACE_ENGINE(ModelInfo, IVModelInfo, VMODELINFO_SERVER_INTERFACE_VERSION);
        /*IFACE_ENGINE(EngineTrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
        IFACE_ENGINE(EngineSound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
        IFACE_SERVER(PlayerInfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
        IFACE_SERVER(BotManager, IBotManager, INTERFACEVERSION_PLAYERBOTMANAGER);
        IFACE_ENGINE_CUR(EventManager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
        IFACE_ENGINE(Random, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
        IFACE_ENGINE(VoiceServer, IVoiceServer, INTERFACEVERSION_VOICESERVER);
        IFACE_FILESYS_CUR(FileSystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
        IFACE_ENGINE(StringTable, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER);
        IFACE_ENGINE(StaticProp, IStaticPropMgrServer, INTERFACEVERSION_STATICPROPMGR_SERVER);
        IFACE_ENGINE(DataCache, IDataCache, DATACACHE_INTERFACE_VERSION);
        IFACE_SERVER(Effects, IEffects, IEFFECTS_INTERFACE_VERSION);
        IFACE_ENGINE(SoundEmitter, ISoundEmitterSystemBase, SOUNDEMITTERSYSTEM_INTERFACE_VERSION);
        IFACE_SERVER(GameMovement, IGameMovement, INTERFACENAME_GAMEMOVEMENT);*/

        if ((pCallbacks = ismm->GetVSPInfo(NULL)) == NULL)
        {
            ismm->AddListener(this, this);
            ismm->EnableVSPListener();
        }

        pGlobals = ismm->GetCGlobals();

        g_pCVar = pCvar;

        ConVar_Register(0, &gBaseAccessor);

        GET_V_IFACE_ANY(GetEngineFactory, pServer, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);

        pCvar->FindVar("ecs_ver")->SetValue(ECS_VERSION);

        Msg("[ECS] Loaded successfully!");

        return true;
    }

    bool CECS::Unload(char *error, size_t maxlen)
    {
        HOOK_REMOVE(IServerGameDLL, LevelInit, pServer, ECS, true);
        HOOK_REMOVE(IServerGameDLL, LevelShutdown, pServer, ECS, false);
        HOOK_REMOVE(IServerGameDLL, ServerActivate, pServer, ECS, true);
        HOOK_REMOVE(IServerGameClients, ClientConnect, pClients, ECS, false);
        HOOK_REMOVE(IServerGameClients, ClientPutInServer, pClients, ECS, true);
        HOOK_REMOVE(IServerGameClients, ClientActive, pClients, ECS, true);
        HOOK_REMOVE(IServerGameClients, ClientDisconnect, pClients, ECS, true);
        HOOK_REMOVE(IServerGameClients, ClientCommand, pClients, ECS, false);
        HOOK_REMOVE(IServerGameClients, ClientSettingsChanged, pClients, ECS, true);
        HOOK_REMOVE(IServerGameClients, SetCommandClient, pClients, ECS, true);
        HOOK_REMOVE(IServerGameDLL, GameFrame, pServer, ECS, true);

        Msg("[ECS] Unloaded successfully!");
       
        return true;
    }

    // kp
    void CECS::OnVSPListening(IServerPluginCallbacks *iface)
    {
        HOOK_ADD(IServerGameDLL, LevelInit, pServer, ECS, true);
        HOOK_ADD(IServerGameDLL, LevelShutdown, pServer, ECS, false);
        HOOK_ADD(IServerGameDLL, ServerActivate, pServer, ECS, true);
        HOOK_ADD(IServerGameClients, ClientConnect, pClients, ECS, false);
        HOOK_ADD(IServerGameClients, ClientPutInServer, pClients, ECS, true);
        HOOK_ADD(IServerGameClients, ClientActive, pClients, ECS, true);
        HOOK_ADD(IServerGameClients, ClientDisconnect, pClients, ECS, true);
        HOOK_ADD(IServerGameClients, ClientCommand, pClients, ECS, false);
        HOOK_ADD(IServerGameClients, ClientSettingsChanged, pClients, ECS, true);
        HOOK_ADD(IServerGameClients, SetCommandClient, pClients, ECS, true);
        HOOK_ADD(IServerGameDLL, GameFrame, pServer, ECS, true);
    }

    ConVar ECS_ver("ecs_ver", ECS_VERSION, FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY);
All the unposted member functions are present in the file, I just can't put any more characters in this post.

Please look at the methods "bool CECS::Unload(char *error, size_t maxlen)" and "void CECS::OnVSPListening(IServerPluginCallbacks *iface)".

for example
CPP:
    // the 4th parameter, ECS, is unknown.
    // in NativeTools it's just NativeToolsPlugin, no string, no int, nothing in my opinion,
    // or I'm too blind to find it...
    HOOK_ADD(IServerGameDLL, LevelInit, pServer, ECS, true);

    // what has to go there?! I really don't know...


To make it clear, here's the NativeToolsPlugin.cpp file (most things cut out (which aren't relevant)...):
CPP:
    #include <Includes.hpp>
    #include <Tools.hpp>
    #include <Python.hpp>
    #include <ConCommand.hpp>
    #include <ConVar.hpp>
    #include <Entity.hpp>
    #include <MapEnd.hpp>
    #include <Offset.hpp>
    #include <Player.hpp>
    #include <PreEvents.hpp>
    #include <ServerStuff.hpp>
    #include <TempEntities.hpp>
    #include <Touch.hpp>
    #include <Trace.hpp>
    #include <Trigger.hpp>
    #include <UserCommand.hpp>
    #include <UserMessage.hpp>
    #include <Voice.hpp>
    #include <NativeToolsPlugin.hpp>


    #define NT_VERSION "2.0.0.0"

    CNativeToolsPlugin *pNativeToolsPlugin = new CNativeToolsPlugin;

    class BaseAccessor : public IConCommandBaseAccessor
    {
    public:
    #ifdef SMM
        bool RegisterConCommandBase(ConCommandBase *pCommandBase)
        {
            return META_REGCVAR(pCommandBase);
        }
    #else
        virtual bool RegisterConCommandBase(ConCommandBase *pCommandBase)
        {
        #if defined(OB) || defined(OBNV) || defined(L4D) || defined(L4D2)
            pCvar->RegisterConCommand(pCommandBase);
        #else
            pCvar->RegisterConCommandBase(pCommandBase);
        #endif
            return true;
        }
    #endif
    } gBaseAccessor;

    #ifdef SMM
        SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, char const*, char const*, char const*, char const*, bool, bool);
        SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, 0);
        SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t*, int, int);
        SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t*, const char*, const char*, char*, int);
        SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t*, char const*);
        SH_DECL_HOOK2_void(IServerGameClients, ClientActive, SH_NOATTRIB, 0, edict_t*, bool);
        SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t*);
        #if defined(OB) || defined(OBNV) || defined(L4D) || defined(L4D2)
            SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t*, const CCommand &);
        #else
            SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t*);
        #endif
        SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t*);
        SH_DECL_HOOK1_void(IServerGameClients, SetCommandClient, SH_NOATTRIB, 0, int);
        SH_DECL_HOOK1_void(IServerGameDLL, GameFrame, SH_NOATTRIB, 0, bool);

        PLUGIN_EXPOSE(CNativeToolsPlugin, *pNativeToolsPlugin);

    #else
        #if defined(OB) || defined(OBNV) || defined(L4D) || defined(L4D2)
            SourceHook::Impl::CSourceHookImpl g_SourceHook;
        #else
            SourceHook::CSourceHookImpl g_SourceHook;
        #endif
        SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;

        int g_PLID = 0;

        EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CNativeToolsPlugin, IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS, *pNativeToolsPlugin);
    #endif

    CNativeToolsPlugin::CNativeToolsPlugin() : m_iClientCommandIndex(0)
    {
    }

    #ifdef SMM
        bool CNativeToolsPlugin::Unload(char *error, size_t maxlen)
    #else
        void CNativeToolsPlugin::Unload()
    #endif
    {
        HOOK_REMOVE(IServerGameDLL, LevelInit, pServer, NativeToolsPlugin, true);
    #ifdef SMM
        HOOK_REMOVE(IServerGameDLL, LevelInit, pServer, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameDLL, LevelShutdown, pServer, NativeToolsPlugin, false);
        HOOK_REMOVE(IServerGameDLL, ServerActivate, pServer, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameClients, ClientConnect, pClients, NativeToolsPlugin, false);
        HOOK_REMOVE(IServerGameClients, ClientPutInServer, pClients, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameClients, ClientActive, pClients, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameClients, ClientDisconnect, pClients, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameClients, ClientCommand, pClients, NativeToolsPlugin, false);
        HOOK_REMOVE(IServerGameClients, ClientSettingsChanged, pClients, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameClients, SetCommandClient, pClients, NativeToolsPlugin, true);
        HOOK_REMOVE(IServerGameDLL, GameFrame, pServer, NativeToolsPlugin, true);
    #endif
        delete pConCommand;
        delete pConVar;
        delete pEntity;
        delete pMapEnd;
        delete pOffset;
        delete pPlayer;
        delete pPreEvents;
        delete pServerStuff;
        delete pTempEntities;
        delete pTouch;
        delete pTrace;
        delete pTrigger;
        delete pUserCommand;
        delete pUserMessage;
        delete pVoice;
        delete pPython;
        delete pUsers;
        delete pVCalls;
        delete pSigScan;
        delete pSettings;
        delete pHandler;
        delete pTools;

        pCvar->FindVar("nativetools_ver")->SetValue("unloaded ("NT_VERSION")");

    #ifdef SMM
        Msg("[NativeTools SMM] Unloaded successfully\n");
    #else
        Msg("[NativeTools VSP] Unloaded successfully\n");
    #endif

    #ifdef SMM
        return true;
    #endif
    }

    void CNativeToolsPlugin::OnVSPListening(IServerPluginCallbacks *iface)
    {
        pCallbacks = iface;
        HOOK_ADD(IServerGameDLL, LevelInit, pServer, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameDLL, LevelShutdown, pServer, NativeToolsPlugin, false);
        HOOK_ADD(IServerGameDLL, ServerActivate, pServer, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameClients, ClientConnect, pClients, NativeToolsPlugin, false);
        HOOK_ADD(IServerGameClients, ClientPutInServer, pClients, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameClients, ClientActive, pClients, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameClients, ClientDisconnect, pClients, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameClients, ClientCommand, pClients, NativeToolsPlugin, false);
        HOOK_ADD(IServerGameClients, ClientSettingsChanged, pClients, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameClients, SetCommandClient, pClients, NativeToolsPlugin, true);
        HOOK_ADD(IServerGameDLL, GameFrame, pServer, NativeToolsPlugin, true);
    }

    ConVar NativeTools_ver("nativetools_ver", NT_VERSION, FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY);
See? =/

Thanks for any help !! =)

BTW: ECS stands for Easy C++ Plugins, because I want to create a simple plugin like ES, only using C++ as the language.

EDIT: Makefile
MAKE:
    # (C)2004-2010 Metamod:Source Development Team
    # Makefile written by David "BAILOPAN" Anderson

    ###########################################
    ### EDIT THESE PATHS FOR YOUR OWN SETUP ###
    ###########################################

    HL2SDK_ORIG = ../hl2sdk
    HL2SDK_OB = ../hl2sdk-ob
    HL2SDK_OB_VALVE = ../hl2sdk-ob-valve
    HL2SDK_L4D = ../hl2sdk-l4d
    HL2SDK_L4D2 = ../hl2sdk-l4d2
    MMSOURCE18 = ../mmsource-1.8.7

    #####################################
    ### EDIT BELOW FOR OTHER PROJECTS ###
    #####################################

    PROJECT = easycppscripts
    OBJECTS = ecs.cpp \
                                    interfaces.cpp

    ##############################################
    ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
    ##############################################

    OPT_FLAGS = -O3 -funroll-loops -s -pipe
    GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
    DEBUG_FLAGS = -g -ggdb3 -D_DEBUG
    CPP = gcc

    ##########################
    ### SDK CONFIGURATIONS ###
    ##########################

    override ENGSET = false

    # Check for valid list of engines
    ifneq (,$(filter original orangebox orangeboxvalve left4dead left4dead2,$(ENGINE)))
            override ENGSET = true
    endif

    ifeq "$(ENGINE)" "original"
            HL2SDK = $(HL2SDK_ORIG)
            CFLAGS += -DSOURCE_ENGINE=1
    endif
    ifeq "$(ENGINE)" "orangebox"
            HL2SDK = $(HL2SDK_OB)
            CFLAGS += -DSOURCE_ENGINE=3
    endif
    ifeq "$(ENGINE)" "orangeboxvalve"
            HL2SDK = $(HL2SDK_OB_VALVE)
            CFLAGS += -DSOURCE_ENGINE=4
    endif
    ifeq "$(ENGINE)" "left4dead"
            HL2SDK = $(HL2SDK_L4D)
            CFLAGS += -DSOURCE_ENGINE=5
    endif
    ifeq "$(ENGINE)" "left4dead2"
            HL2SDK = $(HL2SDK_L4D2)
            CFLAGS += -DSOURCE_ENGINE=6
    endif

    HL2PUB = $(HL2SDK)/public

    ifeq "$(ENGINE)" "original"
            INCLUDE += -I$(HL2SDK)/public/dlls
            METAMOD = $(MMSOURCE18)/core-legacy
    else
            INCLUDE += -I$(HL2SDK)/public/game/server
            METAMOD = $(MMSOURCE18)/core
    endif

    OS := $(shell uname -s)

    ifeq "$(OS)" "Darwin"
            LIB_EXT = dylib
            HL2LIB = $(HL2SDK)/lib/mac
    else
            LIB_EXT = so
            ifeq "$(ENGINE)" "original"
                    HL2LIB = $(HL2SDK)/linux_sdk
            else
                    HL2LIB = $(HL2SDK)/lib/linux
            endif
    endif

    # if ENGINE is original or OB
    ifneq (,$(filter original orangebox,$(ENGINE)))
            LIB_SUFFIX = _i486.$(LIB_EXT)
    else
            LIB_PREFIX = lib
            LIB_SUFFIX = .$(LIB_EXT)
    endif

    CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 \
            -DSE_LEFT4DEAD=5 -DSE_LEFT4DEAD2=6 -DSE_ALIENSWARM=7

    LINK += $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX) \
            -static-libgcc

    INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
            -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I. -I$(METAMOD) -I$(METAMOD)/sourcehook

    ################################################
    ### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
    ################################################

    BINARY = $(PROJECT).$(LIB_EXT)

    ifeq "$(DEBUG)" "true"
            BIN_DIR = Debug.$(ENGINE)
            CFLAGS += $(DEBUG_FLAGS)
    else
            BIN_DIR = Release.$(ENGINE)
            CFLAGS += $(OPT_FLAGS)
    endif

    GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)

    ifeq "$(OS)" "Darwin"
            LIB_EXT = dylib
            CFLAGS += -isysroot /Developer/SDKs/MacOSX10.5.sdk
            LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
    else
            LIB_EXT = so
            CFLAGS += -D_LINUX
            LINK += -shared
    endif

    CFLAGS += -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp \
            -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca \
            -Dstrcmpi=strcasecmp -Wall -Wno-non-virtual-dtor -Werror -fPIC -fno-exceptions \
            -fno-rtti -msse -m32 -fno-strict-aliasing

    ifeq "$(GCC_VERSION)" "4"
            CFLAGS += $(GCC4_FLAGS)
    endif

    OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)

    $(BIN_DIR)/%.o: %.cpp
            $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<

    all: check
            mkdir -p $(BIN_DIR)
            ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX)
            ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX)
            $(MAKE) -f Makefile easycppscripts
           
    check:
            if [ "$(ENGSET)" = "false" ]; then \
                    echo "You must supply one of the following values for ENGINE:"; \
                    echo "left4dead2, left4dead, orangeboxvalve, orangebox, or original"; \
                    exit 1; \
            fi

    easycppscripts: check $(OBJ_BIN)
            $(CPP) $(INCLUDE) -m32 $(OBJ_BIN) $(LINK) -ldl -lm -o $(BIN_DIR)/$(BINARY)

    default: all

    clean: check
            rm -rf $(BIN_DIR)/*.o
            rm -rf $(BIN_DIR)/$(BINARY)
maybe there's the error..

_________________
New YouTube channel with EventScripts videos only!!]

Image


Last edited by BackRaw on 2012-04-25, 3:31 pm, edited 2 times in total.




User avatar
EventScripts Administrator
EventScripts Administrator
Profile

Posts: 6954
Location:
I am nowhere to be found

Steam Friends Name: godjonez
 
New postPosted: 2012-04-25, 1:55 pm 

The macros in ecs.h try to add p and C to the start of the name, changing them to pECS and CECS. Seems like the preprocessor of your C++ compiler is unable to do it. It should work with GCC... but try to combine those macros to single lines, e.g. taking the \ away at the line end and combine the lines.

_________________
Would you like something new?
popuplib2


User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2012-04-25, 2:03 pm 

Aight, thanks man. I'm using GCC 4.4...

_________________
New YouTube channel with EventScripts videos only!!]

Image


User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2012-04-25, 3:07 pm 
   Post subject: Re:

GODJonez wrote:
The macros in ecs.h try to add p and C to the start of the name, changing them to pECS and CECS. Seems like the preprocessor of your C++ compiler is unable to do it. It should work with GCC... but try to combine those macros to single lines, e.g. taking the \ away at the line end and combine the lines.

Tried that:
CPP:
    /* Hooks */

    #define HOOK_ADD(interfacename, functionname, interfaceinstance, hooktarget, post) SH_ADD_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_REMOVE(interfacename, functionname, interfaceinstance, hooktarget, post) SH_REMOVE_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_ADD_NAME(interfacename, functionname, interfaceinstance, hooktarget, hookfunctionname, post) SH_ADD_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: hookfunctionname), post);

    #define HOOK_REMOVE_NAME(interfacename, functionname, interfaceinstance, hooktarget, hookfunctionname, post) SH_REMOVE_HOOK(interfacename, functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: hookfunctionname), post);

    #define HOOK_VFUNC_ADD(functionname, interfaceinstance, hooktarget, post) SH_ADD_MANUALHOOK(NT_##hooktarget##_##functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_VFUNC_REMOVE(functionname, interfaceinstance, hooktarget, post) SH_REMOVE_MANUALHOOK(NT_##hooktarget##_##functionname, interfaceinstance, SH_MEMBER(p##hooktarget, &C##hooktarget:: functionname), post);

    #define HOOK_VFUNC_REFRESH(functionname, hooktarget, vfuncoffset) SH_MANUALHOOK_RECONFIGURE(NT_##hooktarget##_##functionname, vfuncoffset, 0, 0);

    /* IFACE */

    #define IFACE_INIT(variable, classname) classname *p##variable = NULL;

    #define IFACE_CHECK(type, variable, classname) if (!p##variable) { Msg("[NativeTools] ERROR: ("type"-)Interface '"#classname"' failed, aborting...\n"); return false; }

    #define IFACE_SERVER(variable, classname, interfaceversion) GET_V_IFACE_ANY(GetServerFactory, p##variable, classname, interfaceversion); IFACE_CHECK("Server", variable, classname);

    #define IFACE_SERVER_CUR(variable, classname, interfaceversion) GET_V_IFACE_CURRENT(GetServerFactory, p##variable, classname, interfaceversion); IFACE_CHECK("Server", variable, classname);

    #define IFACE_ENGINE(variable, classname, interfaceversion) GET_V_IFACE_ANY(GetEngineFactory, p##variable, classname, interfaceversion); IFACE_CHECK("Engine", variable, classname);

    #define IFACE_ENGINE_CUR(variable, classname, interfaceversion) GET_V_IFACE_CURRENT(GetEngineFactory, p##variable, classname, interfaceversion); IFACE_CHECK("Engine", variable, classname);

    #define IFACE_FILESYS(variable, classname, interfaceversion) GET_V_IFACE_ANY(GetFileSystemFactory, p##variable, classname, interfaceversion); IFACE_CHECK("FileSystem", variable, classname);

    #define IFACE_FILESYS_CUR(variable, classname, interfaceversion) GET_V_IFACE_CURRENT(GetFileSystemFactory, p##variable, classname, interfaceversion); IFACE_CHECK("FileSystem", variable, classname);
still the same errors =(

_________________
New YouTube channel with EventScripts videos only!!]

Image


User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2012-04-25, 3:08 pm 

ohhhhhhhhh my gosh, now I get what Chrisber wanted to do with this... lol

_________________
New YouTube channel with EventScripts videos only!!]

Image


User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2012-04-25, 3:12 pm 

got it!

I didn't knew that he managed to use "pNativeToolsPlugin" and "CNativeToolsPlugin" dynamically when compiling. I just needed to change the global "g_ECS" to "pECS", now it works :D

Thanks GODJonez!!

_________________
New YouTube channel with EventScripts videos only!!]

Image


User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2012-04-25, 3:31 pm 

Well... now I can compile the plugin, but loading gives the following error:
Code:
Failed to load plugin addons/easycppscripts (/home/srcds/css/css/cstrike/addons/easycppscripts.so: undefined symbol: _ZTV4CECS).

What the heck is that?!

EDIT: Changed
CPP:
    IFACE_SERVER(Server, IServerGameDLL, /*INTERFACEVERSION_SERVERGAMEDLL*/ "ServerGameDLL006"); //
to
CPP:
    IFACE_SERVER(Server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL); // "ServerGameDLL006"
still the same error..

_________________
New YouTube channel with EventScripts videos only!!]

Image


User avatar
Reader
Profile

Posts: 87
 
New postPosted: 2012-05-09, 9:29 pm 

can eventscripts coding be written in a txt file end edited with notepad C++? because i coded one in a txt and i dont know how to load it on my server. please help!


User avatar
Historian
Historian
Profile

Posts: 2928
Location:
Germany

Steam Friends Name: backraw1
 
New postPosted: 2013-02-20, 2:41 pm 
   Post subject: Re:

DNP wrote:
can eventscripts coding be written in a txt file end edited with notepad C++? because i coded one in a txt and i dont know how to load it on my server. please help!

pm me and i'll check it out

_________________
New YouTube channel with EventScripts videos only!!]

Image


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group