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 2227 228 229338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Zitieren
The Camo hat geschrieben
Um, I'm new in scripting, and I need to know something,

I know I can add color in the first line in this:

1
msg ([[[["©000000255"]]]].."1".."2")

But can I add another color here too:

1
msg ([[[["©000000255"]]]].."1"..[[[["©000255000"]]]].."2")

Or is there any other way to do it? (because when i do like in second code it shows text: 1"©000255000"2 )


no you can't create multi color msgs.
cs2d don't support that.

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
i need an command if you write !givelicense ID
The ID gets license[id]=1
and if the command is !removelicense ID
the ID gets license[id]=0

alt Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Zitieren
If i add it lua to server, there is not lua error, but i not spawn with armor, claw and 80hp. how to fix it?

1
2
3
4
5
6
7
8
9
10
11
12
addhook("spwan","spawn")
function spawn(id)
	parse("equip "..id.." 78")
	parse("setmaxhealth "..id.." 80")
	parse("setarmor "..id.." 204")
end

function spawn(p)
	parse("strip "..p.." 2")
	parse("strip "..p.." 1")
	parse("strip "..p.." 50")
end

alt Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Zitieren
vesa-omar hat geschrieben
i need an command if you write !givelicense ID
The ID gets license[id]=1
and if the command is !removelicense ID
the ID gets license[id]=0


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
function string.split(t, b)
	local cmd = {}
	local match = "[^%s]+"
	if b then
		match = "%w+"
	end
	if type(b) == "string" then match = "[^"..b.."]+" end
	if not t then return invalid() end
	for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end
	return cmd
end

function initArray(n,v)
	mt = {}	
	for i = 1,n do	mt[i] = v end	
	return mt
end

license = initArray(0)

addhook("say","my_say")
function my_say(id,txt)
	tab = string.split(txt,' ')
	cmd = tab[1]
	id_s = tab[2]
	
	if(cmd == "!givelicense") then
		license[id_s] = 1
	end	
	
	else if cmd == "removelicense" then
		license[id_s] = 0
	end
end

alt Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Zitieren
MSek hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
12
addhook("spawn","spawn")
function spawn(id)
	parse("equip "..id.." 78")
	parse("setmaxhealth "..id.." 80")
	parse("setarmor "..id.." 204")
end

function spawn(p)
	parse("strip "..p.." 2")
	parse("strip "..p.." 1")
	parse("strip "..p.." 50")
end
You wrote spwan at the addhook

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
MSek hat geschrieben
If i add it lua to server, there is not lua error, but i not spawn with armor, claw and 80hp. how to fix it?

1
2
3
4
5
6
7
8
9
10
11
12
addhook("spawn","spawn")
function spawn(id)
     parse("equip "..id.." 78")
     parse("setmaxhealth "..id.." 80")
     parse("setarmor "..id.." 204")
end

function spawn(p)
     parse("strip "..p.." 2")
     parse("strip "..p.." 1")
     parse("strip "..p.." 50")
end

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("spawn","_spawn")
function _spawn(id)
	parse("equip "..id.." 78")
	parse("setmaxhealth "..id.." 80")
	parse("setarmor "..id.." 204")
end

addhook("endround","_spawn_end")
function _spawn_end(p)
	parse("strip "..p.." 2")
	parse("strip "..p.." 1")
	parse("strip "..p.." 50")
end

you spelled spawn wrong you spelled it spwan and you cant use the same function twice, and you cant have the same name as the hook

alt Help!

waguininho100
User Off Offline

Zitieren
I'm needing help on a script.

It serves to carry someone to tele Celly, Cellx.

Example: Ct must capture the terror.

But I do not know how to configure changes and not know who holds the team and who has to be pressed.

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Code:

Catch_Type = 1	-- How to catch prisoners?
				--[[
					1	-	Default	(Set prisoner's position to CellX, CellY)
					2	-	make prisoner follow capturer + remove weapons
					3	-	"Paralyze" them	+ remove weapons
				--]]

function array (l, v)
	local a = {};l=l or 1; v = v or 0
	for i = 1, l do
		a[i] = v
	end
	return a
end

cap = array(32, 0)

if ( Catch_Type == 1 ) then
	if ( io.open("maps/"..map("name").."_cell.txt") ) then
		dofile("maps/"..map("name").."_cell.txt")
	else
		error("Can not find \"maps/"..map("name")..".txt\" script ended.")
	end
end
if ( type(CELLx) == "number" ) then
	CELLx = {CELLx}
end
if ( type(CELLy) == "number" ) then
	CELLy = {CELLy}
end

math.randomseed(os.time()/os.clock())

pris_trapWPN = {78} 	-- this is the table for weapons that allowed for captures seperate with a comma
pris_trapTeam = {1, 2}  -- these are the teams allowed to capture people seperate with comma


addhook("walkover", "pris_wo")
addhook("hit", "pris_hit")
addhook("move", "pris_move")

function pris_wo (i, item)
	 for aw = 1, #pris_trapWPN do
		  if ( item == pris_trapWPN[aw] ) then
			   for at = 1, #pris_trapTeam do
					if ( player(i, "team") == pris_trapTeam[at] ) then
						 return 0
					else
						 return 1
					end
			   end
		  else
			   return 0
		  end
	 end
end

function pris_hit (id, s, wpn, hd, ad)
	 local wpt = false
	 for i = 1, #pris_trapWPN do
		if ( wpn == pris_trapWPN[i] ) then
			wpt = true
			hd = 0; ad = 0
		else
			wpt = false
		end
	end
	if ( cap[id] > 0 ) then
		hd = 0; ad = 0
	end
	 for i = 1, #pris_trapTeam do
		  if ( wpt and player(s, "team") == pris_trapTeam[i] ) then
			   if ( player(s, "team") ~= player(id, "team") ) then
					if ( Catch_Type == 1 ) then
						parse("setpos "..id.." "..(CELLx[math.random(1,#CELLx)]*32).." "..(CELLy[math.random(1,#CELLy)]*32))
						msg(player(id, "name").." has been captured by "..player(s, "name"))
						parse("sethealth "..id.." "..player(id, "maxhealth"))
					elseif ( Catch_Type == 2 ) then
						if ( cap[id] == 0 ) then
							cap[id] = s; parse("speedmod "..id.." -100")
							parse("strip "..id)
							parse("equip "..id.." 78")
							parse("strip "..id.." 51")
						else
							cap[id] = 0; parse("speedmod "..id.." 0")
						end
					elseif ( Catch_Type == 3 ) then
						if ( player(id, "speedmod") > -100 ) then
							parse("speedmod "..id.." -100")
							parse("strip "..id)
							parse("equip "..id.." 78")
							parse("strip "..id.." 51")
						else
							parse("speedmod "..id.." 0")
						end
					end	
			   else
					msg2(s, player(id, "name").." is on your team. Can not capture.")
			   end
		  end
	 end
	 parse("sethealth "..id.." "..(player(id, "health")-hd))
	 parse("setarmor "..id.." "..(player(id, "armor")-ad))
	 return 1
end

function pris_move (id,x,y,walk)
	for i = 1, 32 do
		if cap[i] > 0 then
			if walk then
				parse("setpos "..i.." "..player(cap[i], "x").." "..player(cap[i], "y"))
			else
				msg2(cap[i], "You must walk (use shift key) with prisoners or they will escape!")
				cap[i] = 0
			end
		end
	end
end

alt Re: Lua Scripts/Questions/Help

KaBooMa
User Off Offline

Zitieren
alright so im making a rp. i wanted to make it new..ya know...so you dont have to have a ct to buy the stores...all so good till i got to this error. the player types !m for the menu for shops..they click the store they wanna buy and if they got 10k they get it....alright so they got a store and now another player trys to buy it...it dont work because i got it scripted to see if S1ID = ""...well ok so its all good but then the owner leaves...well S1ID still isnt "" ( also i make S1ID the playername ) how would i go about making S1ID = "" if player left? thanks for all help i get?

alt Re: Lua Scripts/Questions/Help

Slayer
User Off Offline

Zitieren
CmDark hat geschrieben
wow where did all the new imports come from

I'm working on a project nicknamed "cmmod"
I need some suggestions anyone?
Can't really think of anything to add to my mod..

@slayer
1
2
3
4
5
6
7
addhook('say','saymod')
admtable={usgnid}
function saymod(p, t)
if admtable[player(p,'usgn')] then
msg('©000150000'..player(p,'name')..' (Admin): '..t)
end
end

you do the rest


Tnx!

alt Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Zitieren
Another question I am asking you guys !

Is it possible to script such a lua.

E.g. You are dead
You say !revive,!revival etc...
And you spawn in your spawn point...
And lose 8000$

I am not asking to script one just tell me is it posible !?

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
batlaizys hat geschrieben
Another question I am asking you guys !

Is it possible to script such a lua.

E.g. You are dead
You say !revive,!revival etc...
And you spawn in your spawn point...
And lose 8000$

I am not asking to script one just tell me is it posible !?


yes its possible i think

alt Revival

Rainoth
Moderator Off Offline

Zitieren
What hook or command is to spawn player in his spawn point ?

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Fapicon, no, you can't

batlaizys: You have to loop through all the map and get the spawn points so you can use parse("spawnplayer "..id.." "..x.." "..y) on that location.

alt Revival

Rainoth
Moderator Off Offline

Zitieren
@flacko Do i have to find tile places or pixels ? If pixels then how i find them ?

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
info.txt hat geschrieben
- entity(tileX,tileY,"value")     Return a value of an entity:
                    exists, typename, type, name,


You loop through all the map and you pass X and Y tiles to that function until you find the right typename (spawn_t and spawn_ct for each team)

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
batlaizys hat geschrieben
@flacko Do i have to find tile places or pixels ? If pixels then how i find them ?


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
addhook("say","revival_ct")
function revival_ct(id,txt)
	if (player(id,"team") == 2) and txt=="!revival" then
		if (player(id,"money")>7999) then
			msg2(id,"You spawned your self")
			parse("spawnplayer "..id.." X Y")
			parse("setmoney "..id.." "..player(id,"money") - 8000)
		else
			msg2(id,"You dont have enough money")
		end
	end
end

addhook("say","revival_tt")
function revival_tt(id,txt)
	if (player(id,"team") == 1) and txt=="!revival" then
		if (player(id,"money")>7999) then
			msg2(id,"You spawned your self")
			parse("spawnplayer "..id.." X Y")
			parse("setmoney "..id.." "..player(id,"money") - 8000)
		else
			msg2(id,"You dont have enough money")
		end
	end
end
It should look like that,
X and Y can be found in the Map Editor, Just press the distance
2× editiert, zuletzt 31.07.10 16:10:14

alt help with lua script

J4x
User Off Offline

Zitieren
hi guys i need help here, i need a script that make bots change to knife and i find the podbots script but it have a lot of bugs , can someone help me with this?
2× editiert, zuletzt 31.07.10 17:58:42

alt Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Zitieren
@vesa-omar Thanks,but there are like 5 spawnpoints.
If there would be 1 revival spawnpoint enemies would camp and wait till all revive in that place...
Zum Anfang Vorherige 1 2227 228 229338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht