SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
I can program this easy, but not efficiently.
I want for every person after the first person to add 6 to a value and remove 6 when every people other than the last to subtract 6. |
|
|
Show me what code you have done that isn't efficient, I'll try to make it more efficient
R$2,182 lol im poor |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
I haven't yet so I'll just do it live. [Edit] Well it was harder than I thought... And I feel like it wouldn't work.
v={}
v[1]=0
v[2]=6
v[3]=12 --etc.
v2=10 --Value to add or subtract
v3=0 -- Amount being added or subtracted
np = game.Players.NumPlayers
np.Changed:connect(function(nn)
for i, v in ipairs(v) do
v3=v[nn]
if nn > np then
v2 = v2+v3
else
v2 = v2-v3
end end end)
|
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
uh wtf are you trying to do?
|
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
Recreating COD zombies. In COD for every extra player is 6 extra zombies. People come and go a lot on so I need to also need to subtract 6. As far as what I scripted don't ask me because I don't know either lol. |
|
|
What the hell????
Do you mean:
1.GetPlayers
2.get NumPlayers
3. Multiply NumPlayers * 6
4. Plug that into a for loop to poop out the zombies
5. Repeat constantly if a character leaves the game |
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
number of zombies = game.players.numplayers * 6
is it that hard
|
|
|
Lel Ikr... It's truly common sense |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
Number 1 is unnecessary right?
that would work if 1 * 6 = 0.
I guess I could make an if statement to subtract one, but is there not an answer yet? |
|
|
Anyways, time ticks, may I ask that how would you remove the zombies within the game if people leave? If you do a count each round and make the amount of zombies stay the same for a round, then the question is answered. But if you keep checking repetitively, even while a round occurs, wouldn't it be complicated to remove zombies if a player leaves mid-round? |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
The second player in the game adds 6. The first player adds nothing. Its making sense now that I could just start the value 6 low or something to that effect, but what if I couldn't? Just trying to learn something here. Is there a way I can keep 1 active player adding 0? |
|
|
You can learn more from the wiki. Obviously you don't know the simple stuff of scripting |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Keeping it linear actually might make it to easy, so instead of multiplying it by 6 you should do something more than that (maybe 3^numplrs + 3 or something) |
|
|
If anything, I think the relationship should be exponential. The more zombies, the fun XD |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
I have a function named StartNewRound. Self-explanatory. If a character leaves mid-round then just like COD the extra zombies will just stay for the round. But when the StartNewRound function is called I want those bonus zombies taken out of algorithm. The simple answer is to start lower or subtract when there is only one player. But is there a way I can keep 1 player not adding to the number of zombies? |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
3^x is an awful idea don't listen to me, it gets way too extreme. Maybe 2^(x+1) or something |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
You can see my join date. I haven't programmed since I was a kid and I'm 19 now. So I'm sorry. This is mostly what would be the thought process of creating a pattern, but excluding one number. |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
Flux that would still keep it linear, but not a bad idea. |
|
|
The simple answer is every round you clean up the map of zombies, and do the math to get the new total of zombies, then repeat for each round. If you have one player, you can make an algorithm like: math.pow(6,numberOfPlayers - 1)
that would make it If there's one player, there's 1 zombie
2 players: 6 zombies
3 players: 36 zombies
4 players: 36*6 zombies
5 players: 36*36 zombies
As you can see exponential relationships grow fast, which is why you should put like max 5 players in a server if you do this way. But this way will guarantee like one zombie if there's one player, which I think you are asking for. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Syntropy do you know what linear means? |
|
|
Flux I don't think this guys an idiot, he's 19 |
|
SyntropyJoin Date: 2009-03-16 Post Count: 2272 |
I found the simple answer already with the help of you guys. Now I'm asking how to do create a pattern and exclude one number. For a learning experience. |
|
|
Use an if-statement. Done |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Soapy you sure about that?
2^(x+1) is not linear, it's exponential |
|
|
@Flux, I just read that.... Lol yeah you're right, he doesn't know 7th grade math |
|