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 223 24 25338 339 Next To the start

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
Another question: How can I check (using "If") if a player has a concrete weapon?
Blazzingxx, Player X has a snowball, and Player Y has only a knife. Player Y should only get a snowball by hitting WITH THE KNIFE from Player X, WHEN PLAYER X HAS A SNOWBALL. And when Player X and Player Y both DON'T HAVE a snowball, they shouldn't get one, or more. And your code was posted before.
edited 6×, last 03.07.09 06:36:37 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
So you want to make socer mothod.
Check this:
1
2
3
4
5
6
addhook("hit","hits")
function hits(id,source,weapon)
	if weapon==75 then
	parse("equip "..id.." 75")
end
end
edited 4×, last 03.07.09 06:09:25 pm

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
How to make a embarrasing lua script?

For example if you die in a server it should show a message "Shame on you!" and play sound to the player who died, lol.

Should it look like this?
1
2
3
4
5
addhook("kill","kill.event")
	 function kill.event(p, sv_sound2)
	 parse("sv_sound2 "..p.." sfx/fun/shame_on_you.ogg")
	 msg2(p, "©255255000Shame on you!@C")
end
Am I right or am I right?

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
Blazzingxx, I did what you said, and I came up to this:
http://i41.tinypic.com/2prhh83.png
2 balls= FAIL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("hit","snowball")
function snowball(id,source,weapon,hpdmg,apdmg)
          if (hpdmg > 0) then
               if(weapon==75) then
                    parse("strip "..source.." 75")
                    parse("equip "..id.." 75")
		    msg(""..player(id,"name").." has the ball")
               end
	       if(weapon==50) then
		    parse("strip "..id.." 75")
                    parse("equip "..source.." 75")
		    msg(""..player(source,"name").." has the ball")
	       end
          end
end
edited 1×, last 03.07.09 08:25:42 pm

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
wups has written
@kimkat

Why not test before you write about the code?
Well, why would I want to test such a simple script.
Also, I'm done with that already. Any opinions on that script?

@mat5b: You should strip yourself from that weapon Snowball if you successfully pass to a player. I just randomly came up with that idea.

For example:
1
2
3
4
5
6
addhook("hit","snowball")
function snowball(id,source,weapon,hpdmg,apdmg) 
if(weapon == 75) then
parse('strip '..source..' 75, "Snowball"')
parse('equip ..id.. 75')
end
Don't know how to use it correctly, but something like it.
edited 5×, last 04.07.09 08:18:50 am

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@mat5b
You just asked how to do that...
I just made method how to do that...
You just shoud strip "source" when you hit "id"
Strip snowball then player attack.
edited 2×, last 03.07.09 10:31:39 pm

old Re: Lua Scripts/Questions/Help

michaelrule4
User Off Offline

Quote
Could someone make me a script that changes maps after a team wins (No round draw) because i am trying to make a collaborated multi-minigame's map something like Lag Fun server's except you switch maps instead of teleport.

Once again if someone could make one of the above scripts it would be nice and could you please indicate where to put the map name by writing "mapnamehere".

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
michaelrule4 has written
Could someone make me a script that changes maps after a team wins (No round draw) because i am trying to make a collaborated multi-minigame's map something like Lag Fun server's except you switch maps instead of teleport.

Once again if someone could make one of the above scripts it would be nice and could you please indicate where to put the map name by writing "mapnamehere".
You can simply add a entity to your map which does it for you. The entity is called "Func_GameAction" place it anywhere on the map. Name the entity "loadmap" then set its action to "7 - Load Map X." X could be used by second or trigger, I've used it myself. In the X put (mapname), in trigger field write "loadmap_once" just to be sure that you're not missing anything lol.

You need to make a "trigger once"-entity name it "loadmap_once" make it trigger "loadmap" perhaps you need to add more gameactions.

Play around with it, until you get it right. Don't know how to manage that in lua though.

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
Blazzingxx has written
You just shoud strip "source" when you hit "id"
Strip snowball then player attack.

No, I've meant the 2 snowballs thing. It was for the second part of the code, I tried to make a "ball stealing" system (stealing with a knife), but when a player without a ball, hits a player without a ball, he gets a ball. AND IT SHOULDN'T BE SO.
@Blazzingxx: (the second post after that) Thanks for the script!
edited 1×, last 05.07.09 12:26:43 pm

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
mat5b has written
Blazzingxx has written
You just shoud strip "source" when you hit "id"
Strip snowball then player attack.

No, I've meant the 2 snowballs thing. It was for the second part of the code, I tried to make a "ball stealing" system (stealing with a knife), but when a player without a ball, hits a player without a ball, he gets a ball. AND IT SHOULDN'T BE SO.
I think it must check if player who your hitting on has a Snowball. And then return value true or false? not sure how to do that though, leegao made some examplary post some pages back.

I got some help from MiroslavR to make that check for

1
2
3
4
5
6
7
8
9
addhook("hit","steal_snowball")
function steal_snowball(id,source,weapon,hpdmg,apdmg) 
wpns = {75}
wpns = playerweapons(id)
if ("wpns" ==75) then
if (player(id, "name") == wpns[i]) then
parse("strip '..id..' 75") do
parse("equip '..source..' 75")
end
Not sure if the code works, but try.
edited 2×, last 04.07.09 03:13:26 pm

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
"playerweapons(playerid)"
Too check for weapons and a for loop to check the id for the weapon and return true or false.


This is what i come up with.
It sucks but the bot like to knife me over 9000 times in a row. And can't test it out'
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
ch=0


addhook("hit","ball1")
function ball1(p,s,w)
msg(s)
	if (w == 75) then
		parse("strip "..p.." 75")
		parse("equip "..s.." 75")
		msg(player(s,"name").." Have the ball ")
		return 1
	end
	if (w == 50) then
		if (wch(s,w) == 1) then
			parse("strip "..s.." 75")
			parse("equip "..p.." 75")
			msg(player(p,"name").." Have the ball!")
		end
		return 1
	end
end

addhook("walkover","ball2")
function ball2(p,ii,w)
	if (w == 75) then
		msg(player(p,"name").." Have the ball!")
	end
end

function wch(p,w)
ch=0
tb=playerweapons(p)
	for x=1,#tb do
		if (tb[x] == w) then
		ch = 1
		end
	end
return ch
end

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Thats for you @mat5b.
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
-- Football Characters Script by Blazzingxx

if lua==nil then lua={} end
lua.server={}

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

lua.server.type=initArray(32)
lua.server.ball=initArray(32)

function lua.server.classmenu(id)
	menu(id,"Select Your Type,Goal Keeper|(200 hp Speed 1.0),Defender|(140 hp Speed 1.1) ,Midfielder|(100 hp Speed 1.4),Striker|(80 hp Speed 1.5)")	
end

addhook("team","lua.server.team")
function lua.server.team(id,team)
	if (team>0) then
		lua.server.classmenu(id)
	end
end

addhook("menu","lua.server.menu")
function lua.server.menu(id,menu,sel)
	if (menu=="Select Your Type") then
		if (sel>=0 and sel<=6) then
			lua.server.type[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	end
end

addhook("spawn","lua.server.spawn")
function lua.server.spawn(id)
	if (lua.server.type[id]<=1) then
		parse ("setmaxhealth "..id.." 200")
		parse ("speedmod "..id.." 1")
		return "41";
	end
	if (lua.server.type[id]==2) then
		parse ("setmaxhealth "..id.." 140")
		parse ("speedmod "..id.." 5")
		return
	end
	if (lua.server.type[id]==3) then
		parse ("setmaxhealth "..id.." 100")
		parse ("speedmod "..id.." 10")
		return
	end
	if (lua.server.type[id]==4) then
		parse ("setmaxhealth "..id.." 80")
		parse ("speedmod "..id.." 15")
		return
	end
end

addhook("hit","lua.server.snowball") 
function lua.server.snowball(id,source,weapon,hpdmg,apdmg) 
	if (hpdmg > 0) then 
		if(weapon==75) then
			if lua.server.ball[source]==1 then
			lua.server.ball[source]=0
			lua.server.ball[id]=1
			parse("strip "..source.." 75") 
			parse("equip "..id.." 75") 
			msg(""..player(id,"name").." has the ball") 
			end
		end 
     		 if(weapon==50) then
			if lua.server.ball[id]==1 then
			lua.server.ball[id]=0
			lua.server.ball[source]=1
			parse("strip "..id.." 75")
			parse("equip "..source.." 75")
			msg(""..player(source,"name").." has the ball") 
			end
		end 
	end 
end

addhook("buy","lua.server.buy")
function lua.server.buy()
	return 1
end

addhook("walkover","lua.server.walkover")
function lua.server.walkover(id,iid,type)
	if type>=75 then
		lua.server.ball[id]=1
		return 0
	end
end
Thats working on your map
edited 2×, last 05.07.09 03:49:18 am

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
if (type>=75) then ? isn't that wrong?

You can trigger the snowball counter, if you walks over this items.
Quote
76 Air Strike
77 Mine
78 Claw
79 Light Armor
80 Armor
81 Heavy Armor
82 Media Armor
83 Super Armor
84 Stealth Suit
85 Chainsaw
86 Gut Bomb
87 Laser Mine
88 Portal Gun


The only thing that will be a problem, it will adds 10 snowballs when use "equip". That sucks :p

old Re: Lua Scripts/Questions/Help

younes
COMMUNITY BANNED Off Offline

Quote
i need help making a lua script to speed up upgrading and reparing,and if possible to directly build tripple turrets
i tryde smthin but it didnt work, could you help me with it (tell me whats wrong pls)
here's wher i got so far,i used fast build script::
original script:
1
2
3
4
5
6
7
8
9
addhook("build","no_site")
function no_site(id)
     return 1
end

addhook("build","no_sitenow")
function no_sitenow(id,type,x,y)
     parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
end

what i tryde:
1
2
3
4
5
6
7
8
9
addhook("build","no_upgrade")
function no_upgrade(id)
     return 1
end

addhook("build","no_upgradenow")
function no_sitenow(id,type,x,y)
     parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
end

all i did was changing the
1
no_site
bye
1
no_upgrade
and i'm so not shur that it works

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
You only need this one.

1
2
3
4
5
addhook("build","no_upgradenow")
function no_upgradenow(id,type,x,y)
parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
return 1
end

old Re: Lua Scripts/Questions/Help

younes
COMMUNITY BANNED Off Offline

Quote
@wups
Quote
You only need this one.
1
2
3
4
5
addhook("build","no_upgradenow")
function no_upgradenow(id,type,x,y)
parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
return 1
end
good idea but i tryed it and it didn't work, what it does is that instead of speeding the upgrades it instantly builds stuff for freeee!!and with no limitthats wierd coz it's supposed to only speed up the upgrade... anyways i still need help for making the no upgrade script

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
If anyone's been paying attention, if you were to return 1 on a hit event and instead artificially create the death of a player, then the Knifekill event of the sample quake mod would not work. This is because the weapon type id for a custom kill is always set at 250 (This is a possible bug). The workaround is to add the following in the kill hook

1
if weapon == 250 then weapon = player(killer, "weapontype") end

This will work with all weapons except for grenades.

Just in case anyone who is currently writing a rpg-mod that has level based custom damages, this is the workaround you will need to have weapon detection up and working again.
To the start Previous 1 223 24 25338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview