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 2215 216 217338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
vesa-omar has written
Srry didnt work,

and i meant it spawns the item in the map not just equips it.
I need this couse im doing an mod called Zombie harm Mod
And the one that help's me will get credit's there


1
2
3
4
5
6
7
addhook("projectile","zhm_ammogiver")
function zhm_ammogiver(id,weapon,x,y)
	if weapon == 51 then
		parse("spawnitem 61 "..math.floor(x/32).." "..math.floor(y/32))
		parse("spawnitem 62 "..math.floor(x/32).." "..math.floor(y/32))
	end
end

old Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Quote
addhook("projectile","zhm_ammogiver")
function zhm_ammogiver(id,weapon,x,y)
     if (weapon==51) then
          local tx,ty = math.floor(x/32),math.floor(y/32)
          parse("spawnitem 61 "..tx.." "..ty)
          parse("spawnitem 62 "..tx.." "..ty)
     end
end

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
Dont need, but thanks anyways

I made an Buy Ammo script instead of the HE throw
but maybe you can help me with

1
2
3
4
5
6
7
8
9
addhook("hit","zhm_uspheal")
function zhm_uspheal(id,source,weapon,hpdmg,apdmg)
     if (weapon==1) then
          parse ("sethealth "..id.." "..player(id,"health")+20)
          parse('effect "fire" ' ..x.. ' ' ..y.. ' 140 96 0 0 0')
          msg2(id,"©000500000You got healed by "..player(p,"name").."")
          return 1
     end
end

when you hit some one the guy you hitted will have an fire effect on him self

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("hit","zhm_uspheal")
function zhm_uspheal(id,source,weapon,hpdmg,apdmg)
if (weapon==1) then
parse ("sethealth "..id.." "..player(id,"health")+20)
parse('effect "fire" ' ..x.. ' ' ..y.. ' 140 96 0 0 0')
msg2(id,"©000200000You got healed by "..player(source,"name").."")
return 1
end
end

old Re: Lua Scripts/Questions/Help

KenVo
User Off Offline

Quote
what wrong with my tibia's ninja skill ?

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
[107] = {
		name = "Ninja skill",
		desc = "You may only use it once.",
		r = 255, g = 255, b = 255,
		action = {"cast","hold"},
		slot = 9,
		level = 30,
		fimage = "gfx/weiwen/rune.png",
		func = {function(id, itemslot, itemid, equip)
			radiusmsg(player(id,"name") .. " use ninja skill.", player(id,"x"), player(id,"y"))
			if player(id,"team")>0 and player(id,"health")>0 then
				local rot = player(id,"rot")
				if rot < -90 then rot = rot + 360 end
					local distance = 32 * 2
					local angle = math.rad(math.abs(rot + 90)) - math.pi
					local xt = player(id,"x") + math.cos(angle) * distance
					local yt = player(id,"y") + math.sin(angle) * distance
					if tile(math.floor(x/32),math.floor(y/32),"walkable") then
					parse("setpos "..id.." "..xt.." "..yt)
					explosion(xt, yt, 96, 40, id)
					local pos = player(id,"x") .. " " .. player(id,"y")
					parse("effect \"colorsmoke\" " .. pos .. " 100 96 255 255 255")
					destroyitem(id, itemslot, equip)
					else
					message(id, 'You cannot use this to go into walls!','255255255')
					end
				end
			end,equip},
	},


Line: "if tile(math.floor(x/32),math.floor(y/32),"walkable") then" has errors with x and y

old Re: Lua Scripts/Questions/Help

mafia_man
User Off Offline

Quote
@vesa-omar
frm where script must get x and y ??
I think this must look like this :

1
2
3
4
5
6
7
8
9
10
11
12
addhook("hit","zhm_uspheal")
function zhm_uspheal( id, source, weapon, hpdmg, apdmg)
	if (weapon == 1) then
		local x, y
		x = player( id, "x")
		y = player( id, "y")
		parse("sethealth "..id.." "..player( id, "health") + 20)
		parse('effect "fire" ' ..x.. ' ' ..y.. ' 140 96 0 0 0')
		msg2( id, "©000500000You got healed by 	"..player( source, "name").."")
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
I have small 2 questions

> Where can i download fifa2d mod...?
> Who can give me mod for map: "rpg_mapb_b4.5",
"rpg_mapb_b4.1" or "rpg_mapb_b4"

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
The mod for map rpg_map4.5 is not available due to the fact that it's private to Hitsugaya mod.

Alright, and I have one last question. I've seen a lot of trig math used in scripts, and I've noticed increasingly how powerful it is.
I know what these statements relatively do, but I am a bit fuzzy on how they work exactly.
such as this
1
2
3
local angle = math.rad(math.abs(rot + 90)) - math.pi
					local xt = player(id,"x") + math.cos(angle) * distance
					local yt = player(id,"y") + math.sin(angle) * distance
or this
1
local rot = math.atan2(player(owner_id,"y")-monster_y[npc],player(owner_id,"x")-monster_x[npc]) + math.pi/2 - (math.random(-1,2)/10)
or this
1
math.random(-1, 1)*math.pi/2
Does this have something to do with changing the angle of the image using radians?
I just used this from my friends scripts.

@Ken Dude, I already told you that, heres the new version that doesn't let you cross over walls either
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
[107] = {
		name = "jump explosion attack rune",
		desc = "You may only use it once.",
		r = 255, g = 22, b = 0,
		action = {"cast","hold"},
		slot = 9,
		fimage = "gfx/weiwen/rune.png",
		func = {function(id, itemslot, itemid, equip)
			distance = 0
			radiusmsg(player(id,"name") .. " casts a jump explosion attack rune.", player(id,"x"), player(id,"y"))
			if player(id,"team")>0 and player(id,"health")>0 then
				local rot = player(id,"rot")
				if rot < -90 then rot = rot + 360 end
					while distance < 32*5 do
						distance = distance + 32
						angle = math.rad(math.abs(rot + 90)) - math.pi
						xt = player(id,"x") + math.cos(angle) * distance
						yt = player(id,"y") + math.sin(angle) * distance
						if tile(math.floor(xt/32),math.floor(yt/32),"walkable") then
							if distance == 32*4 then
								destroyitem(id, itemslot, equip)
								parse("setpos "..id.." "..xt.." "..yt)
								explosion(player(id,"x"), player(id,"y"), 64, 15, id)
							end
						else
							message(id, 'You cannot use this to go into/or through walls!','255255255')
							break
						end
					end
				end
			end,equip},
	},
edited 4×, last 02.07.10 12:01:54 am

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
I was playing with Lua to do stuff anyway I tried to load a function from a text document after using string.dump on the function but it never works.
1
2
3
4
5
6
7
8
9
10
function test (a)
	print(a)
end
s=string.dump(test)
local f = io.open("dump.txt", "w")
f:write(s)
for line in io.lines("dump.txt") do
	s2 = loadstring(line)
end
pcall(s2, " - ")

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
Hi all
I want if I say "laser" and if I hit then somebody with USP that this injured player get a laser.
And if I say "RPG" and if I hit then somebody with USP that this injured player get a RPG.

CAN ANYBODY SHOW ME A SCRIPT LIKE THIS??

SRY FOR MY BAD ENGLISH

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
lazor = 0

addhook ("say","sages")
function sages(id,text)
if text=="laser" and lazor ==0 then
lazor = 1
elseif text=="laser" and lazor ==1 then
lazor = 0
end
end

addhook ("hit","ho")
function ho(id,source,we)
if we == 1 and lazor == 1 then
parse ("equip "..id.." 45")
end
end

try this..

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
@ Schinken

Weil du Deutsch kannst sag ich's so.
Also wenn ich "laser" sage und einen mit USP anschieße
das der dann laser bekommt klappt aber......
Ich habe dein Script zweimal Eingefügt und es verändert das der angeschossene zum beispiel wenn ich sage "portal" das der portal gun kriegt aber weil ich vorher "laser" gesagt habe kriegt der laser und portal gun
also brauch ich was das wenn ich etwas anderes sage als vorher das der nicht trotzdem das vorherige (laser) sondern dann nur noch die portal gun kriegt.

ICH BRAUCH WENIGSTENS WAS WAS DAS SCRIPT RÜCKGÄNGIG MACHT ZUM BEISPIEL WENN ICH SAGE
"back"

Ich geb dir mal (mein/dein) script

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
lazor = 0

addhook ("say","sages")
function sages(id,text)
if text=="laser" and lazor ==0 then
lazor = 1
elseif text=="laser" and lazor ==1 then
lazor = 0
end
end

addhook ("hit","ho")
function ho(id,source,we)
if we == 1 and lazor == 1 then
parse ("equip "..id.." 45")
end
end

portal = 3

addhook ("say","sages2")
function sages2(id,text)
if text=="portal" and portal ==2 then
portal = 3
elseif text=="portal" and portal ==3 then
portal = 2
end
end

addhook ("hit","ho2")
function ho2(id,source,we)
if we == 1 and portal == 3 then
parse ("equip "..id.." 88")
end
end

Admin/mod comment

English only! /TheKilledDeath

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
I have a little question

I want if somebody have used the cmd="kill"
that this player does not die.
I need it for a prison
Can anybody help me?

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
Snake_Eater: this is impossible.
however you could punish people for suicides

1
2
3
4
5
6
7
addhook("die","suicide")
function suicide(victim,killer,weapon)
	if (killer==0 and weapon==0) then
		msg(player(victim,"name").." has been punished for commiting suicide!")
		parse("kick "..victim)
	end
end

attention: I'm not sure if this will only be executed when you use /kill. maybe it will also happen in some other cases. maybe when killed by deadly tiles or dynamic walls. you would have to test that.
To the start Previous 1 2215 216 217338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview