[RELEASE] Useful Functions

Posts 121–135 of 189 · Page 9 of 13
hey, im new to this and i want to learn coding. can you tell me how this works? and do i put it in notepad and convert to .dll or something?
Quote Originally Posted by edwardjiang View Post
hey, im new to this and i want to learn coding. can you tell me how this works? and do i put it in notepad and convert to .dll or something?
Nahh mate ...
Download and learn Microsoft visual C++
whats that? can someone like an expert coder teach me or give me a tutorial? that would be heaps good. thanks for helping whit
go to cplusplus.com (seriously)
Then learn D3D at the Toymaker.

Come back
useful class i wrote to handle console commands

Code:
class CConsoleCommand {

	char commands[100][100];
	float on_value[100];
	float off_value[100];
	int othertoggle[100];
	int* toggle;
	int oldtoggle;
	int slot;

public:
	CConsoleCommand(){
		memset(&commands, 0, sizeof(commands));
		memset(&on_value, 0, sizeof(on_value));
		memset(&off_value, 0, sizeof(off_value));
		memset(&othertoggle, 0, sizeof(othertoggle));
		toggle = 0;
		oldtoggle = 0;
	}

	CConsoleCommand(int *toggle) {
		CConsoleCommand();
		this->toggle = toggle;
	}

	void Add(char* cmd, float on_value, float off_value, int toggle = 0) {
		strcpy(commands[slot], cmd);
		this->on_value[slot] = on_value;
		this->off_value[slot] = off_value;

		if(toggle) {
			othertoggle[slot] = toggle;
		}

		slot++;
	}

	void Execute() {

		if(*toggle && *toggle != oldtoggle) {

			oldtoggle = *toggle;

			char buf[64] = "";

			bool found = false;

			for(int i = 0; i < slot; i++) {
				if(othertoggle[i] == *toggle) {

					sprintf(buf, "%s %f", commands[i], on_value[i]);
					g_pEngine->m_pLTBase->RunConsoleCommand(buf);
					found = true;
				}
			}

			if(found) {

				return;
			}

			for(int i = 0; i < slot; i++) {
				if(!othertoggle[i]) {

					sprintf(buf, "%s %f", commands[i], on_value[i]);
					g_pEngine->m_pLTBase->RunConsoleCommand(buf);
				}
			}
		}

		if(!*toggle && *toggle != oldtoggle) {

			oldtoggle = *toggle;
			char buf[64] = "";

			for(int i = 0; i < slot; i++) {
				sprintf(buf, "%s %f", commands[i], off_value[i]);
				g_pEngine->m_pLTBase->RunConsoleCommand(buf);
			}
		}
	}
};
replace runconsolecommand with ur function

usage;
Code:
//global definition, cvars.Boxes is the variable i use to turn Boxes on or off
CConsoleCommand cmdBoxes(&cvars.Boxes);

//initialization, call it only once
cmdBoxes.Add("ModelDebug_DrawBoxes", 1, 0);

//in a thread:
cmdBoxes.Executes();
Quote Originally Posted by Gordon` View Post
useful class i wrote to handle console commands

Code:
class CConsoleCommand {

	char commands[100][100];
	float on_value[100];
	float off_value[100];
	int othertoggle[100];
	int* toggle;
	int oldtoggle;
	int slot;

public:
	CConsoleCommand(){
		memset(&commands, 0, sizeof(commands));
		memset(&on_value, 0, sizeof(on_value));
		memset(&off_value, 0, sizeof(off_value));
		memset(&othertoggle, 0, sizeof(othertoggle));
		toggle = 0;
		oldtoggle = 0;
	}

	CConsoleCommand(int *toggle) {
		CConsoleCommand();
		this->toggle = toggle;
	}

	void Add(char* cmd, float on_value, float off_value, int toggle = 0) {
		strcpy(commands[slot], cmd);
		this->on_value[slot] = on_value;
		this->off_value[slot] = off_value;

		if(toggle) {
			othertoggle[slot] = toggle;
		}

		slot++;
	}

	void Execute() {

		if(*toggle && *toggle != oldtoggle) {

			oldtoggle = *toggle;

			char buf[64] = "";

			bool found = false;

			for(int i = 0; i < slot; i++) {
				if(othertoggle[i] == *toggle) {

					sprintf(buf, "%s %f", commands[i], on_value[i]);
					g_pEngine->m_pLTBase->RunConsoleCommand(buf);
					found = true;
				}
			}

			if(found) {

				return;
			}

			for(int i = 0; i < slot; i++) {
				if(!othertoggle[i]) {

					sprintf(buf, "%s %f", commands[i], on_value[i]);
					g_pEngine->m_pLTBase->RunConsoleCommand(buf);
				}
			}
		}

		if(!*toggle && *toggle != oldtoggle) {

			oldtoggle = *toggle;
			char buf[64] = "";

			for(int i = 0; i < slot; i++) {
				sprintf(buf, "%s %f", commands[i], off_value[i]);
				g_pEngine->m_pLTBase->RunConsoleCommand(buf);
			}
		}
	}
};
replace runconsolecommand with ur function

usage;
Code:
//global definition, cvars.Boxes is the variable i use to turn Boxes on or off
CConsoleCommand cmdBoxes(&cvars.Boxes);

//initialization, call it only once
cmdBoxes.Add("ModelDebug_DrawBoxes", 1, 0);

//in a thread:
cmdBoxes.Executes();
THanks for that but it isnt needed... only d3d in gellins was semi-patched.. not PTC. But ty
Quote Originally Posted by CAFlames View Post


THanks for that but it isnt needed... only d3d in gellins was semi-patched.. not PTC. But ty
dont post bullshit if you dont know what the code does.
Whats the off statement for a D3D Crosshair.
Guys, how do u make the menu appear over hte box? my box overlaps menu.
Quote Originally Posted by CAFlames View Post
Guys, how do u make the menu appear over hte box? my box overlaps menu.
Draw box first then your menu and fonts
Quote Originally Posted by Zoom View Post


Draw box first then your menu and fonts
Hmmm i need to draw box in endscene not with my menu so shud i just put if insert then sleep(100) right above draw.string?
Quote Originally Posted by CAFlames View Post


Hmmm i need to draw box in endscene not with my menu so shud i just put if insert then sleep(100) right above draw.string?
why would you sleep endscene. Thats just asking for lag D:
Draw the box first then the menu. Try that.
Posts 121–135 of 189 · Page 9 of 13
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us