如何更正此代码? [英] how to correct this code?

查看:79
本文介绍了如何更正此代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在更新游戏引擎的代码,但是出现了这些错误...

Updating the code of a game engine, but I got these errors...

// 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

推荐答案

刚刚对照显示的源检查了您发布的源,我认为您会发现出现错误的行上面有三个未匹配的空行括号.
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.
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!


就在您对"{//error here"的评论之前的if语句似乎未正确关闭.

如果((pPlayer-> pev->武器& (1<

如果使用Visual Studio编辑文件,则可以使用CTRL +]来帮助找到匹配的花括号.
如果在带有错误注释的大括号的行上使用CTRL +],您会发现它找到了匹配的大括号.
如果您在上一行使用if语句尝试使用CTRL +],则找不到匹配的右括号.
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.


这篇关于如何更正此代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆