English Lua Scripts/Questions/Help

6,770 replies
Goto Page
To the start Previous 1 2 ... 239 240 241 ... 338 339 Next To the start
25.08.10 12:40:50 pm
Up
murilogc
User
Offline Off
@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
25.08.10 02:15:48 pm
Up
Loooser
User
Offline Off
how to make someone complete invisible?
IMG:http://i45.tinypic.com/saus1e.jpg
25.08.10 02:41:30 pm
Up
kalis
User
Offline Off
Code:
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!
Code:
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
25.08.10 03:12:22 pm
Up
Evool
User
Offline Off
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!
25.08.10 03:28:55 pm
Up
Fehu
User
Offline Off
@Evool:

Code:
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...
IMG:http://www.flashflashrevolution.com/profile/newsiggy/Fehu/stardust/0/0-1-2-3-4-5.png
25.08.10 05:16:48 pm
Up
murilogc
User
Offline Off
@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
25.08.10 05:29:28 pm
Up
Evool
User
Offline Off
Fehuziom has written:
@Evool:
     if (x==X POSITION) and (y==Y POSITION) then


One question- position of Door? or button??
25.08.10 05:41:11 pm
Up
Loooser
User
Offline Off
does someone know how to make players completly invisible?
IMG:http://i45.tinypic.com/saus1e.jpg
25.08.10 06:14:29 pm
Up
murilogc
User
Offline Off
@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
25.08.10 09:34:26 pm
Up
Fehu
User
Offline Off
Evool has written:
Fehuziom has written:
@Evool:
     if (x==X POSITION) and (y==Y POSITION) then


One question- position of Door? or button??

button...
IMG:http://www.flashflashrevolution.com/profile/newsiggy/Fehu/stardust/0/0-1-2-3-4-5.png
25.08.10 10:52:19 pm
Up
Soja1997
User
Offline Off
i have question to cs2d 0.1.1.8 i cant join server error i can't download map
26.08.10 01:03:58 am
Up
archmage
User
Offline Off
@Soja1997
This thread is not for that!
We must secure the existence of our people and a future for white children. 14/88
26.08.10 02:05:59 am
Up
3D
User
Offline Off
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!
26.08.10 06:34:55 am
Up
kalis
User
Offline Off
Code:
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!

Code:
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
26.08.10 07:26:22 am
Up
Mr_God
User
Offline Off
help me to fix script
it work but machete not ex

Code:
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
26.08.10 12:05:35 pm
Up
Tenaika
User
Offline Off
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:
Code:
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
Nothing to see here, move along.
26.08.10 12:09:22 pm
Up
Jermuk
User
Offline Off
nil value means nothing (0 is not nothing).
Try to put a message before everyline then you will see when the message appears.
26.08.10 12:15:27 pm
Up
Soja1997
User
Offline Off
i need script if i kill npc with trigger boss
open door with name boss
26.08.10 12:23:02 pm
Up
Jermuk
User
Offline Off
Soja1997 has written:
i need script if i kill npc with trigger boss
open door with name boss


What do you mean?
26.08.10 12:26:16 pm
Up
Vectarrio
User
Offline Off
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 2 ... 239 240 241 ... 338 339 Next To the start