Errors when compiling with custom weapon Created 6 years ago2018-03-25 19:45:24 UTC by lythium lythium

Created 6 years ago2018-03-25 19:45:24 UTC by lythium lythium

Posted 6 years ago2018-03-25 19:45:24 UTC Post #339106
Ok so i found this thread http://twhl.info/articulator.php?art=31
and i followed it to create my custom weapon so i have a smg and a rifle, now i reused the half life 1 smg and improved accuracy and damage to make into rifle and this new weapon into smg. now all i done is replace the m16 parts with smg1 and my hl dll compiles properly but cl dll doesnt
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(5) : error C2504: 'CBasePlayerWeapon' : base class undefined
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(10) : error C2061: syntax error : identifier 'ItemInfo'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(11) : error C2061: syntax error : identifier 'CBasePlayer'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(14) : error C2146: syntax error : missing ';' before identifier 'Deploy'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(14) : error C2433: 'CSMG1::BOOL' : 'virtual' not permitted on data declarations
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(14) : warning C4183: 'Deploy': missing return type; assumed to be a member function returning 'int'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(18) : error C2146: syntax error : missing ';' before identifier 'UseDecrement'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(18) : error C2433: 'CSMG1::BOOL' : 'virtual' not permitted on data declarations
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(18) : warning C4183: 'UseDecrement': missing return type; assumed to be a member function returning 'int'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(9) : error C2065: 'SMG1_SLOT' : undeclared identifier
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(26) : error C2504: 'CBasePlayerAmmo' : base class undefined
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(29) : error C2146: syntax error : missing ';' before identifier 'AddAmmo'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(29) : error C2433: 'CSMG1AmmoClip::BOOL' : 'virtual' not permitted on data declarations
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(29) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(29) : error C2061: syntax error : identifier 'CBaseEntity'
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(29) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\administrator\desktop\hl sdk\src_dll\cl_dll\smg.h(29) : warning C4183: 'AddAmmo': missing return type; assumed to be a member function returning 'int'

the SMG.h is same in both directories, for cl dll and the hl dll so it is little weird that it works in 1 file but not other. i went thru it 3 times to see if any typos or anything but nothing

if you can help me out, thanks!
Posted 6 years ago2018-03-25 20:10:29 UTC Post #339107
hl_baseentity.cpp, hl_events.cpp, hl_objects.cpp, and hl_weapons.cpp need to be included in cl_dll project, I think they should have automatically be included but better make sure.
Posted 6 years ago2018-03-26 11:47:52 UTC Post #339110
They are included, theyre in hl subfolder if that makes any difference,
cl_dll>hl folder>hl_events, basentity and those
Posted 6 years ago2018-03-26 11:57:19 UTC Post #339111
#ifndef SMG1_H
#define SMG1_H

class CSMG1 : public CBasePlayerWeapon
{
public:
virtual void Spawn( void );
virtual void Precache( void );
virtual int iItemSlot( void ) { return SMG1_SLOT; }
virtual int GetItemInfo(ItemInfo *p);
virtual int AddToPlayer( CBasePlayer *pPlayer );
virtual void PrimaryAttack( void );
virtual BOOL Deploy( void );
virtual void Reload( void );
virtual void WeaponIdle( void );
virtual BOOL UseDecrement( void ) { return TRUE; }
private:
int m_iShell;
unsigned short m_event;
};

class CSMG1AmmoClip : public CBasePlayerAmmo
{
virtual void Spawn( void );
virtual void Precache( void );
virtual BOOL AddAmmo( CBaseEntity *pOther ) ;
};

enum CSMG1_e
{
smg1idle_SIL = 0,
smg1idle2,
smg1nade,
smg1reload,
smg1draw,
smg1fire1,
smg1fire2,
smg1fire3,
};
#endif

this ismy code in smg_h
Posted 6 years ago2018-03-26 15:18:20 UTC Post #339112
Did you include cbase.h, util.h and weapons.h before including your own header?
Posted 6 years ago2018-03-26 17:15:08 UTC Post #339113
not in smg.h but in smg.cpp
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "soundent.h"
#include "gamerules.h"

#include "smg.h"

LINK_ENTITY_TO_CLASS(weapon_smg1, CSMG1);
LINK_ENTITY_TO_CLASS(ammo_smg1, CSMG1AmmoClip);

void CSMG1::Spawn()
{
pev->classname = MAKE_STRING("weapon_smg1");
Precache();
SET_MODEL(ENT(pev), SMG1_MODEL_WORLD);
the smg.cpp compiles properly, its .h that has issues
Posted 6 years ago2018-03-26 17:39:41 UTC Post #339114
do u even need a header for a custom weapon? WHen I made them I dont remember needing a header for new weapons. All that could just go into the cpp file
Posted 6 years ago2018-03-26 18:13:30 UTC Post #339115
Where else are you including the header?
Posted 6 years ago2018-03-27 10:43:28 UTC Post #339117
@2muchvideogames add me at http://steamcommunity.com/id/lythxd if you can, id appriciate the help, thx
You must be logged in to post a response.