Thread: Number Gen

Page 1 of 3 123 LastLast
Results 1 to 15 of 38
  1. #1
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,404
    My Mood
    In Love

    Number Gen

    Code:
    int RandomNum(int lowest, int highest)
    {
        int random_integer; 
        int range=(highest-lowest)+1; 
            random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
    	return random_integer;
    }
    Idk what this can be used for but i guess you can use it for "Speed Surprise".
    A feature I'm adding into my menu hack /
    You never know how fast you will go in ca

    How to use
    Code:
    Lucky = RandomNum(1,100000);


    Credits:
    Me for function
    No I do not make game hacks anymore, please stop asking.


    Been MPGH Minion: 6 July 2011 - 1 August 2012

  2. The Following 3 Users Say Thank You to flameswor10 For This Useful Post:

    mad boy (02-02-2011),PikaMucha_Itu (02-10-2011),Sixx93 (02-02-2011)

  3. #2
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    Code:
    int GetRandomNumber(int MAXNUM)
    {
    	srand((DWORD)time(0));
    	return rand() % MAXNUM;
    }
    Last edited by kotentopf; 02-02-2011 at 05:04 AM.
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  4. #3
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,404
    My Mood
    In Love
    Quote Originally Posted by kotentopf View Post
    Code:
    srand((DWORD)time(0);
    
    int Number = rand % <highestnumber>;

    Don't be soo mean LOL
    No I do not make game hacks anymore, please stop asking.


    Been MPGH Minion: 6 July 2011 - 1 August 2012

  5. #4
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    Quote Originally Posted by flameswor10 View Post

    Don't be soo mean LOL
    its much easier and need not so much code
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  6. #5
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,404
    My Mood
    In Love
    Quote Originally Posted by kotentopf View Post
    its much easier and need not so much code
    To them it's just C+P so theres not much difference
    No I do not make game hacks anymore, please stop asking.


    Been MPGH Minion: 6 July 2011 - 1 August 2012

  7. The Following User Says Thank You to flameswor10 For This Useful Post:

    kotentopf (02-02-2011)

  8. #6
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    i know....
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  9. #7
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    damn, ty i was searching for something about how to get a random number... i know the rand() function (not so good), but i have some problems... ty for this!

  10. #8
    xChocolatex's Avatar
    Join Date
    Jan 2011
    Gender
    female
    Posts
    81
    Reputation
    35
    Thanks
    1,819
    Quote Originally Posted by flameswor10 View Post
    Code:
    int RandomNum(int lowest, int highest)
    {
        int random_integer; 
        int range=(highest-lowest)+1; 
            random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
    	return random_integer;
    }
    How to use
    Code:
    Lucky = RandomNum(1,100000);
    Credits:
    Me for function
    I found similar post by Raygoe in 2007, honestly you didnt create the function.

    [Highlight=C++]#include "input.h"
    #include "OgreStringConverter.h"
    #include "simulation.h"

    #include "Ogre.h"
    #include <string>
    #include <sstream>

    #include <iostream>
    #include <ctime>
    #include <cstdlib>

    #include "OgreWindowEventUtilities.h"

    int randomNum (int lowest, int highest) {
    int random_integer;
    int range = (highest-lowest)+1;

    random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
    return random_integer;
    }

    InputHandler::InputHandler(Simulation *sim, unsigned long hWnd, Ogre::Root* ogre, Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr, Ogre::Camera* camera, Ogre::SceneNode* buildnode, Ogre::SceneNode* cameraNode) {

    root_ogre = ogre;
    rWindow = window;
    sMan = sceneMgr;
    cam = camera;
    bNode = buildnode;

    robotI = 0;

    OIS::ParamList pl;
    pl.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
    //SHOW MOUSE
    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
    pl.insert( std::make_pair( std::string( "w32_mouse" ), std::string("DISCL_NONEXCLUSIVE") ) );

    m_hWnd = hWnd;
    m_ois = OIS::InputManager::createInputSystem( pl );
    mMouse = static_cast<OIS::Mouse*>(m_ois->createInputObject( OIS::OISMouse, true ));
    mKeyboard = static_cast<OIS::Keyboard*>(m_ois->createInputObject( OIS::OISKeyboard, true));
    mMouse->setEventCallback(this);
    mKeyboard->setEventCallback(this);

    mRotate = 0.13;
    mMove = 0;

    mContinue = true;
    m_simulation = sim;

    mDirection = cam->getPosition();

    camNode = cameraNode;

    srand((unsigned)time(0));
    targetNode = sMan->getSceneNode("playerRob");
    }

    InputHandler::~InputHandler() {
    if (mMouse)
    delete mMouse;
    if (mKeyboard)
    delete mKeyboard;
    OIS::InputManager::destroyInputSystem(m_ois);
    }

    void InputHandler::capture() {
    mMouse->capture();
    mKeyboard->capture();
    }

    bool InputHandler::movePlayerCam(float ft) {
    frameTime = (ft);

    if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W) || mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) {
    mDirection = (0,0,mMove);
    didMove = true;
    }

    if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) {
    targetNode->yaw(Ogre:egree(2*frameTime),Ogre::Node::TS_WORLD);
    camNode->yaw(Ogre:egree(2*frameTime),Ogre::Node::TS_WORLD);
    didMove = true;
    }
    else if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) {
    targetNode->yaw(Ogre:egree(-2*frameTime),Ogre::Node::TS_WORLD);
    camNode->yaw(Ogre:egree(-2*frameTime),Ogre::Node::TS_WORLD);
    didMove = true;
    }

    if (didMove != true) {
    return false;
    } else {
    didMove = false;
    }

    mMoveTo = (targetNode->getOrientation() * ((mDirection * frameTime) - targetNode->getPosition()));
    //mDirection.x = 0;
    //mDirection.y = 0;
    //mDirection.z = 0;
    targetNode->translate(mMoveTo);
    cam->lookAt(targetNode->getPosition());
    //cam->setPosition();

    std::cout << mMoveTo << "\n" << targetNode->getPosition() << "\n";
    return true;
    }

    void InputHandler::setWindowExtents(int width, int height){
    //Set Mouse Region.. if window resizes, we should alter this to reflect as well
    const OIS::MouseState &ms = mMouse->getMouseState();
    ms.width = width;
    ms.height = height;
    }

    /*bool InputHandler::frameStarted(const Ogre::FrameEvent &evt) {
    camNode->translate(mDirection * evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);
    return true;
    }*/

    // MouseListener
    bool InputHandler::mouseMoved(const OIS::MouseEvent &evt) {
    if (evt.state.buttonDown(OIS::MB_Right)) {
    camNode->pitch(Ogre:egree(-mRotate * evt.state.Y.rel), Ogre::Node::TS_LOCAL);
    camNode->yaw(Ogre:egree(-mRotate * evt.state.X.rel), Ogre::Node::TS_WORLD);
    cam->lookAt(targetNode->getPosition());
    }
    return true;
    }

    bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
    return true;
    }

    bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
    return true;
    }


    // KeyListener
    bool InputHandler::keyPressed(const OIS::KeyEvent &evt) {
    if (evt.key == OIS::KC_UP || evt.key == OIS::KC_W) {
    mMove = 100;
    }
    if (evt.key == OIS::KC_DOWN || evt.key == OIS::KC_S) {
    mMove = -50;
    }
    return true;
    }

    bool InputHandler::keyReleased(const OIS::KeyEvent &evt) {
    if (evt.key == OIS::KC_ESCAPE)
    m_simulation->requestStateChange(SHUTDOWN);
    if (evt.key == OIS::KC_F5) {
    robotI++;
    std::stringstream stream;
    stream << "robot" << robotI;
    std::string robotID = stream.str();

    Ogre::Entity* ent1 = sMan->createEntity( robotID, "robot.mesh" );
    Ogre::SceneNode* secondary = bNode->createChildSceneNode( robotID, Ogre::Vector3( randomNum(0,20), randomNum(0,20), (randomNum(0,20) - 500) ) );
    std:: cout << robotID << "\n";
    secondary->attachObject( ent1 );
    }
    if (evt.key == OIS::KC_F6) {
    camNode->setOrientation(Ogre::Quaternion(-1,0,-.5,0));
    }
    if (evt.key == OIS::KC_UP || evt.key == OIS::KC_W) {
    mMove = 0;
    }
    if (evt.key == OIS::KC_DOWN || evt.key == OIS::KC_S) {
    mMove = 0;
    }
    return true;
    }

    // JoyStickListener
    bool InputHandler::buttonPressed(const OIS::JoyStickEvent &evt, int index) {
    return true;
    }

    bool InputHandler::buttonReleased(const OIS::JoyStickEvent &evt, int index) {
    return true;
    }

    bool InputHandler::axisMoved(const OIS::JoyStickEvent &evt, int index) {
    return true;
    }

    bool InputHandler:ovMoved(const OIS::JoyStickEvent &evt, int index) {
    return true;
    }[/Highlight]

  11. #9
    LionelMessi10's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    MPGH.NET
    Posts
    6,125
    Reputation
    114
    Thanks
    4,545
    My Mood
    Aggressive
    Using Class.

    Code:
       int IRandom(int min, int max){       // output random integer
          // get integer random number in desired interval
          int iinterval = max - min + 1;
          if (iinterval <= 0) return 0x80000000; // error
          int r = int(iinterval * Random()); // truncate
          if (r >= iinterval) r = iinterval-1;
          return min + r;
       }
    };

  12. #10
    whit+'s Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    267
    Reputation
    10
    Thanks
    37
    My Mood
    Breezy
    Quote Originally Posted by xChocolatex View Post
    I found similar post by Raygoe in 2007, honestly you didnt create the function.
    You didnt Make your pro hacks
    So STFU

  13. The Following 3 Users Say Thank You to whit+ For This Useful Post:

    DannyIzHere (02-02-2011),[MPGH]flameswor10 (02-02-2011),GodHack2 (02-02-2011)

  14. #11
    -xGhost-'s Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    C:\Sytem32
    Posts
    347
    Reputation
    9
    Thanks
    57
    My Mood
    Relaxed
    Quote Originally Posted by whit+ View Post
    You didnt Make your pro hacks
    So STFU
    Take it easy, he actually gives credit to Gellin now...



  15. #12
    xChocolatex's Avatar
    Join Date
    Jan 2011
    Gender
    female
    Posts
    81
    Reputation
    35
    Thanks
    1,819
    Quote Originally Posted by whit+ View Post
    You didnt Make your pro hacks
    So STFU
    Same thing Goes to you
    So STFU

  16. #13
    whit+'s Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    267
    Reputation
    10
    Thanks
    37
    My Mood
    Breezy
    Quote Originally Posted by xChocolatex View Post
    Same thing Goes to you
    So STFU
    Sorry i dont think i released any hacks lately...
    Sorry if i use my Knowledge for coding thing other than hacks

  17. The Following User Says Thank You to whit+ For This Useful Post:

    [MPGH]Jason (02-02-2011)

  18. #14
    xChocolatex's Avatar
    Join Date
    Jan 2011
    Gender
    female
    Posts
    81
    Reputation
    35
    Thanks
    1,819
    Quote Originally Posted by whit+ View Post
    Sorry i dont think i released any hacks lately...
    Sorry if i use my Knowledge for coding thing other than hacks
    Feel so pro? Your last release used gellin's base so what's different between you and me, huh? If you jealous just release better hack than mine.

  19. #15
    whit+'s Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    267
    Reputation
    10
    Thanks
    37
    My Mood
    Breezy
    Quote Originally Posted by xChocolatex View Post
    Feel so pro? Your last release used gellin's base so what's different between you and me, huh? If you jealous just release better hack than mine.
    Yea like a year ago..Who cares tho i changed the menu around and added groups to it..Thats was when i just start coding dumbass

    Atleast i dont use it now.. Unlike you i dont compile and release hacks off a VIP base..
    Do us all a favor and get the hell out..
    Last edited by whit+; 02-02-2011 at 12:49 PM.

  20. The Following User Says Thank You to whit+ For This Useful Post:

    [MPGH]Jason (02-02-2011)

Page 1 of 3 123 LastLast