Zh/CS:GO VScript Examples

From Valve Developer Community
< Zh
Revision as of 06:08, 30 August 2017 by GEEKiDoS (talk | contribs) (Created page with "{{csgo}} 以下是适用于Counter-Strike: Global Offensivevscripts 脚本 . ===找到离一个已知实体实体最近的玩家=== <source lang=cpp>but...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

反恐精英:全球攻势 以下是适用于Counter-Strike: Global Offensivevscripts 脚本 .

找到离一个已知实体实体最近的玩家

buttonReference <- Entities.FindByName( null, "button_01" ); // 找到一个叫 "button_01" 的实体并且储存它的targetname(名字)
	
player <- Entities.FindByClassnameNearest( "player", buttonReference.GetOrigin(), 512 ); // 在距离按钮中心 512 Hammer单位(英寸) 的范围内寻找玩家并且储存为一个变量.

会原地爆炸爆的诱弹

//以下的脚本需要附加到一个类似logic_script之类的实体上

EXPLOSION_SOUND <- "c4.Explode"; //这个可以在Hammer的声音浏览器里找到

function Precache() /如果这个函数定义了那么他会在脚本执行时自动执行
{
	self.PrecacheScriptSound( EXPLOSION_SOUND );
}

//以下脚本的作用是每间隔 0.1 秒检查地图上有没有 decoy_projectiles 这个实体
//当地图上有这个实体的时候检测他的速度是否为 0,0,0
//如果是的那么诱弹就是停下来了然后就可以运行剩下的部分:
//创建一个 env_explosion 并且移动到诱弹的中心点
//然后触发这玩意,随后kill掉诱弹

function Think()
{
	ent <- null;
	while ((ent = Entities.FindByClassname(ent, "decoy_projectile")) != null)
	{		
		if(ent.GetVelocity().Length() == Vector(0,0,0).Length())
		{		
			owner <- ent.GetOwner();
			origin <- ent.GetOrigin();	
			
			exp <- Entities.CreateByClassname("env_explosion");
			exp.__KeyValueFromInt("iMagnitude", 2000);
					
			ent.EmitSound(EXPLOSION_SOUND);
									
			exp.SetOrigin(origin);
			exp.SetOwner(owner);
									
			EntFireByHandle(exp, "Explode", "", 0.1, owner,owner);						
			ent.Destroy();						
			DispatchParticleEffect("explosion_c4_500", origin, origin);
		}		
	}
}

[待完善]

看一下这些吧

外部链接