Raised This Month: $ Target: $400
 0% 

GHW_Sleepmod.sma


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rocofelu
Member
Join Date: Nov 2010
Old 05-01-2012 , 12:53   GHW_Sleepmod.sma
Reply With Quote #1

Another problem here:

Console:
Code:
L 05/01/2012 - 10:20:43: [AMXX] Displaying debug trace (plugin "GHW_Sleepmod.amxx")
L 05/01/2012 - 10:20:43: [AMXX] Run time error 10: native error (native "set_user_maxspeed")
L 05/01/2012 - 10:20:43: [AMXX]    [0] GHW_Sleepmod.sma::fadeout (line 102)
L 05/01/2012 - 10:20:43: [FUN] Invalid player 10
And GHW_Sleepmod.sma
Code:
/*
*   _______     _      _  __          __
*  | _____/    | |    | | \ \   __   / /
*  | |         | |    | |  | | /  \ | |
*  | |         | |____| |  | |/ __ \| |
*  | |   ___   | ______ |  |   /  \   |
*  | |  |_  |  | |    | |  |  /    \  |
*  | |    | |  | |    | |  | |      | |
*  | |____| |  | |    | |  | |      | |
*  |_______/   |_|    |_|  \_/      \_/
*
*
*
*  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>

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")
	register_clcmd("say /dorm","cmd_sleep")
	register_clcmd("say /treaz","cmd_wakeup")

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

	register_dictionary("GHW_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,"[Lunetistii.Ro] %L",id,"MSG_NOWAKEUP")
	else asleep[id]=false
}

public cmd_sleep(id)
{
	if(asleep[id]) client_print(id,print_chat,"[Lunetistii.Ro] %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,"[Lunetistii.Ro] %L",id,"MSG_SLEEP")
		client_print(id,print_chat,"[Lunetistii.Ro] %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,"[Lunetistii.Ro] %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()
		}
	}
}
Where is the problem? And how can i fix it? Thank's in advance!
rocofelu is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-01-2012 , 12:57   Re: GHW_Sleepmod.sma
Reply With Quote #2

PHP Code:
if( !is_user_connectedid ) )
  return; 
Add this check in fadeout( id ).
__________________

Last edited by claudiuhks; 05-01-2012 at 12:57.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Old 05-03-2012, 05:49
rocofelu
This message has been deleted by Exolent[jNr]. Reason: English only.
rocofelu
Member
Join Date: Nov 2010
Old 05-03-2012 , 10:56   Re: GHW_Sleepmod.sma
Reply With Quote #3

Code:
if( !is_user_connected( id ) )
  return;
where? ;))

its ok like this?

Code:
/*
*   _______     _      _  __          __
*  | _____/    | |    | | \ \   __   / /
*  | |         | |    | |  | | /  \ | |
*  | |         | |____| |  | |/ __ \| |
*  | |   ___   | ______ |  |   /  \   |
*  | |  |_  |  | |    | |  |  /    \  |
*  | |    | |  | |    | |  | |      | |
*  | |____| |  | |    | |  | |      | |
*  |_______/   |_|    |_|  \_/      \_/
*
*
*
*  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>

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")
	register_clcmd("say /dorm","cmd_sleep")
	register_clcmd("say /treaz","cmd_wakeup")

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

	register_dictionary("GHW_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,"[Lunetistii.Ro] %L",id,"MSG_NOWAKEUP")
	else asleep[id]=false
}

public cmd_sleep(id)
{
	if(asleep[id]) client_print(id,print_chat,"[Lunetistii.Ro] %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,"[Lunetistii.Ro] %L",id,"MSG_SLEEP")
		client_print(id,print_chat,"[Lunetistii.Ro] %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])
        if( !is_user_connected( id ) )
        return;  
	{
		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,"[Lunetistii.Ro] %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()
		}
	}
}
rocofelu is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode