Forum

> > CS2D > Scripts > [Solved] Menu acting as radio button.
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Solved] Menu acting as radio button.

6 replies
To the start Previous 1 Next To the start

old Re: [Solved] Menu acting as radio button.

Ajmin
User Off Offline

Quote
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 !
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

old Re: [Solved] Menu acting as radio button.

Raaj Nadar
User Off Offline

Quote
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.

old Re: [Solved] Menu acting as radio button.

Ajmin
User Off Offline

Quote
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!

old Re: [Solved] Menu acting as radio button.

Raaj Nadar
User Off Offline

Quote
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.

old Re: [Solved] Menu acting as radio button.

Ajmin
User Off Offline

Quote
> A small edit of the first code fits the lvl system!
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!
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

old Re: [Solved] Menu acting as radio button.

Raaj Nadar
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
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 Ajmin:
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview