English [Solved] Menu acting as radio button.

6 replies
Goto Page
To the start Previous 1 Next To the start
Up
Raaj Nadar
User
Offline Off
Hello guys!

Today i was scripting and got an idea i wanted a menu in which there will be 5 buttons and they will act as and radio button in a html code.

Means only one button can be enable at once.

I got some help from this!

http://www.unrealsoftware.de/forum_posts.php?post=371903

and this

http://www.cs2d.com/help.php?luacmd=menu#cmd

But still need a example code.
edited 1×, last 14.04.15 11:26:42 am
11.04.15 02:44:12 pm
Up
JeeewNazi
User
Offline Off
Dude sry i dont understand what u are talking about disabling a button is simple like a hell.

Edit :

Not tested also i am not sure if this is the script u need !
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
rad = {}


addhook("spawn","s")
function s(id)
rad[id]=1
menu(id,"Page,"..active(id,1).."|1,"..active(id,2).."|2")
end

function active(id,p)
     if rad[id]==p then
          return "Button(p)"

     else
          return "(Buttton("..p.."))"
     end
end

Here,rad is a table u may increase it with some specific hooks etc..
If rad is not equal to the button , that button will be disabled.
edited 3×, last 11.04.15 03:40:14 pm
12.04.15 10:16:48 am
Up
Raaj Nadar
User
Offline Off
Did you ever made a html radio buttton.

Like if you saw a registration form of anything there is gender which has two options male ans female we can only select one button at once.

Same like that i want a menu with 3 button and if a person uses 1st button it should be unclick able again until he selects 2nd or 3rd button.

@Ajmin I guess you'r code will work let me test and reply.
13.04.15 11:13:30 am
Up
JeeewNazi
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
rad = {}


addhook("spawn","s")
function s(id)
rad[id]=0
menu(id,"Page,"..active(id,1).."|1,"..active(id,2).."|2")
end

function active(id,p)
     if rad[id]==p then
          return "(Buttton("..p..")) "

     else
          return "Button(p)"
     end
end


This could work then!
13.04.15 01:00:00 pm
Up
Raaj Nadar
User
Offline Off
No did not worked!

Can a button be disable with a if situation like a made a level script a person who is above level 5 can access the 2 button.

As soon as he reach level 10 he can access 3rd button also and so on.
13.04.15 07:14:17 pm
Up
JeeewNazi
User
Offline Off
> A small edit of the first code fits the lvl system!
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
lvl = {}

addhook("spawn","s")
function s(id)
lvl[id]=2
menu(id,"Page,"..active(id,1).."|1,"..active(id,2).."|2,"..active(id,3).."|3")
end

function active(id,p)
     if lvl[id]>=p then
          return "Button(p)"

     else
          return "(Button("..p.."))"
     end
end




> This fits your radio like button!
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
rad = {}

addhook("serveraction","s")
function s(id,a)
if a==1 then
menu(id,"Page,"..active(id,1).."|1,"..active(id,2).."|2")
end
end

addhook("menu","mm")
function mm(id,t,b)
if t=="Page" then
if b<10 then
rad[id]=b
end
end
end

function active(id,p)
     if rad[id]~=p then
          return "Button(p)"

     else
          return "(Buttton("..p.."))"
     end
end


∗ Tested
14.04.15 11:25:45 am
Up
Raaj Nadar
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
rad = {}

addhook("serveraction","s")
function s(id,a)
if a==1 then
menu(id,"Page,"..active(id,1).."|1,"..active(id,2).."|2")
end
end

addhook("menu","mm")
function mm(id,t,b)
if t=="Page" then
if b<10 then
rad[id]=b
end
end
end

function active(id,p)
     if rad[id]~=p then
          return "Button(p)"

     else
          return "(Buttton("..p.."))"
     end
end


Yuho the code helped me now i just need to workout with this to comple my script and thanks @user JeeewNazi:
To the start Previous 1 Next To the start