crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
If there is a single vote for one, and a single vote for six, then it will always choose one, because it wouldnt even think of six. What i'm asking for is to make this current part of the voting system NOT Biased. Thanks.
one = script.Parent.Votes.One.Value
two = script.Parent.Votes.Two.Value
three = script.Parent.Votes.Three.Value
four = script.Parent.Votes.Four.Value
five = script.Parent.Votes.Five.Value
six = script.Parent.Votes.Six.Value
if math.max(one,two,three,four,five,six)==one then
marp = 1
elseif math.max(one,two,three,four,five,six)==two then
marp = 2
elseif math.max(one,two,three,four,five,six)==three then
marp = 3
elseif math.max(one,two,three,four,five,six)==four then
marp = 4
elseif math.max(one,two,three,four,five,six)==five then
marp = 5
elseif math.max(one,two,three,four,five,six)==six then
marp = 6
elseif math.max(one,two,three,four,five,six)==0 then
marp = math.random(1,6)
end |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Bump |
|
mammed22Join Date: 2011-10-14 Post Count: 1501 |
OMG CRAZYBLOX FIRST POST |
|
mammed22Join Date: 2011-10-14 Post Count: 1501 |
Oh and I dont know how to script much sooooo.... |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Bump |
|
TLuaJoin Date: 2010-07-26 Post Count: 42 |
So um, check if both the numbers are the same? |
|
noobkidJoin Date: 2007-09-17 Post Count: 649 |
Uglyhax...
Just use;
Marp = math.max(..) |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Noobkid, you read my thread wrong.
I want it to return the number/map with the most votes, not the value of the map/number with the most votes. |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
I'm not sure but try putting this in a table like so.
one = script.Parent.Votes.One.Value
two = script.Parent.Votes.Two.Value
three = script.Parent.Votes.Three.Value
four = script.Parent.Votes.Four.Value
five = script.Parent.Votes.Five.Value
six = script.Parent.Votes.Six.Value
Vote1 = {
if math.max(one,two,three,four,five,six)==one then
marp = 1
}
if math.max(Vote1, Vote2)==Vote1 then
etc.
i have never heard of math.max but hope this helped =P |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
Oh I meant put his after the end ok?
Hope I helped =P |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
You know what, Try this.
one = script.Parent.Votes.One.Value
two = script.Parent.Votes.Two.Value
three = script.Parent.Votes.Three.Value
four = script.Parent.Votes.Four.Value
five = script.Parent.Votes.Five.Value
six = script.Parent.Votes.Six.Value
if math.max(one,two,three,four,five,six)==one then
marp = 1
elseif math.max(one,two,three,four,five,six)==two then
marp = 2
elseif math.max(one,two,three,four,five,six)==three then
marp = 3
elseif math.max(one,two,three,four,five,six)==four then
marp = 4
elseif math.max(one,two,three,four,five,six)==five then
marp = 5
elseif math.max(one,two,three,four,five,six)==six then
marp = 6
elseif math.max(one,two,three,four,five,six)==0 then
marp = math.random(1,6)
end
while wait(1) do
if marp == 1 then
-- Code here.
elseif marp == 2 then
--Code here
end
I really have no idea, Even as I am a rather strong Lua coder... |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
Forgot the extra end =P
end
end |
|
|
Wouldn't just using one math.max() work because it would return the highest voted map? |
|
iFordMCJoin Date: 2011-08-26 Post Count: 1491 |
No he wants not to print it, But to see if it is... I don't know what I'm saying... |
|
|
@OP;
Just do
marp = math.max(one,two,three,four,five,six)
That will return a number value anyway, so 'marp' will be set as a number. |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
I honestly dont know how Tables work. Sorry! and for the marp = math.max() thing, it would return what the highest votes of most chosen value, so if 3 people voted for map 4, it would load up map 3, because it reads the value, not the mapnumber. I feel like i dont even know what im doing anymore xD
one = script.Parent.Votes.One.Value
two = script.Parent.Votes.Two.Value
three = script.Parent.Votes.Three.Value
four = script.Parent.Votes.Four.Value
five = script.Parent.Votes.Five.Value
six = script.Parent.Votes.Six.Value
seven = script.Parent.Votes.Seven.Value
if math.max(one,two,three,four,five,six,seven)==one then
marp = 1
elseif math.max(one,two,three,four,five,six,seven)==two then
marp = 2
elseif math.max(one,two,three,four,five,six,seven)==three then
marp = 3
elseif math.max(one,two,three,four,five,six,seven)==four then
marp = 4
elseif math.max(one,two,three,four,five,six,seven)==five then
marp = 5
elseif math.max(one,two,three,four,five,six,seven)==six then
marp = 6
elseif math.max(one,two,three,four,five,six,seven)==seven then
marp = 7
elseif math.max(one,two,three,four,five,six,seven)==0 then
marp = math.random(1,7)
end
print(marp)
game.Lighting[marp]:Clone().Parent = game.Workspace
game.Workspace[marp].Name = "Map" |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Bump. MALLEO |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Bump. |
|
NewFissyJoin Date: 2011-01-03 Post Count: 1303 |
Hi crazyblox. Try this script:
Maps = {script.Parent.Votes.One.Value,script.Parent.Votes.Two.Value,script.Parent.Votes.Three.Value,script.Parent.Votes.Four.Value,script.Parent.Votes.Five.Value,script.Parent.Votes.Six.Value} -- Map Votes
function ReturnHighestVotes()
MaxVotes=math.max(one,two,three,four,five,six)
MaxVotesMaps = {}
for i = 1, #Maps do
if Maps[i] == MaxVotes then
table.insert(MaxVotesMaps,i)
end
end
if #MaxVotesMaps == 1 then
return MaxVotesMaps[1]
else
return MaxVotesMaps[math.random(1,#MaxVotesMaps)]
end
end
MapNumbWithHighestVotes = ReturnHighestVotes()
print(MapNumbWithHighestVotes)
game.Lighting[MapNumbWithHighestVotes]:Clone().Parent = game.Workspace -- Example Map chosen: game.Lighting.1
game.Workspace[MapNumbWithHighestVotes].Name = "Map" |
|
vargy3454Join Date: 2009-08-10 Post Count: 3638 |
|
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Hi Fissy, i've used your coding and it works a charm so far in solo! Im going to upload it now. Thanks! |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Uh oh! theres something horribly wrong with that code!
if map one has 2 votes, and map seven has 4 votes, IT CAN CHOOSE MAP ONE!
I want it so if Map one has 4 votes and map seven has 4 votes they can be chosen between eachother, not map one being chosen when it has less votes than map seven!
It doesnt have to be map one or seven, this is just an example,
HELP!
|
|
HatHelperTop 25 PosterJoin Date: 2009-03-02 Post Count: 46305 |
So if two maps have the same amount of votes, you want it to choose fairly between the two(or more)? |
|
crazybloxJoin Date: 2008-03-16 Post Count: 6139 |
Yes, if thats possible. |
|
HatHelperTop 25 PosterJoin Date: 2009-03-02 Post Count: 46305 |
This is not the most efficient script, but here:
maps = {1,2,3,4,5,6}
votes = {1,0,2,2,1,1}
maps={1},vot=0
for i=1, #votes do
if votes[i] > vot then
maps = {i}
vot = votes[i]
elseif votes[i] == vot then
table.insert(maps, i)
end
end
mapselected = maps[math.random(1, #maps)]
not sure if this is waht you want
untested.
|
|