Forum

> > CS2D > Scripts > Sleep Script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Sleep Script

16 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Sleep Script

Bobakrome
User Off Offline

Zitieren
Hi all, can someone help me with a script? If you do there is what i want:

If player stands on a Trigger_Use called "Sleep" if press e then he go fade to sleep i mean:

Sleep

Screen fades to black, then it will be black for a 5,10 sec idk, then when screen fades to normal after 5,10 sec the player will have full health.

cookie For help..

alt Re: Sleep Script

EngiN33R
Moderator Off Offline

Zitieren
user itsoxymoron hat geschrieben
What if you make a Trigger_use/move - Trigger delay and Env - sprite?


That will make it visible to all people, he asks it to be visible for one player only.

1
2
3
4
5
6
7
8
9
10
11
12
13
sleepx,sleepy = 1,1 -- coordinates of the button

addhook("usebutton","sleepbut")
function sleepbut(id,x,y)
	if x==sleepx and y=sleepy then
		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id)
		imagealpha(sleepi,0)
		tween_alpha(sleepi,1000,1)
		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1
		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth"))
		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2
	end
end

I think this should work.

alt Re: Sleep Script

itsoxymoron
User Off Offline

Zitieren
user EngiN33R hat geschrieben
user itsoxymoron hat geschrieben
What if you make a Trigger_use/move - Trigger delay and Env - sprite?


That will make it visible to all people, he asks it to be visible for one player only.

1
2
3
4
5
6
7
8
9
10
11
12
13
sleepx,sleepy = 1,1 -- coordinates of the button

addhook("usebutton","sleepbut")
function sleepbut(id,x,y)
	if x==sleepx and y=sleepy then
		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id)
		imagealpha(sleepi,0)
		tween_alpha(sleepi,1000,1)
		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1
		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth"))
		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2
	end
end

I think this should work.


Oh, sorry, i understood.

alt Re: Sleep Script

Bobakrome
User Off Offline

Zitieren
I want if the Trigger_Use is called "Sleep" or if have at "Trigger": "sleep"

Because i need every bed in my happy town to do that so, its really much..

alt Re: Sleep Script

EngiN33R
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
addhook("usebutton","sleepbut")
function sleepbut(id,x,y)
	if entity(x,y,"name")=="sleep" then
		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id)
		imagealpha(sleepi,0)
		tween_alpha(sleepi,1000,1)
		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1
		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth"))
		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2
	end
end

alt Re: Sleep Script

Bobakrome
User Off Offline

Zitieren
user EngiN33R hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
addhook("usebutton","sleepbut")
function sleepbut(id,x,y)
	if entity(x,y,"name")=="sleep" then
		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id)
		imagealpha(sleepi,0)
		tween_alpha(sleepi,1000,1)
		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1
		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth"))
		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2
	end
end


Thinking of that may work but idk, when i start my server

"EXCEPTION_ACCESS_VIOLATION"

Uh when i edited from

1
dofile(htdirectory .. 'GoSleep.lua')
to
1
--dofile(htdirectory .. 'GoSleep.lua')
It worked then..
Maybe is something wrong with script

alt Re: Sleep Script

DC
Admin Off Offline

Zitieren
dofile crashes the game as soon as the script has a bug. this will be fixed.

alt Re: Sleep Script

Bobakrome
User Off Offline

Zitieren
user DC hat geschrieben
dofile crashes the game as soon as the script has a bug. this will be fixed.


Uhh then it will be hard to see script's bugs...

alt Re: Sleep Script

Obviously Exactly Myself
User Off Offline

Zitieren
user Bobakrome hat geschrieben
user EngiN33R hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
addhook("usebutton","sleepbut")
function sleepbut(id,x,y)
	if entity(x,y,"name")=="sleep" then
		local sleepi=image("gfx/sprites/block.bmp",320,240,2,id)
		imagealpha(sleepi,0)
		tween_alpha(sleepi,1000,1)
		timer(6000,"parse","lua tween_alpha("..sleepi..",1000,0)") --delay of 6 seconds because fading takes up 1
		timer(6000,"parse","sethealth "..id.." "..player(id,"maxhealth"))
		timer(7000,"parse","lua freeimage("..sleepi..")") --delay of 7 seconds because both fades take up 2
	end
end


Thinking of that may work but idk, when i start my server

"EXCEPTION_ACCESS_VIOLATION"

Uh when i edited from

1
dofile(htdirectory .. 'GoSleep.lua')
to
1
--dofile(htdirectory .. 'GoSleep.lua')
It worked then..
Maybe is something wrong with script

*facepalm*

Putting "--" will make the line unreadable.

alt Re: Sleep Script

Bobakrome
User Off Offline

Zitieren
Okay, the scripts allow you to walk, its possible to freeze you until you sleep? and oh yeah! the "block" it covers just the player 32x32 pixels, not the full screen
1× editiert, zuletzt 03.03.12 13:35:25

alt Re: Sleep Script

EngiN33R
Moderator Off Offline

Zitieren
Oh, whoops. Add these lines before tween_alpha in the if statement:

1
2
3
4
local speed=player(id,"speedmod")
imagescale(sleepi,20,15)
parse("speedmod "..id.." -100")
timer(7000,"parse","speedmod "..id.." "..speed)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht