Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 291 92 93338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
Vectar666 has written
I cannot use hook "reload", if weapon is AUG or sg552!
Please help, other weapons are working with the same script!


wtf, you found a nice bug xD.

hey i remember your post (rol xd) and in the new version is there a new hook: break(x,y) (on breaking a breakable entity).

bye


EDIT:


I NEED HELP, i know how to use image and freeimage.
But if the image has mode = 200+id (draw over a player), i cant use freeimage with this image because it doesnt remove!
edited 1×, last 16.11.09 06:40:10 pm

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
Flacko has written
NBK, post your script please...

K
I have some codes using that.
First for example there is a function like this:


function gph(id)
id6=image("gfx/asd.bmp",1,1,201)
end

then there is one like this:

function rem(id)
freeimage(id6)
end

thats all
bye

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
Flacko has written
Uhhh, I guess you are doing something really wrong...
Post an ENTIRE script, so I can help you to fix it


oh sorry. anyway the script is practically the same

escaper = 0

addhook("attack","prisonert")
function prisonert(id)
     if (player(id,"team")==1) then
timer(50,"prisongfx",1,1)
escaper = id
end
end


function prisongfx(id)
id1=image("gfx/escaper.bmp",1,1,escaper)
timer(200,"escaperend",1,1)
end

function escaperend(id)
freeimage(id1)
timer(200,"removeall",1,1)
end

function removeall(id)
freetimer()
end

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
can anyone explain me the "maths" things like
mat.randomseed, math.cos, math.sin, etc.
i don't understand that things :S

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
hmmm...
Try this NBK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function array(s)
	local t={}
	for i=1,s do
		t[i]=0
	end
end

--I removed the variable escaper, we will use an array instead

img=array(32) --We will use 32 sprites, actually, we are just storing the ID OF THE IMAGE in this array

addhook("attack","prisonert")
function prisonert(id)
	if (player(id,"team")==1) then
		prisongfx(id)
	end
end


function prisongfx(id)
	img[id]=image("gfx/escaper.bmp",1,1,200+escaper) --Load the image 
	timer(
		1000*3, --Three seconds
		"escaperend", --Call this function, that will ERASE THE SPRITE
		tostring(id), --With this string as parameter, the PLAYER ID
		1 --And do it just ONCE
	)
end

function escaperend(id)
	freeimage( img[tonumber(id)] ) --Free the corresponding sprite
end

--I also removed the function to free timers, we don't need to free them because they are called only ONCE

Wilson:
math.randomseed initalizes the random number generator, you pass a number to it that will be multiplied, summed, diveded, etc, to get PSEUDO-random values. Because they aren't 100% random, that's what makes us better than machines

math.cos and sin: Easy, you pass an angle (I will specify later how you must pass it) to the function and the function returns a number that multiplied by certain number (this number is known as length for some reason) will return the carthesian coordinates, that is X (if you used math.cos) and Y (if used math.sin)

If you survived the last paragraph you will still have to know how must be the angle that you pass to math.sin and cos. The angle must be in radians, being -Pi the left side, 0 the right side and Pi the left side again :P. It's clockwise starting from the left.

Now, a small example in pseudo code
1
2
3
angle = math.pi/4 --This is the bottom right
speed = 4 --This will be the speed, the higher the value, the further u move
parse("setpos 1 "..math.cos(angle)*speed.." "..math.sin(angle)*speed)
Good luck

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
Flacko has written
hmmm...
Try this NBK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function array(s)
	local t={}
	for i=1,s do
		t[i]=0
	end
end

--I removed the variable escaper, we will use an array instead

img=array(32) --We will use 32 sprites, actually, we are just storing the ID OF THE IMAGE in this array

addhook("attack","prisonert")
function prisonert(id)
	if (player(id,"team")==1) then
		prisongfx(id)
	end
end


function prisongfx(id)
	img[id]=image("gfx/escaper.bmp",1,1,200+escaper) --Load the image 
	timer(
		1000*3, --Three seconds
		"escaperend", --Call this function, that will ERASE THE SPRITE
		tostring(id), --With this string as parameter, the PLAYER ID
		1 --And do it just ONCE
	)
end

function escaperend(id)
	freeimage( img[tonumber(id)] ) --Free the corresponding sprite
end

--I also removed the function to free timers, we don't need to free them because they are called only ONCE

Wilson:
math.randomseed initalizes the random number generator, you pass a number to it that will be multiplied, summed, diveded, etc, to get PSEUDO-random values. Because they aren't 100% random, that's what makes us better than machines

math.cos and sin: Easy, you pass an angle (I will specify later how you must pass it) to the function and the function returns a number that multiplied by certain number (this number is known as length for some reason) will return the carthesian coordinates, that is X (if you used math.cos) and Y (if used math.sin)

If you survived the last paragraph you will still have to know how must be the angle that you pass to math.sin and cos. The angle must be in radians, being -Pi the left side, 0 the right side and Pi the left side again :P. It's clockwise starting from the left.

Now, a small example in pseudo code
1
2
3
angle = math.pi/4 --This is the bottom right
speed = 4 --This will be the speed, the higher the value, the further u move
parse("setpos 1 "..math.cos(angle)*speed.." "..math.sin(angle)*speed)
Good luck


Thank you Flacko, I will try it.

old Re: Lua Scripts/Questions/Help

Chunks
User Off Offline

Quote
CAN SOMEONE HELP ME ?
IM JUST SAYIN 1 TIME THIS AND NO1 HEAR ME o.O
Can someone help me PLEASE ?:
How i make a command that the player get god stats
like inf health
and he never die
like if cmd: god <id>
then it does lol
i dont know script can someone help me ?

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Chunks has written
CAN SOMEONE HELP ME ?
IM JUST SAYIN 1 TIME THIS AND NO1 HEAR ME o.O
Can someone help me PLEASE ?:
How i make a command that the player get god stats
like inf health
and he never die
like if cmd: god <id>
then it does lol
i dont know script can someone help me ?

we cant help you because you don't even have a script. this thread is for "helping" not asking someone to make it. At least try to make it by yourself. Its really easy to learn how to script in lua

EDIT: Oh, and one more thing, there is already a script I made about god mode. Just search it in this thread.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
can anyone help me to do a function that makes this:
a single class is unlocked and when every T dies 5 times then
T's cannot respawn anymore for a minute and after that another class is unlocked
i've thought something like this (unfinished cus i don't know how to do it :S)
Spoiler >

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
-WiLSoN- has written
can anyone help me to do a function that makes this:
a single class is unlocked and when every T dies 5 times then
T's cannot respawn anymore for a minute and after that another class is unlocked
i've thought something like this (unfinished cus i don't know how to do it :S)
Spoiler >

I have managed to make it like this:
Spoiler >

But the trick is that it kills a player after a spawn. So he has 6 deaths when he becomes spectator

Those timers are a new story for me
Maybe Flacko could edit my script. Hes awesome in it!

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
-WiLSoN- has written
thanks but i need to unlock some class after that ;S
how to make it =S !!

No idea. I never learned how to make a menu in lua so i never needed to know
Ahh... time is patient.

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
-WiLSoN- has written
can anyone help me to do a function that makes this:
a single class is unlocked and when every T dies 5 times then
T's cannot respawn anymore for a minute and after that another class is unlocked
i've thought something like this (unfinished cus i don't know how to do it :S)
Spoiler >


Hey!. Try this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[spoiler]

tcanspawn = 1

addhook("die","nomorexd")
function nomorexd(victim,killer,weapon,x,y)
	if (player(victim,"team")==1 and player(victim,"deaths")==5) then
tcanspawn = 0
timer(60000,"canagain",1,1)
end
end



addhook("spawn","spawnn")
function spawnn(id,team)
	if (tcanspawn = 0 and player(id,"team")==1) then
msg("You can't spawn yet")
return 0
else

end
end

function canagain(id)
tcanspawn = 1
end
[/spoiler]

It's bizarre but i think will work!.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
spawn hook return is for items it just gives me the "you can't spawn yet" message :S
anyways thanks you gave me an idea
(i'm still receiving answers xD)

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
-WiLSoN- has written
spawn hook return is for items it just gives me the "you can't spawn yet" message :S
anyways thanks you gave me an idea
(i'm still receiving answers xD)


sorry for the return, i saw it then!.
But is the same, just put parse("makespec "..id)

use ur brain man...

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
LinuxGuy has written
Maybe Flacko could edit my script. Hes awesome in it!


Oh Lol.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function array(size,value)
	local t = {}
	for i=1,size do
		t[i]=value
	end
	return t
end

--We will store the deaths of a player here, so that the class doesn't get activated by just typing kill in console
player_deathst = array(32,0)
--When the class gets unlocked we change Ts to spectators and we will set them back with this
player_wast = {}
--Won't let players spawn
t_can_spawn = true
--5 unlockable classes
unlocked_classes = array(5,false)

function unlock_next_class()
	for i,v in ipairs(unlocked_classes) do
		if v == false then
			unlocked_classes[i] = true --Unlock this class
			break
		end
	end
end

function unlock_terrorists()
	t_can_spawn = true
	for i,v in ipairs(player_wast) do
		parse("maket "..v)
	end
end

--Prevent zombies from switching back to T
addhook("team","class_team")
function class_team(id,team)
	if team == 1 then
		if t_can_spawn == false then
			return 1
		end	
	end
end

addhook("kill","class_kill")
function class_kill(k,v,w)
	if player(k,"team")==2 and player(v,"team")==1 then
		player_deathst[v]=player_deathst[v]+1
		if(player_deathst[v]>= 5) then --5 Deaths
			unlock_next_class() --Unlock the next class
			t_can_spawn = false --No more spawning for you guys
			player_deathst = array(32,0) --Reset the array
			player_wast = {}
			timer(1000*60,"unlock_terrorists","",1) --Unlock the team in a minute
			for i=1,32 do
				if player(i,"team")==1 then
					table.insert(player_wast,i)
					parse("makespec "..i)
				end
			end
		end
	end
end

Try it and tell me what errors you get
edited 7×, last 17.11.09 12:54:09 am
To the start Previous 1 291 92 93338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview