1. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Randomizing when a printer will blow up question

Discussion in 'DarkRP Modding Questions & Help' started by Redneck Rabbit, Dec 27, 2017.

  1. Redneck Rabbit

    Redneck Rabbit New Member

    After working on some custom printers, I have come up on the issue that I'd like them to blow up randomly based on the level. From looking at the Darkrpmodification custom printer example, specifically "if math.random(1, overheatchance) == 3 then self:BurstIntoFlames() end" and other printers I've seen is some use math.random to damage themselves until the health is less than 0, at which they then remove themselves. My main question would be with either of these methods (I'd prefer the one in which it damages itself randomly so that printers damaged by players will blow up faster), which variable(s) tell it how often to randomize the change to damage itself until it reaches?
  2. Trackster

    Trackster Member

    Ok first of all: Please use some formatting when showing example code...in middle of your text is not nice at all..also:

    if math.random(1, overheatchance) == 3 then



    I suggest you to make "math.random(1, overheatchance)" to a variable. So you have

    OverHeatChance = math.random(1, overheatchance)

    if OverHeatChance == 3 then



    Simply because it looks nicer and is easier to edit in case you do any updates later.

Share This Page