Forum

> > CS2D > Scripts > Vote system
Forums overviewCS2D overview Scripts overviewLog in to reply

English Vote system

13 replies
To the start Previous 1 Next To the start

old Vote system

Suprise
BANNED Off Offline

Quote
When you press button F3 a menu ( ONLY IF PLAYER HAVE USGN! )
1
menu(id,"Server rating,Cool server|"..currentcool..",Boring server|"..currentboring.."")
(IF PLAYER NO HAVE USGN THEN MENU DOESNT WORK FOR HIM. )
So. Player 'vote' for cool or boring the server. And he cant vote again with his USGN. I think this need a folder (Voted players,etc)! And 'currentcool' will has +1 vote ! if vote boring then +1 boring vote.

Im sorry if you didnt understand me.
Thx in advance.

old Re: Vote system

Ridho
User Off Offline

Quote
i already tried and get an error, but not appear in console, here it is:
Spoiler >


sorry because i am newbie

old Re: Vote system

Suprise
BANNED Off Offline

Quote
user Ridho has written
i already tried and get an error, but not appear in console, here it is:
Spoiler >


sorry because i am newbie


Thx for the try.
Yes ur script is have error but idk what O.o

old Re: Vote system

Ridho
User Off Offline

Quote
Thx for the try.
Yes ur script is have error but idk what O.o

i think the error is at menu hook

old Re: Vote system

krabob
User Off Offline

Quote
user Ridho has written
Thx for the try.
Yes ur script is have error but idk what O.o

i think the error is at menu hook



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("menu","voting")
function voting(id,title,sel)
     if title == "Server rating" then
          if sel == 1 then
               if (player(id,"usgn")>0) and voted[id]==0 then
                    C[id]=1
                    msg(id,"©000255000"..player(id,"name").." Voted this server to Cool")
                    voted[id]=1
               elseif voted[id]==1 then
                    msg(id,"©255000000You already Voted this server!@C")
               end
          end
          if sel == 2 then
               if (player(id,"usgn")>0) and voted[id]==0 then
                    B[id]=1
                    msg(id,"©255000000"..player(id,"name").." Voted this server to Bored")
                    voted[id]=1
               elseif voted[id]==1 then
                    msg2(id,"©255000000You already Voted this server!@C")
               end
          end
     end
end

Replace the menu function with this one.

Wrong use of parameter by ridho

old Re: Vote system

krabob
User Off Offline

Quote
Yea, some other parts are broken in the script too, but I cba to do that shit

old Re: Vote system

Ridho
User Off Offline

Quote
maybe like this??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("menu","voting")
function voting(id,title,button)
     if title == "Server rating" then
          if button==1 then
               if (player(id,"usgn")>0) and voted[id]==0 then
                    C[id]=1
                    msg(id,"©000255000"..player(id,"name").." Voted this server to Cool")
                    voted[id]=1
               elseif voted[id]==1 then
                    msg(id,"©255000000You already Voted this server!@C")
               end
          end
          elseif button==2 then
               if (player(id,"usgn")>0) and voted[id]==0 then
                    B[id]=1
                    msg(id,"©255000000"..player(id,"name").." Voted this server to Bored")
                    voted[id]=1
               elseif voted[id]==1 then
                    msg2(id,"©255000000You already Voted this server!@C")
               end
          end
     end
end

i hope it work

old Re: Vote system

EngiN33R
Moderator 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
voted = {}
currentcool = 0
currentboring = 0

addhook("serveraction","votemenu")
function votemenu(id,a)
	if a==2 then
		if player(id,"usgn")>0 then
			menu(id,"Server rating,Cool|"..currentcool..",Boring|"..currentboring)
		else
			msg2(id,"Sorry, you're not logged into USGN!")
		end
	end
end

addhook("menu","voting")
function voting(id,menu,sel)
	if menu=="Server rating" then
		if player(id,"usgn")>0 then
			if not voted[id] then
				if sel==1 then
					currentcool=currentcool+1
					msg2(id,"You've voted for 'Cool'. Thank you for your vote!")
				end
				if sel==2 then
					currentboring=currentboring+1
					msg2(id,"You've voted for 'Boring'. Thank you for your vote!")
				end
				voted[id]=true
			else
				msg2(id,"Sorry, you've already voted!")
			end
		else
			msg2(id,"Sorry, you're not logged into USGN!")
		end
	end
end

This should work.

old Re: Vote system

EngiN33R
Moderator Off Offline

Quote
It doesn't change the map, it's a script that makes players able to assess the quality of the server - if it's 'cool' or 'boring'. It's not a map voting system.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview