#include <sourcemod>
#include <sdktools>
new Handle:a1 = null;
ConVar gamestart_sec;
public Plugin:myinfo =
{
name = "[紫冰] 倒计时",
author = "紫冰",
description = "倒计时功能",
version = "1.0",
url = ""
};
public OnPluginStart()
{
HookEvent("round_start", Event_RoundStart);
HookEvent("vote_passed", Event_VoteEnded);
HookEvent("vote_changed", Event_VoteEnded);
HookEvent("map_transition", Event_VoteEnded);
RegConsoleCmd("sm_a1",Command_a1,"");
gamestart_sec = CreateConVar("l4d1_timer_sec","60","时间设定", FCVAR_SPONLY);
}
//初始时间
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(0.1, GameReStart);
}
public Action GameReStart(Handle timer)
{
if(a1 != null)
{
ResetTimer();
}
else
{
a1 = CreateTimer(1.0, GameStart,GetConVarInt(gamestart_sec));
}
return Plugin_Handled;
}
public Action GameStart(Handle timer,int time)
{
if( time > 0 && a1 != null)
{
CreateTimer( 1.0, GameStart, --time);
}
else
{
return Plugin_Stop;
}
if(time <= 10 && time > 0)
{
EmitSoundToAll("ambient/alarms/klaxon1.wav", _, SNDCHAN_AUTO, SNDLEVEL_RAIDSIREN, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_LOW, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
}
PrintHintTextToAll("尸潮来袭: %i 秒", time);
return Plugin_Continue;
}
void ResetTimer()
{
if(a1 != null)
{
KillTimer(a1);
a1 = null;
}
}
public Action Event_VoteEnded(Event event, const char[] name, bool dontBroadcast)
{
PrintToChatAll("\x04[调试] 执行了投票操作...");
a1 = null;
}
public Action Command_a1(client, args)
{
a1 = null;
}
[游戏代码]求生之路插件:倒计时写法
最新推荐文章于 2022-05-18 16:12:09 发布
这篇博客介绍了如何在游戏《求生之路》中编写插件实现倒计时功能,包括学习连接语法和具体的时间脚本写法教程。
1万+

被折叠的 条评论
为什么被折叠?



