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 2239 240 241338 339 Next To the start

old Re: Lua Scripts/Questions/Help

murilogc
User Off Offline

Quote
@beckerchen has written:
so you want that the player (if hes a medic / hotelowner ) gets telepotet to a point medics/hotelowners?
Then i need the xtile and the ytyle for the special places. MEDIC 456 346 HOTEL 784 235.


@beckerchen has written:
You Don't want a command !goshop ??


no , because have 6 shops , but shop owners , win 5k and one weapon if 5 , 5 min , and msg YOU WIN ONE WEAPON and shopowners , can drop armors , if txt !droparmor .




@beckerchen as written:
how long should a day go? ~5minutes?

YES

old Re: Lua Scripts/Questions/Help

kalis
User Off Offline

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

function load(id)
usgn = player(id,"usgn")
if (usgn > 0) then
local usgn = player(id,"usgn")
files = io.open("sys/lua/scelldata/"..usgn..".txt","r")
if(files~=nil) then
msg2(id,"©000255000Your save file found!@C")
msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
parse('hudtxt2 '..id..' 7 "©000255000Login as: '..usgn..'" 40 415')
for line in io.lines("sys/lua/scelldata/"..usgn..".txt","r") do
local parses = totable(line)
if (tonumber(parses[1])>0) then
yourmon[id] = tonumber(parses[1])
license[id] = tonumber(parses[2])
break
end
end
else
msg2(id,"©255000000Failed to load save!@C")
msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
end
end
end

addhook("leave","save")
function save(id)
if (player(id,"usgn") > 0) then
save_data = license[id].." "..yourmon[id]
file = assert(io.open("sys/lua/scelldata/"..usgn..".txt","w"))
file:write(save_data)
file:close()
msg2(id,'©000255001Save Data Successfull!@C')
else
msg2(id,"©255000000Failed to Save!@C")
end
it work but i go out
error : attempt to contatane global "usgn" (a nil value)
help!
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
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end

license = initArray(32)
posy = initArray(32)
posx = initArray(32)
collect = initArray(32)

addhook("leave","license_leave")
function license_leave(id)
license[id]=0
collect[id]=0
posy[id]=0
posx[id]=0
end

addhook("serveraction","license_action")
function license_action(id,b)
if license[id]==1 and b==2 then
menu(id,"License Menu,Set Pos,Teleport,Togle Spawn(0)")
elseif license[id]==0 and b==2 then
msg2(id,"You have license? buy type !buylicense ^^")
end
end

addhook("menu","license_menu")
function license_menu(id,title,button)
     if title=="License Menu" then
          if button==1 and player(id,"health")>0 then
               posx[id]=player(id,"x")
               posy[id]=player(id,"y")
               msg2(id,"©000255000Your saved spawnpoint is x:"..posx[id].." y:"..posy[id].." now!@C")
          elseif button==2 and posy[id]==0 and posx[id]==0 and player(id,"health")>0 then
               msg2(id,"©000255000 You don't have Position")
          else
               parse ("setpos "..id.." "..posx[id].." "..posy[id]) end
          elseif button==3 and collect[id]==0 and player(id,"health")>0 then
               msg2(id,"Collection ON")
               collect[id]=1
          elseif button==3 and collect[id]==1 and player(id,"health")>0 then
               msg2(id,"Collection OFF")
               collect[id]=0
          end
     end

addhook("walkover","license_collect")
function license_collect(id)
     if collect[id]==1 then
          return 1
     elseif collect[id]==0 then
          return 0
     end
end
i don't see Collect in menu

old Re: Lua Scripts/Questions/Help

Evool
User Off Offline

Quote
Evool has written
Hi guys! I want one lua script - door, which can open only players, when USGN i write in lua. Please help me!

Sorry for my bad english, i am polish.


Hey, help please!

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
@Evool:

1
2
3
4
5
6
7
8
9
addhook("usebutton","use")
function use(id,x,y)

	if (x==X POSITION) and (y==Y POSITION) then
		if player(id,"usgn")==USGN PLAYER then
			parse("trigger DOOR NAME")
		end
	end
end

I dont test this you must write only x and y position , usgn , and door name...

old Re: Lua Scripts/Questions/Help

murilogc
User Off Offline

Quote
@beckerchen has written:
so you want that the player (if hes a medic / hotelowner ) gets telepotet to a point medics/hotelowners?
Then i need the xtile and the ytyle for the special places. MEDIC 456 346 HOTEL 784 235.


@beckerchen has written:
You Don't want a command !goshop ??


no , because have 6 shops , but shop owners , win 5k and one weapon if 5 , 5 min , and msg YOU WIN ONE WEAPON and shopowners , can drop armors , if txt !droparmor .




@beckerchen as written:
how long should a day go? ~5minutes?

YES

old Re: Lua Scripts/Questions/Help

Evool
User Off Offline

Quote
Fehuziom has written
@Evool:
     if (x==X POSITION) and (y==Y POSITION) then


One question- position of Door? or button??

old Re: Lua Scripts/Questions/Help

murilogc
User Off Offline

Quote
@beckerchen has written:
so you want that the player (if hes a medic / hotelowner ) gets telepotet to a point medics/hotelowners?
Then i need the xtile and the ytyle for the special places. MEDIC 456 346 HOTEL 784 235.


@beckerchen has written:
You Don't want a command !goshop ??


no , because have 6 shops , but shop owners , win 5k and one weapon if 5 , 5 min , and msg YOU WIN ONE WEAPON and shopowners , can drop armors , if txt !droparmor .




@beckerchen as written:
how long should a day go? ~5minutes?

YES

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Evool has written
Fehuziom has written
@Evool:
     if (x==X POSITION) and (y==Y POSITION) then


One question- position of Door? or button??

button...

old OOOOOO Good

3D
User Off Offline

Quote
OOOOOO Good OOOOOO Good OOOOOO Good OOOOOO Good OOOOOO Good null

Admin/mod comment

this is pure pointless spam and a rule violation! don't repeat this or your account will be banned!

old Re: Lua Scripts/Questions/Help

kalis
User Off Offline

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

function load(id)
usgn = player(id,"usgn")
if (usgn > 0) then
local usgn = player(id,"usgn")
files = io.open("sys/lua/scelldata/"..usgn..".txt","r")
if(files~=nil) then
msg2(id,"©000255000Your save file found!@C")
msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
parse('hudtxt2 '..id..' 7 "©000255000Login as: '..usgn..'" 40 415')
for line in io.lines("sys/lua/scelldata/"..usgn..".txt","r") do
local parses = totable(line)
if (tonumber(parses[1])>0) then
yourmon[id] = tonumber(parses[1])
license[id] = tonumber(parses[2])
break
end
end
else
msg2(id,"©255000000Failed to load save!@C")
msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
end
end
end

addhook("leave","save")
function save(id)
if (player(id,"usgn") > 0) then
save_data = license[id].." "..yourmon[id]
file = assert(io.open("sys/lua/scelldata/"..usgn..".txt","w"))
file:write(save_data)
file:close()
msg2(id,'©000255001Save Data Successfull!@C')
else
msg2(id,"©255000000Failed to Save!@C")
end
it work but i go out
error : attempt to contatane global "usgn" (a nil value)
help!

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
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end

license = initArray(32)
posy = initArray(32)
posx = initArray(32)
collect = initArray(32)

addhook("leave","license_leave")
function license_leave(id)
license[id]=0
collect[id]=0
posy[id]=0
posx[id]=0
end

addhook("serveraction","license_action")
function license_action(id,b)
if license[id]==1 and b==2 then
menu(id,"License Menu,Set Pos,Teleport,Togle Spawn(0)")
elseif license[id]==0 and b==2 then
msg2(id,"You have license? buy type !buylicense ^^")
end
end

addhook("menu","license_menu")
function license_menu(id,title,button)
if title=="License Menu" then
if button==1 and player(id,"health")>0 then
posx[id]=player(id,"x")
posy[id]=player(id,"y")
msg2(id,"©000255000Your saved spawnpoint is x:"..posx[id].." y:"..posy[id].." now!@C")
elseif button==2 and posy[id]==0 and posx[id]==0 and player(id,"health")>0 then
msg2(id,"©000255000 You don't have Position")
else
parse ("setpos "..id.." "..posx[id].." "..posy[id]) end
elseif button==3 and collect[id]==0 and player(id,"health")>0 then
msg2(id,"Collection ON")
collect[id]=1
elseif button==3 and collect[id]==1 and player(id,"health")>0 then
msg2(id,"Collection OFF")
collect[id]=0
end
end

addhook("walkover","license_collect")
function license_collect(id)
if collect[id]==1 then
return 1
elseif collect[id]==0 then
return 0
end
end
i can get Togle spawn but not script not work
not msg collect on or collect off

old Re: Lua Scripts/Questions/Help

Mr_God
User Off Offline

Quote
help me to fix script
it work but machete not ex

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
exp_gas = 1
exp_size = 32
exp_damage = 100
exp_infsnow = 1
exp_snow_use = 1


function gotweapon(id,wep)
		weps=playerweapons(id)
			for i=1,#weps do
				if(weps[i]==wep) then
					return true
				end
			end
		return false
end


addhook("projectile","proj")
function proj(id,weapon,x,y)
	if(weapon==69 and exp_gas==1) then
		parse("explosion "..x.." "..y.." "..exp_size.." "..exp_damage.." "..id)
		if(exp_infsnow==1) then
			parse("equip "..id.." 69")
		end
		return 1
	end
end

addhook("use","snow_use")
function snow_use(id,event,data,x,y)
	if(exp_snow_use==1) then
		if(gotweapon(1,69)==false) then
			parse("equip "..id.." 69")
			msg2(id,"You got 10 Snowballs")
		else
			msg2(id,"You already have snowballs!")
		end
	end
end

old Re: Lua Scripts/Questions/Help

Tenaika
User Off Offline

Quote
Heeeeey, I am just a novice in Lua scripting, and I have a small problem with my script...
Every second, in console, a "Attempt to call nil value" appears. I can't find a way to fix it, halp pl0x?

Part of the script here:
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
if sample==nil then sample={} end
sample.sur={}

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

hunger=initArray(1000)
thirst=initArray(1000)
stamina=initArray(1000)
sample.sur.systemb=initArray(1000)
maxhunger = 500
lowesthunger = 0
maxthirst = 500
lowestthirst = 0
maxstamina = 500
loweststamina = 0

-------------------------------------------------------------------------

addhook("serveraction","action1")
addhook("menu", "menu1")
function action1(id,sact)
	if(sact == 1) then
		menu(id, "Menu, Eat, Drink, Sleep")
	end
end

function menu1(id, title, button)
	if (title=="Menu") then
		if(button==1) then
			hunger[id]=hunger[id]+100
		end
		if(button==2) then
			thirst[id]=thirst[id]+100
		end
		if(button==3) then
			stamina[id]=stamina[id]+100
		end
	end
end

addhook("join","updatehud")
function updatehud(id)
	for id=1,32 do
		if player(id,"exists") then
			parse('hudtxt2 '..id..' 3 "©010255000Hunger:  '..hunger[id]..'" 17 350')
			parse('hudtxt2 '..id..' 2 "©000000235Thirst:  '..thirst[id]..'" 17 370')
			parse('hudtxt2 '..id..' 1 "©235000235Stamina:  '..stamina[id]..'" 17 390')
		end
	end
end

addhook("spawn","start")
function start(id)
	for id=1,32 do
		if player(id,"exists") then
			hunger[id]=hunger[id]+500
			thirst[id]=thirst[id]+500
			stamina[id]=stamina[id]+500
			updatehud(id)
		end
	end
end

addhook("second","sample.sur.systemb")
function sample.sur.systemb()
	for id=1,32 do
		if player(id,"exists") then
			hunger[id]=hunger[id]-1
			thirst[id]=thirst[id]-1
			stamina[id]=stamina[id]-1
			updatehud(id)
		end
	updatehud(id)
	max(id)
	lowest(id)
	end
end

function max(id)
	if (hunger[id]>maxhunger) then
		hunger[id] = maxhunger
		updatehud(id)
	end
	if (thirst[id]>maxthirst) then
		thirst[id] = maxthirst
		updatehud(id)
	end
	if (stamina[id]>maxstamina) then
		stamina[id] = maxstamina
		updatehud(id)
	end
end

function lowest(id)
	if (hunger[id]<=lowesthunger) then
		hunger[id] = lowesthunger
		updatehud(id)
	end
	if (thirst[id]<=lowestthirst) then
		thirst[id] = lowestthirst
		updatehud(id)
	end
	if (stamina[id]<=loweststamina) then
		stamina[id] = loweststamina
		updatehud(id)
	end
end

old Re: Lua Scripts/Questions/Help

Jermuk
User Off Offline

Quote
nil value means nothing (0 is not nothing).
Try to put a message before everyline then you will see when the message appears.

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
Soja1997 has written
i need script if i kill npc with trigger boss
open door with name boss

use hook "objectkill" and hook "triggerentity", so, if it triggers NPC, (boss is created) it will have boss object id (#objects).
Now use objectkill, and if object id==boss id then parse("trigger \"nameofdynwall\"")
To the start Previous 1 2239 240 241338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview