收藏文章 楼主

DOD1.3睡觉恢复HP(需自行设置音效)

版块:AMXX 插件及模块发布区   类型:普通   作者:海呀   查看:56   回复:1   获赞:0   时间:2025-08-07 23:29:07
/*
*   _______     _      _  __          __
*  | _____/    | |    | | \ \   __   / /
*  | |         | |    | |  | | /  \ | |
*  | |         | |____| |  | |/ __ \| |
*  | |   ___   | ______ |  |   /  \   |
*  | |  |_  |  | |    | |  |  /    \  |
*  | |    | |  | |    | |  | |      | |
*  | |____| |  | |    | |  | |      | |
*  |_______/   |_|    |_|  \_/      \_/
*
*
*
*  Last Edited: 12-30-07
*
*  ============
*   Changelog:
*  ============
*
*  v2.0
*    -Added ML
*    -Optimized Code
*
*  v1.0
*    -Initial Release
*
*/

#define VERSION	"2.0"

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dodx>

static const sound1[32] = "sleep.wav"
static const sound2[32] = "bagyawn.wav"
static const sound1b[32] = "sound/sleep.wav"
static const sound2b[32] = "sound/bagyawn.wav"

new bool:playsound1
new bool:playsound2

new bool:asleep[33]

new max_health

public plugin_init()
{
	register_plugin("Sleep Mod",VERSION,"GHW_Chronic")

	register_clcmd("say /sleep","cmd_sleep")
	register_clcmd("say /wakeup","cmd_wakeup")

	max_health = register_cvar("sleep_maxhp","120")

	register_dictionary("Sleepmod.txt")
}

public plugin_precache()
{
	if(file_exists(sound1b))
	{
		playsound1=true
		precache_sound(sound1)
	}
	if(file_exists(sound2b))
	{
		playsound2=true
		precache_sound(sound2)
	}
}

public client_connect(id) asleep[id]=false
public client_disconnect(id) asleep[id]=false

public cmd_wakeup(id)
{
	if(!asleep[id]) client_print(id,print_chat,"[睡觉补血] %L",id,"MSG_NOWAKEUP")
	else asleep[id]=false
}

public cmd_sleep(id)
{
	if(asleep[id]) client_print(id,print_chat,"[睡觉补血] %L",id,"MSG_NOSLEEP")
	else if(!is_user_alive(id)) client_print(id,print_chat," %L",id,"MSG_NOSLEEP2")
	else
	{
		asleep[id]=true
		set_task(0.2,"fadeout",id,"",0,"b")
		client_print(id,print_center,"[睡觉补血] %L",id,"MSG_SLEEP")
		client_print(id,print_chat,"[睡觉补血] %L",id,"MSG_WAKEUP")
		if(playsound1) emit_sound(id,CHAN_VOICE,sound1,VOL_NORM,ATTN_NORM,0,PITCH_NORM)
	}
}

public fadeout(id)
{
	if(!asleep[id])
	{
		set_user_maxspeed(id,320.0)
		client_cmd(id,"-duck")

		if(playsound2) emit_sound(id,CHAN_VOICE,sound2,VOL_NORM,ATTN_NORM,0,PITCH_NORM)
		client_print(id,print_center,"[睡觉补血] %L",id,"MSG_WAKEUP2")

		set_user_rendering(id)

		message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
		write_short(~0)
		write_short(~0)
		write_short(1<<12)
		write_byte(0)
		write_byte(0)
		write_byte(0)
		write_byte(0)
		message_end()
		remove_task(id)
	}
	else if(!is_user_alive(id))
	{
		asleep[id]=false
		fadeout(id)
	}
	else
	{
		new health = get_user_health(id)
		if(health>=get_pcvar_num(max_health))
		{
			asleep[id]=false
			fadeout(id)
		}
		else
		{
			set_user_maxspeed(id,1.0)
			client_cmd(id,"+duck")

			set_user_health(id,health + 1)

			set_user_rendering(id,kRenderFxGlowShell,0,255,0,kRenderTransAlpha,25)

			message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
			write_short(~0)
			write_short(~0)
			write_short(1<<12)
			write_byte(0)
			write_byte(0)
			write_byte(0)
			write_byte(255)
			message_end()
		}
	}
}

 
回复列表
默认   热门   正序   倒序
haiya
2F
海呀Lv0
需在文件夹sound下放入 

sleep.wav 

bagyawn.wav 

以上两个音频文件,一个是睡觉,一个是睡醒音效,当然也可直接删除音效



 lang文件夹下新建文档Sleepmod.txt 将以下内容粘贴保存


 [cn] 
MSG_NOWAKEUP = 你不能睡觉. 
MSG_NOSLEEP = 你已经睡着了.
MSG_NOSLEEP2 = 你当前状态无法睡觉
MSG_SLEEP = * 开始睡觉 *
MSG_WAKEUP = 起床.
MSG_WAKEUP2 = 起床时间.

共0条回复,点击查看回复
 0   24天前  回复

回复:DOD1.3睡觉恢复HP(需自行设置音效)

Powered by HadSky 8.5.2

©2015 - 2025 CND论坛 - 中国梦DOD

苏ICP备2025177870号-1

您的IP:10.3.91.85,2025-09-01 22:26:48,Processed in 0.06667 second(s).

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息