Warrock - Code Snippets

10/02/2012 15:54 ignorehax#376
Please Source MemPatch and OPK Player
10/02/2012 17:50 Raz9r#377
Here you go with your memory class which is able to restore a saved value. Easily extendable.

mempatch.h
Code:
#pragma once

template<typename _Ty>
class mempatch
{
private:
  typedef _Ty value_type;
  typedef const _Ty const_value_type;
  typedef _Ty *pointer_type;
  typedef const _Ty *const_pointer_type;

  pointer_type _addressedMemory;
  value_type _savedState;

public:
  void initWithAddressedMemory(const_pointer_type addressedMemory, bool saveInitialState = false);
  void initWithReferencedObject(const_value_type &referencedObject, bool saveInitialState = false);
  
  const_pointer_type getAddressedMemory() const;
  void setValue(const_value_type value, bool saveState = false) const;

  void save();
  void restore();
};
mempatch.cpp
Code:
#include "mempatch.h"

template<typename _Ty>
void mempatch<_Ty>::initWithAddressedMemory(mempatch<_Ty>::const_pointer_type addressedMemory, bool saveInitialState)
{
  _addressedMemory = addressedMemory;
  if(saveInitialState == true)
    _savedState = *_addressedMemory;
};

template<typename _Ty>
void mempatch<_Ty>::initWithReferencedObject(mempatch<_Ty>::const_value_type &referencedObject, bool saveInitialState)
{
  initWithAddressedMemory(&referencedObject, saveInitialState);
}

template<typename _Ty>
mempatch<_Ty>::const_pointer_type mempatch<_Ty>::getAddressedMemory() const
{
  return _addressedMemory;
}

template<typename _Ty>
void mempatch<_Ty>::setValue(mempatch<_Ty>::const_value_type value, bool saveState) const
{
  *_addressedMemory = value;
  if(saveState == true)
    save();
}

template<typename _Ty>
void mempatch<_Ty>::save()
{
  _savedState = *_addressedMemory;
}

template<typename _Ty>
void mempatch<_Ty>::restore()
{
  *_addressedMemory = _savedState;
}
10/03/2012 15:41 -Marekiarox-#378
#request Speed,GlassWalls,HeadShot Source?
10/03/2012 19:04 ignorehax#379
UnderScore@
fail ;] Full errors:
Code:
1>  MemPatch.cpp
1>MemPatch.cpp(4): error C2146: syntax error : missing ')' before identifier 'addressedMemory'
1>MemPatch.cpp(4): error C2182: 'initWithAddressedMemory' : illegal use of type 'void'
1>MemPatch.cpp(4): error C2470: 'mempatch<_Ty>::initWithAddressedMemory' : looks like a function definition, but there is no parameter list; skipping apparent body
1>MemPatch.cpp(4): error C2072: 'mempatch<_Ty>::initWithAddressedMemory' : initialization of a function
1>MemPatch.cpp(4): error C2059: syntax error : ')'
1>MemPatch.cpp(12): error C2065: 'referencedObject' : undeclared identifier
1>MemPatch.cpp(12): error C2062: type 'bool' unexpected
1>MemPatch.cpp(19): error C2143: syntax error : missing ';' before '{'
1>MemPatch.cpp(19): error C2447: '{' : missing function header (old-style formal list?)
1>MemPatch.cpp(24): error C2146: syntax error : missing ')' before identifier 'value'
1>MemPatch.cpp(24): error C2182: 'setValue' : illegal use of type 'void'
1>MemPatch.cpp(24): error C2470: 'mempatch<_Ty>::setValue' : looks like a function definition, but there is no parameter list; skipping apparent body
1>MemPatch.cpp(24): error C2072: 'mempatch<_Ty>::setValue' : initialization of a function
1>MemPatch.cpp(24): error C2059: syntax error : ')'
1>MemPatch.cpp(33): error C2143: syntax error : missing ';' before '{'
1>MemPatch.cpp(33): error C2447: '{' : missing function header (old-style formal list?)
10/03/2012 19:38 ~ExoduS~*#380
Quote:
Originally Posted by ignorehax View Post
UnderScore@
fail ;] Full errors:
Code:
1>  MemPatch.cpp
1>MemPatch.cpp(4): error C2146: syntax error : missing ')' before identifier 'addressedMemory'
1>MemPatch.cpp(4): error C2182: 'initWithAddressedMemory' : illegal use of type 'void'
1>MemPatch.cpp(4): error C2470: 'mempatch<_Ty>::initWithAddressedMemory' : looks like a function definition, but there is no parameter list; skipping apparent body
1>MemPatch.cpp(4): error C2072: 'mempatch<_Ty>::initWithAddressedMemory' : initialization of a function
1>MemPatch.cpp(4): error C2059: syntax error : ')'
1>MemPatch.cpp(12): error C2065: 'referencedObject' : undeclared identifier
1>MemPatch.cpp(12): error C2062: type 'bool' unexpected
1>MemPatch.cpp(19): error C2143: syntax error : missing ';' before '{'
1>MemPatch.cpp(19): error C2447: '{' : missing function header (old-style formal list?)
1>MemPatch.cpp(24): error C2146: syntax error : missing ')' before identifier 'value'
1>MemPatch.cpp(24): error C2182: 'setValue' : illegal use of type 'void'
1>MemPatch.cpp(24): error C2470: 'mempatch<_Ty>::setValue' : looks like a function definition, but there is no parameter list; skipping apparent body
1>MemPatch.cpp(24): error C2072: 'mempatch<_Ty>::setValue' : initialization of a function
1>MemPatch.cpp(24): error C2059: syntax error : ')'
1>MemPatch.cpp(33): error C2143: syntax error : missing ';' before '{'
1>MemPatch.cpp(33): error C2447: '{' : missing function header (old-style formal list?)

is not to copy and paste it will be seen that you have no idea of ​​just c++ learn c + + the source work perfect.
10/03/2012 21:43 Too.™#381
Thanks of this thread realy useful
10/04/2012 00:23 Raz9r#382
Quote:
Originally Posted by ignorehax View Post
UnderScore@
fail ;] Full errors:
Code:
1>  MemPatch.cpp
1>MemPatch.cpp(4): error C2146: syntax error : missing ')' before identifier 'addressedMemory'
1>MemPatch.cpp(4): error C2182: 'initWithAddressedMemory' : illegal use of type 'void'
1>MemPatch.cpp(4): error C2470: 'mempatch<_Ty>::initWithAddressedMemory' : looks like a function definition, but there is no parameter list; skipping apparent body
1>MemPatch.cpp(4): error C2072: 'mempatch<_Ty>::initWithAddressedMemory' : initialization of a function
1>MemPatch.cpp(4): error C2059: syntax error : ')'
1>MemPatch.cpp(12): error C2065: 'referencedObject' : undeclared identifier
1>MemPatch.cpp(12): error C2062: type 'bool' unexpected
1>MemPatch.cpp(19): error C2143: syntax error : missing ';' before '{'
1>MemPatch.cpp(19): error C2447: '{' : missing function header (old-style formal list?)
1>MemPatch.cpp(24): error C2146: syntax error : missing ')' before identifier 'value'
1>MemPatch.cpp(24): error C2182: 'setValue' : illegal use of type 'void'
1>MemPatch.cpp(24): error C2470: 'mempatch<_Ty>::setValue' : looks like a function definition, but there is no parameter list; skipping apparent body
1>MemPatch.cpp(24): error C2072: 'mempatch<_Ty>::setValue' : initialization of a function
1>MemPatch.cpp(24): error C2059: syntax error : ')'
1>MemPatch.cpp(33): error C2143: syntax error : missing ';' before '{'
1>MemPatch.cpp(33): error C2447: '{' : missing function header (old-style formal list?)
Quote:
Originally Posted by ~ExoduS~* View Post
is not to copy and paste it will be seen that you have no idea of ​​just c++ learn c + + the source work perfect.
I re-compiled this just for testing purposes in a new project with default settings in the newest version of Visual Studio (VS2012 Professional, Student Edition) and it works like a charm. Just created the two files, copied the code into them and after that I wrote some code in the main function to test it.
Basically the source is taken out of some old code in my project, but I removed some enhancements to it which would not be needed anyways. I don't think any of you guys will need initWithReferencedObject anyways, but it is the only extension I decided not to delete from the class (as it's basic stuff anyways).
If you guys prefer using constructor code you may also rename initWithAddressedMemory to mempatch (to make it the public constructor with 2 arguments), delete initWithReferencedObject and then add an empty destructor ~mempatch.
10/04/2012 17:36 FamousBrothers#383
request

glasswall (adr v.)
nospawnwait (my v. dont work :/)
10/04/2012 17:52 Pu3Mi2o#384
GlassWall ,
On = 4
Off = 0
*(INT*) Addy = 4;

NoSpawnWait
*(FLOAT*) Addy = 0;
10/04/2012 18:05 FamousBrothers#385
Quote:
Originally Posted by Pu3Mi2o View Post
GlassWall ,
On = 4
Off = 0
*(INT*) Addy = 4;

NoSpawnWait
*(FLOAT*) Addy = 0;
hab ich beides genau so.

gehen beide nicht.

edit: war ein scriptfehler^^

edit2:
PHP Code:
#define ADR_WTW                        0x00862C48

if (WTW == 1)
    {
        *(
float*)(ADR_WTW) = -999;
    }
else
    {
        *(
float*)(ADR_WTW) = 6;
    } 
CRASH AFTER JOIN! :/
10/04/2012 22:02 CyberVeezy :)#386
Quote:
Originally Posted by FamousBrothers View Post
hab ich beides genau so.

gehen beide nicht.

edit: war ein scriptfehler^^

edit2:
PHP Code:
#define ADR_WTW                        0x00862C48

if (WTW == 1)
    {
        *(
float*)(ADR_WTW) = -999;
    }
else
    {
        *(
float*)(ADR_WTW) = 6;
    } 
CRASH AFTER JOIN! :/
Checke die Addy noch einmal und versuche es mit Mempatch
10/05/2012 09:55 FamousBrothers#387
Quote:
Originally Posted by CyberVeezy :) View Post
Checke die Addy noch einmal und versuche es mit Mempatch
Habs mit mempatch versucht.

Kann nur in eine wand glitchen aber nicht durch^^
10/05/2012 13:52 .Kha'Zix.#388
Code:
if ( cPlayer.WTW == 1 )
{
WriteMEM<float>((void*)ADR_WTW,-3);
}
else
{
WriteMEM<float>((void*)ADR_WTW,6);
}
10/05/2012 14:46 __BuRn3R#389
Code:
class CPlayer
{
public:
	char BuRn3R1[66304];//0x00
	float PosX;//0x10300
	char BuRn3R2[4];//0x10304
	float PosY;//0x10310
	char BuRn3R3[4];//0x10314
	float PosZ;//0x10308
};
class CBase
{
public:
	CPlayer *p_Local;
	char BuRn3R1[1199116];
	CPlayer **p_Global;
};
if (PlayerOPK)
{
	int Index = 0;
	while (GetIndexInfo(Index))
	{
		p_Base->p_Global[Index]->PosX = 0.0F;
		p_Base->p_Global[Index]->PosY = 0.0F;
		p_Base->p_Global[Index]->PosZ = 0.0F;
		Index++;
	}
}
10/05/2012 15:52 FamousBrothers#390
Quote:
Originally Posted by .Kha'Zix. View Post
Code:
if ( cPlayer.WTW == 1 )
{
WriteMEM<float>((void*)ADR_WTW,-3);
}
else
{
WriteMEM<float>((void*)ADR_WTW,6);
}

geht auch nicht,

hab als value -9999998.0175 genommen,
klappt besser.

Falls ihr diese Value benutzt
währen credits nett! ich hab 3 stunden drann gessessen ;)



______________________________________


Wie definiert man p_Player?