Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Updating the code of a game engine, but I got these errors...

C#
// advanced NVG
class CItemNVG : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_longjump.mdl"); // you''ll want to change this
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL("models/w_longjump.mdl"); // you''ll want to change this
PRECACHE_SOUND("buttons/blip1.wav");
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ( pPlayer->m_fNVG ) // does the player already have it
{
return FALSE; // if so, quit
}

if ( ( pPlayer->pev->weapons & (1<
{//error here 
pPlayer->m_fNVG = TRUE; // player now has night vision goggles

// make the client.dll print out the symbol on ammo history
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) );
MESSAGE_END();

// play a sound to tell the player he''s picked up the NVG
EMIT_SOUND(pPlayer->edict(), CHAN_WEAPON, "buttons/blip1.wav", 0.8, ATTN_NORM );
return TRUE;
}
return FALSE;
}// error here
};

LINK_ENTITY_TO_CLASS( item_nvg, CItemNVG );
// advanced NVG



ERROR:

1>\dlls\items.cpp(387): error C2958: the left parenthesis '(' found at '\dlls\items.cpp(373)' was not matched correctly
1>\dlls\items.cpp(388): error C2969: syntax error : ';' : expected member function definition to end with '}'
1>\dlls\items.cpp(390): error C2059: syntax error : 'string'
1>\dlls\items.cpp(390): error C2238: unexpected token(s) preceding ';'
1>\dlls\items.cpp(392): fatal error C1004: unexpected end-of-file found



Please help me
Posted

Having just checked the source you posted against the displayed source, I think you will find that the line above where you get the error has three unmatched open brackets.
C++
if ( ( pPlayer->pev->weapons & (1<
I suspect you did not copy the line completely when you pasted it in from whatever website you found it at. You may well find that you need to go back to the site, and copy the source code again, properly this time!

In future, indent your code so it is readable, or be prepared for some nasty messages and a distinct lack of help - if you make it difficult for us, then why would we help you? It's not as if we get paid for this!
 
Share this answer
 
Comments
Simon Bang Terkildsen 10-Sep-11 14:59pm    
OP wrote
Found & fixed it
The code id incomplete but I can fix it!
Thanks for your help!
The if statement right before your comment of "{//error here" looks like it is not closed properly.

if ( ( pPlayer->pev->weapons & (1<

If you are using Visual Studio to edit your files, you can use CTRL+] to help find matching braces.
If you use CTRL+] on the line with the braces with the error comment, you will see that it finds the matching end brace.
If you try CTRL+] on the previous line with the if statement, it can't find the matching closing parentheses.
 
Share this answer
 
Comments
sora97 10-Sep-11 2:08am    
I am using Visual C++ 2010
Simon Bang Terkildsen 10-Sep-11 14:59pm    
OP wrote
Found & fixed it
The code id incomplete but I can fix it!
Thanks for your help!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900