Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2173 174 175338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
Umm, I got a question about triggers and about detecting a players weapons.
1: With a trigger, could you use the for i=1,32 do for it?
2: I am trying to strip a primary weapon or secondary weapon if they have one, and equip another one, Can I see the type of weapons they have?

alt Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Zitieren
Use 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
function addWeapon(id,wpnid, type)
	local haswpn
	for i, v in ipairs(playerweapons(id)) do
		if type == 1 then
			for j, k in ipairs{10,11,20,21,22,23,24,38,39,30,32,31,33,34,35,36,37,40} do
				if v == k then
					parse('strip '..id..' '..v)
					haswpn = true
					break
				end
			end
		else
			for j, k in ipairs{1,2,3,4,5,6} do
				if v == k then
					parse('strip '..id..' '..v)
					haswpn = true
					break
				end
			end
		end
		if haswpn then parse('equip '..wpnid) return true end
	end
	return false
end
Use the function addWeapon(id,wpnid,1 for primary or 2 for secondary) to add a weapon to the player.
3× editiert, zuletzt 12.03.10 12:03:07

alt Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Zitieren
Blazzingxx hat geschrieben
DRoNe hat geschrieben
1
msg([b]"©255000000'[/b]..player(id,"name")..[b]' is noob!"[/b])

If you are starting string with " then you should finish the same.
√ 'string'
√ "string"
× 'string"
× "string'


It's very useful for me, thank you

alt Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Zitieren
I'm having trouble with the color-coding in HUD. Instead of changing the color of my text, it adds "©255000000" in front of the text.

I think it might have to do with the character encoding I use in my lua scripts, but changing doesn't seem to help.

alt Re: Lua Scripts/Questions/Help

Dictatus Papae
User Off Offline

Zitieren
Can someone please tell me how to make a spawn script as in the cc rp, so when a player joins he can only join Ts and if he tries to be CT he will spawn as a T. If the player's logged in as an admin, he can join bofe teams, but if not, he wil always spawn as a T.

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Zitieren
Noxic hat geschrieben
I'm having trouble with the color-coding in HUD. Instead of changing the color of my text, it adds "©255000000" in front of the text.

I think it might have to do with the character encoding I use in my lua scripts, but changing doesn't seem to help.

The '©#' MUST be first before any other characters

alt Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Zitieren
@Terminator
I'm not sure if there's any method to force the player to join the T team, but this will just not allow them to choose a CT.
1
2
3
4
5
6
addhook('team','onSelectTeam')
function onSelectTeam(id, team, look)
	if team == 2 then
		return 1
	end
end

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
DRoNe hat geschrieben
Zitat
put the entities ct_info near the t_info


OMG...........i mean in lua


OMG, that not possible and OMG you need to setpos

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Some funny stuff written by me...
Few basics misc from CSH objects script.

Note: shoot/attack to see the effect.

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
-- Projectiles Stuff Example --
-- Lua Scripting Tutorial Example
-- Not Finshed --

obj = {x = {}, y = {}, rot = {}, img = {}, id = {}}

addhook("always","obj_update")
addhook("attack","obj_add")

function obj_remove(id)
	local k, v
	if obj.img[id] then freeimage(obj.img[id]) end
	for k, v in pairs(obj) do table.remove(obj[k], id) end
end

function obj_add(p)
	local x , y, rot , id = player(p,"x"), player(p,"y"), player(p,"rot")
	id = image("gfx/sprites/flare2.bmp",x,y,1)
	imageblend(id, 1)
	table.insert(obj.img, id)
	table.insert(obj.x, x)
	table.insert(obj.y, y)
	table.insert(obj.id, p)
	table.insert(obj.rot, rot)
end

function obj_update()
	local del, id, n = {}
	for id, n in pairs(obj.img) do
		obj.x[id] = obj.x[id] + math.cos(math.rad(obj.rot[id] - 90)) * 10
		obj.y[id] = obj.y[id] + math.sin(math.rad(obj.rot[id] - 90)) * 10
		imagepos(n, obj.x[id], obj.y[id], obj.rot[id])
		if tile( math.ceil(obj.x[id] / 32) - 1, math.ceil(obj.y[id] / 32) - 1, "wall") then
			parse("explosion "..obj.x[id].." "..obj.y[id].." 50 250 "..obj.id[id])
			table.insert(del, id)
		end
	end
	for id, n in ipairs(del) do obj_remove(n) end
end

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Okay, I added some explanations...
Spoiler >

alt Re: Lua Scripts/Questions/Help

Dictatus Papae
User Off Offline

Zitieren
Can anyone tell me how to make a credit system that has no limit and shows it on the players screen. Also, if anyone knowas, how can I add the function to it (it's possible, already saw it on servers) , for example if aplayer collects money ($500), then it will add 500 to the normal money, but then take 500 away again (so it will be 0), but add 500 to the credits.

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Zitieren
Terminator T02 hat geschrieben
Can anyone tell me how to make a credit system that has no limit and shows it on the players screen. Also, if anyone knowas, how can I add the function to it (it's possible, already saw it on servers) , for example if aplayer collects money ($500), then it will add 500 to the normal money, but then take 500 away again (so it will be 0), but add 500 to the credits.

are you saying they should be able to have unlimited money?

alt Re: Lua Scripts/Questions/Help

Dictatus Papae
User Off Offline

Zitieren
I have an error in this script, and I don't know this one, and I don't know what it means. The error is:
1
LUA ERROR:sys/lua/samples/Bounty_Hunter_DEMO.lua:61:attemp to index field 'mainmenu' (a function value)
.

I also have a VERY serious problem, what I can't even guess why it happens. The problem is that when I press key 1 (F2), the whole game closes. I hope someone knows how to solve it.

The script is unfinished, but I don't care, I just want to solve the problems.

The code is:
Spoiler >

Sorry, but the site put the ends in straight colums, otherwise it wouldn't be like that.

CmDark hat geschrieben
Haha....
Terminator T02 is trying to recreate
[CC] RP Server's
lua scripts


No, I just think that it's a standard thing for all rps, I'm going to make mine completely different.
2× editiert, zuletzt 14.03.10 03:32:06
Zum Anfang Vorherige 1 2173 174 175338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht