English Lua Scripts/Questions/Help

6,770 replies
Goto Page
To the start Previous 1 2 ... 141 142 143 ... 338 339 Next To the start
21.01.10 12:30:11 am
Up
Homer
User
Offline Off
Eh, How do you add a value to a table?
I detest that man who hides one thing in the depths of his heart, and speaks for another.
21.01.10 01:18:10 am
Up
Flacko
User
Offline Off
You can use table.insert to add a value into a table with a new index or you can use t[n] = v
Where t is your table, n is your index or key and v is your value.
21.01.10 01:36:57 am
Up
Zanahoria
User
Offline Off
Help me!
I want to select the five-seven laser is created.
Everything was fine with Usp (1) but the change (6) no longer works. What do I wrong?

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
laser=initArray(32)
laser01=initArray(32)

addhook("select","laserz")
function laserz(id,type,mode)
     if type == 6 then
          if (laser01[type] == 6) then
               laser01[type]=0
               freeimage(laser[type])
          else 
               laser01[type]=6
               laser[type]=image("gfx/!Huevitorojo Sprites/laser.png",1,1,200+type)
               imageblend(laser[type],1)
               imagecolor(laser[type],255,0,0)
               imagealpha(laser[type],0.7)
          end
          return 1
     end
end
21.01.10 02:10:07 am
Up
wups
User
Offline Off
Zanahoria has written:
Help me!
I want to select the five-seven laser is created.
Everything was fine with Usp (1) but the change (6) no longer works. What do I wrong?


Why do you use [type] instead of id?
If you add players it will always give the player with id "type" the laser.

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

laser=initArray(32)
laser01=initArray(32)

addhook("select","laserz")
function laserz(id,t,mode)
     if t == 1 then
          if (laser01[id] == 1) then
               laser01[id]=0
               freeimage(laser[id])
          else
               laser01[id]=1
               laser[id]=image("gfx/!Huevitorojo Sprites/laser.png",1,1,200+id)
               imageblend(laser[id],1)
               imagecolor(laser[id],255,0,0)
               imagealpha(laser[id],0.7)
          end
    else 
     -- If not selected the right weapon, Remove the laser.
          laser01[id]=0
          freeimage(laser[id])
     end
end


Something is wrong with the tabs, i don't know why.
Looks good in notepad++...
edited 1×, last 21.01.10 02:20:09 am
21.01.10 02:30:22 am
Up
Zanahoria
User
Offline Off
THX MEN! U R THE BEST!
1)if I do it with another weapon, I do another?
2) i want make this with F3 and not F2
Spoiler >
21.01.10 03:47:59 am
Up
Homer
User
Offline Off
How would someone use the table.insert function, Could you give a example pls?
I detest that man who hides one thing in the depths of his heart, and speaks for another.
21.01.10 04:24:29 am
Up
Flacko
User
Offline Off
Code:
1
2
3
4
5
6
7
8
t = {12,"hi"}
print(t[3])
-->Output: Nil

t = {12,"hi"}
table.insert(t,"hello")
print(t[3])
-->Output: hello
21.01.10 11:44:21 am
Up
wups
User
Offline Off
How do i script this thing the best way too make more of them? And i'm really newbie with arrays, and how i should create it too work best without lag and things.

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
x = 0
addhook("say","discot")
function discot(p,t)

     if t == "disco" then

          test = image("gfx/sprites/flare1.bmp", player(p,"x"), player(p,"y"),1)
          testx = player(p,"x")
          testy = player(p,"y")
          imageblend(test,1)
          imagescale(test,2,2)
     end
end

addhook("ms100","sec")
function sec()
     if test ~= nil then
          x = x + 30
          rand = math.random(1,3)
          if x < 360 then
               imagepos(test,testx,testy,x)
               imagecolor(test,x+80,x*2,x-100)
               imagescale(test,rand,rand)
          else
               x = 0
               imagepos(test,testx,testy,x)
          end
     end
end
21.01.10 03:03:06 pm
Up
TicTac
BANNED
Offline Off
Help me .. it shows me a error how fix this?


I just want make reload script sounds but dont know how fix it
Code:
1
2
3
4
5
6
7
8
9
10
11
12
--hooks
addhook("reload","op4_rw")

--funcs

function op4_rw(id,mode)
     if (mode==1) then
          if (player(id,"weapontype")==30) then
               parse("sv_sound2 "..id.." \"lolwtf/ak47rld.wav\"")
          elseif (player(id,"weapontype")==32) then
               parse("sv_sound2 "..id.." \"lolwtf/m4a1rld.wav\"")
               end
^.^ all
21.01.10 03:18:56 pm
Up
Starkkz
Moderator
Offline Off
TicTac has written:
Help me .. it shows me a error how fix this?


I just want make reload script sounds but dont know how fix it
Code:
1
2
3
4
5
6
7
8
9
10
11
12
--hooks
addhook("reload","op4_rw")

--funcs

function op4_rw(id,mode)
     if (mode==1) then
          if (player(id,"weapontype")==30) then
               parse("sv_sound2 "..id.." \"lolwtf/ak47rld.wav\"")
          elseif (player(id,"weapontype")==32) then
               parse("sv_sound2 "..id.." \"lolwtf/m4a1rld.wav\"")
               end


Code:
1
2
3
4
5
6
7
8
9
addhook("reload","op4_rw")
function op4_rw(id,m)
wpn = player(id,"weapontype")
     if (wpn==30) then
          parse("sv_sound2 "..id.." \"lolwtf/ak47rld.wav\"")
     elseif (wpn==32) then
          parse("sv_sound2 "..id.." \"lolwtf/m4a1rld.wav\"")
     end
end
lol
21.01.10 03:36:58 pm
Up
TicTac
BANNED
Offline Off
@Starkkz hehe thanx!!
^.^ all
21.01.10 07:09:28 pm
Up
Zanahoria
User
Offline Off
I want change the server action 1(F2) by serveraction 2(F3]
What i need to change?
Spoiler >
21.01.10 07:12:59 pm
Up
SQ
Moderator
Online On
Change
Code:
1
if p == 1 then

With this
Code:
1
if p == 2 then


You should use right function parameters... You switched them.
Quote:
serveraction(id,action)     
21.01.10 07:23:56 pm
Up
Zanahoria
User
Offline Off
But when i changed it before, it doent work!
21.01.10 07:31:02 pm
Up
SQ
Moderator
Online On
I already said the problem, everything works if it's fixed.

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

light01=initArray(32)
light=initArray(32)

addhook("serveraction","menuss")
function menuss(id,button)
     if button == 2 then
          if (light01[id] == 1) then
               light01[id]=0
               freeimage(light[id])
          else
               light01[id]=1
               light[id]=image("gfx/!Huevitorojo Sprites/linterna.png",1,1,200+id)
               imageblend(light[id],1)
               imagecolor(light[id],200,200,100)
               imagealpha(light[id],0.7)
          end
     end
end
21.01.10 07:31:34 pm
Up
Redefinder
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Explosive --
        if (sample.zombie.class[id]==6) then
                if (player(id,"team")==1) then
                        parse ("setmaxhealth "..id.." 120")
                        parse ("speedmod "..id.." -4")
                        parse ("equip "..id.." 51")
                        msg2(id,"©255000000Class:Explosive")
                     sample.zombie.teleports[id]=0    
                end
        end
     function explosion(x, y, size, damage)
          parse("explosion "..x.." "..y.." "..size.." "..damage)
     end
     addhook("die","explode")
     function explode(id,x,y)
          if (sample.zombie.class[id]==6) then
          explosion(x,y,300, 300)
          end
     end

This is supposed to make an explosion on the place where the player is killed,but instead it makes an explosion on a specific place of the map.
21.01.10 07:34:10 pm
Up
Zanahoria
User
Offline Off
THX Blazzingxx!
But what was the little problem?
21.01.10 07:45:15 pm
Up
SQ
Moderator
Online On
Blazzingxx has written:
You should use right function parameters... You switched them

Again, you switched player ID and button parameters.

So in your script button was player id.
And player ID was button.
21.01.10 07:59:48 pm
Up
Redefinder
User
Offline Off
redefinder has written:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Explosive --
if (sample.zombie.class[id]==6) then
if (player(id,"team")==1) then
parse ("setmaxhealth "..id.." 120")
parse ("speedmod "..id.." -4")
parse ("equip "..id.." 51")
msg2(id,"©255000000Class:Explosive")
      sample.zombie.teleports[id]=0
end
end
     function explosion(x, y, size, damage)
     parse("explosion "..x.." "..y.." "..size.." "..damage)
     end
     addhook("die","explode")
     function explode(id,x,y)
          if (sample.zombie.class[id]==6) then
          explosion(x,y,300, 300)
          end
     end

This is supposed to make an explosion on the place where the player is killed,but instead it makes an explosion on a specific place of the map.

someone help me plz
21.01.10 08:02:23 pm
Up
Zanahoria
User
Offline Off
ok!I always can trust you
To the start Previous 1 2 ... 141 142 143 ... 338 339 Next To the start