anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 01 Mar 2014 07:29 PM |
| do a chance system like on murder mystery or darkness 2 |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 01 Mar 2014 07:32 PM |
| no because some players have more chances than others |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 01 Mar 2014 07:34 PM |
still math.random probs something like this
local table = {} for i, v in pairs(game.Players:GetPlayers()) do local percentage = v.Percentage.Value for i = 1, percentage do table.insert(table, v) end end
Then math.random. |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
| |
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 01 Mar 2014 07:40 PM |
| I think it works but how would you do a math.random on a table? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 01 Mar 2014 07:41 PM |
srsly table[math.random#table] leftoutafew()butidrc |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 07:44 PM |
| wazap, take it easy on him, he's having trouble. I saw his other post, he isn't bad, but sometimes some of us don't learn basic stuff in the beginning, (example; I still haven't learnt IsA() yet) |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 07:47 PM |
@war if part:IsA("ClassName") then
basically, it is a conditional used to see if the part in question literally is a Part, or BasePart, or whatever |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 01 Mar 2014 07:47 PM |
tryed this: a = math.random(1,#listtable) but a is a number. how would I make it the players name? |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 01 Mar 2014 07:48 PM |
| And thanks for all your help! |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
|
| 01 Mar 2014 07:49 PM |
i got it if a person had a 3% chance insert their name 3 times because % is out of 100 then use math.random on the table to get the random 1% people with higher percentages have a better chance of getting chosen |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
| |
|
|
| 01 Mar 2014 08:01 PM |
@mario so this;
Super5737; 3% (3 times) Dienowplz; 87% (87 times) FreakyCreeps; 10% (10 times) Creepynutso; 0% (0 times)
That works out perfect, but I'd just sooner add their name in 1 time for every round they aren't picked, and revert to 1 when they are, why bother with a percent system?!? |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 01 Mar 2014 09:10 PM |
okay I thought it worked until I tryed it in f7 mode with 7 players. here is my current script:
Vip = {"shadownetwork","anth4321"} z = 1
listtable = {} for i, v in pairs(game.Players:GetPlayers()) do percentage = v.Chance.Value for i = 1, percentage do table.insert(listtable, v) end end
print(listtable)
function PickAssassin() a = math.random(1,#listtable) plr=listtable[a] if plr.Picked == false then plr.Assassin = true plr.Picked = true print(plr" is assassin") else PickAssassin() end end
function PickPolice() a = math.random(1,#listtable) plr=listtable[a] if plr.Picked == false then if z == 1 then z = 0 plr.SpecialPolice = true plr.Picked = true else plr.Police = true plr.Picked = true end print(plr" is police") else PickPolice() end end
function PickTarget() a = math.random(1,#listtable) plr=listtable[a] if plr.Picked == false then plr.Target = true plr.Picked = true print(plr" is target") else PickTarget() end end
function pickplayers() PickAssassin() d = math.random(2,4) for i=1,d do PickPolice() end d = math.random(1,2) for i=1,d do PickTarget() end end
pickplayers()
Output 22:07:20.161 - Workspace.Script:15: stack overflow 22:07:20.162 - Script 'Workspace.Script', Line 15 - global PickAssassin 22:07:20.164 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.166 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.167 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.169 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.170 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.170 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.171 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.172 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.173 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.174 - Script 'Workspace.Script', Line 22 - global PickAssassin 22:07:20.175 - Script 'Workspace.Script', Line 22 - global PickAssassin |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
| |
|
|
| 02 Mar 2014 05:08 AM |
| You tried to set off the function INSIDE itself, if you finish declaring it (put proper amount of ends) it should work |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
|
| 03 Mar 2014 01:09 PM |
I think I fixed it. going to test it now. |
|
|
| Report Abuse |
|
|
anth4321
|
  |
| Joined: 22 Sep 2009 |
| Total Posts: 29 |
|
| |
|