Register for your free account! | Forgot your password?
Rust Cheats

Go Back   elitepvpers > Popular Games > Rust
You last visited: Today at 06:38

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Rust Script Tutorial | A simple tutorial with source

Discussion on Rust Script Tutorial | A simple tutorial with source within the Rust forum part of the Popular Games category.

Reply
 
Old   #1
Trade Restricted
 
cr.Sensei's Avatar
 
elite*gold: 24
Join Date: Jul 2022
Posts: 17
Received Thanks: 1
Post Rust Script Tutorial | A simple tutorial with source


Main Code
Code:
#include <Windows.h> // Win32 functions

#include <vector> // allows use of vectors

#include "Util.h" // Include the utility functions
 

// this was old recoil 
std::vector<vector2> ak47 = { {-35, 50}, {5, 46}, {-55, 42}, {-42, 37}, 
{0, 33}, {16, 28}, {29, 24}, {38, 19}, {42, 14}, {42, 9}, 
{38, 9}, {30, 18}, {17, 25}, {0, 29}, {-15, 32}, {-27, 33}, {-37, 32}, {-43, 29}, {-46, 24},
 {-45, 17}, {-42, 8}, {-35, 5}, {-24, 14}, {-11, 21}, 
{12, 25}, {36, 28}, {49, 28}, {49, 26}, {38, 21} };
double ak47_baseDelay = 60000 / 450; // converting round per minute to milliseconds (RPM can be found https://rust.gamepedia.com/Assault_Rifle)

int main()
{
	while (true)
	{
		if (GetAsyncKeyState(VK_RBUTTON) & 0x8000) // this checks to see if the player is scoping. This will start to work the cpu because its running in a fast loop this can be altered ** 
		{
			for (int i = 0; i < ak47.size() && GetAsyncKeyState(VK_LBUTTON) & 0x8000; i++) // loop through the recoil table size of AK47
			{
				Util::simple_smooth(ak47[i].x, ak47[i].y, ak47_baseDelay);
			}

			//Sleep(1); ** Remove the comment to rest CPU while scoped
		}
		Sleep(1); // cpu usage
	}

	return EXIT_SUCCESS;
}

// Keep in mind this is only for ak47 and it is extremely basic and can be improved and edited in numerous ways.

Util

Code:
#include <Windows.h>

#include "Util.h"

namespace Util
{
	static void accurate_sleep(int ms) // more accurate sleep better than the win32 sleep()
	{
		LONGLONG timerResolution;
		LONGLONG wantedTime;
		LONGLONG currentTime;

		QueryPerformanceFrequency((LARGE_INTEGER*)&timerResolution);
		timerResolution /= 1000;

		QueryPerformanceCounter((LARGE_INTEGER*)&currentTime);
		wantedTime = currentTime / timerResolution + ms;
		currentTime = 0;
		while (currentTime < wantedTime)
		{
			QueryPerformanceCounter((LARGE_INTEGER*)&currentTime);
			currentTime /= timerResolution;
		}
	}

	void simple_smooth(int move_point_x, int move_point_y, double delay) // Simple Smoothing function to allow for smooth movement from point a - b
	{
		for (int i = 0; i < 5; i++) { // loop 6 iterations

			mouse_event(1, move_point_x / 5, move_point_y / 5, 0, 0); // divide the total movement value by however so once the 6 iterations are over its completed a full move

			accurate_sleep(delay / 5); // same idea but diving the sleep time
		}

		mouse_event(1, move_point_x % 5, move_point_y % 5, 0, 0); // move for the remainer of the 6 iterations
	}
}
cr.Sensei is offline  
Reply

Tags
rust script




All times are GMT +2. The time now is 06:38.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.