|
You last visited: Today at 08:59
Advertisement
Warrock - Code Snippets
Discussion on Warrock - Code Snippets within the WarRock forum part of the Shooter category.
02/14/2013, 12:04
|
#706
|
elite*gold: 158
Join Date: Sep 2011
Posts: 878
Received Thanks: 2,493
|
Todo : Update Player Pointer
Todo : Update CBase Reclass
Todo : Update CPlayer Reclass
Todo : Update Add PlayerOPKItem to your Menu
Todo : Try to understand the source by reading the Comments , If you just copy it , you will never be able to Create things yourself
Credits :
Code ( Cyno__™ )
Comments ( Cyno__™ )
Code:
int PlayerOPKItem = 0;
struct CPlayer
{
int index;
float X;
float Y;
float Z;
};
struct CBase
{
CPlayer * m_pLocalPlayer;
char GlobalPtr[123456];
CPlayer ** m_pGlobalPlayers;
};
unsigned long PlayerPointer = 0x0;
unsigned long __stdcall PlayerOPK ( void * lpParam )
{
UNREFERENCED_PARAMETER ( lpParam );// Ignore Unreferenced Parameter Warining
CBase * pBase = ( CBase * )(PlayerPointer);// Init our Reclass with the Original WR Class Pointer
bool bTeleportMyself = true; // Helper Var to Check if theres a new Round and we have to Teleport ourself
while ( true ) // Endless Loop
{
if ( PlayerOPKItem ) // Menu Items = On ?
{
if ( pBase->m_pLocalPlayer ) // Do we Live ?
{
if ( bTeleportMyself )// Do we need to Teleport us once ?
{
pBase->m_pLocalPlayer->X = 0.0f;// Set our X Pos to 0 ( once )
pBase->m_pLocalPlayer->Y = 0.0f;// Set our Y Pos to 0 ( once )
pBase->m_pLocalPlayer->Z = 0.0f;// Set our Z Pos to 0 ( once )
bTeleportMyself = FALSE;//Teleported us once we are Living ? Do do it anymore
}
for ( int i = 0; i < 32 ; i++ )// Loop trough all Players
{
if ( pBase->m_pGlobalPlayers[i] )// Pointer to Global Player Valid ( != 0 ) ?
{
if ( i != pBase->m_pLocalPlayer->index )// Teleport all ( 0-32 Players ) but not ourself to Position 0.0f
{
pBase->m_pGlobalPlayers[i]->X = 0.0f;// Set Player(i)'s X Pos to 0
pBase->m_pGlobalPlayers[i]->Y = 0.0f;// Set Player(i)'s Y Pos to 0
pBase->m_pGlobalPlayers[i]->Z = 0.0f;// Set Player(i)'s Z Pos to 0
}// End Index Check ( Global Player is not our own Player )
}// End Valid Ptr Check
}// End Loop trough all Players
}
else
{
bTeleportMyself = TRUE;// Are we Dead ? Teleport us once when we are living again
Sleep ( 200 );// Dont Overload
}
}
else
{
Sleep ( 200 );// Var is Off -> Chillout 200ms ( anti overload )
}
}
return NO_ERROR;// Should never Reach this under normal circumstances
}
int __stdcall DllMain ( HINSTANCE__ * hModule , unsigned long ulReason , void * lpReserved )
{
UNREFERENCED_PARAMETER(lpReserved);// Ignore Unreferenced Parameter warning
if ( ulReason == DLL_PROCESS_ATTACH )
{
CreateThread ( 0 , 0 , & PlayerOPK , 0 , 0 , 0 );
}
}
|
|
|
02/14/2013, 13:24
|
#707
|
elite*gold: 297
Join Date: Dec 2010
Posts: 1,129
Received Thanks: 1,687
|
@Cyno: Warum lässt du den Thread weiterlaufen, wenn OPK nicht aktiv ist? Selbst wenn er nur Sleep() ausführt...
Richtig wäre wohl, den Thread entweder mit einer  zu pausieren oder den Thread sogar ganz zu beenden und neu zu starten, wenn OPK neu angemacht wird.
Und warum zur Hölle benutzt ihr alle CreateThread, wenn es doch  gibt?
Edit:  solltet ihr mal lesen, wenn ihr effektiv mit Multithreading arbeiten wollt. Wobei das nur die Basics sind. ;-)
|
|
|
02/14/2013, 13:31
|
#708
|
elite*gold: 158
Join Date: Sep 2011
Posts: 878
Received Thanks: 2,493
|
Quote:
Originally Posted by __underScore
@Cyno: Warum lässt du den Thread weiterlaufen, wenn OPK nicht aktiv ist? Selbst wenn er nur Sleep() ausführt...
Richtig wäre wohl, den Thread entweder mit einer Condition-Variable zu pausieren oder den Thread sogar ganz zu beenden und neu zu starten, wenn OPK neu angemacht wird.
|
Ja da hast du wohl recht , wäre besser.
Ehm ich weiß nicht was "besser" ist und da ich damals CreateThread kennengelernt habe und eigentlich noch keine Probleme damit gehabt habe , verwende ich es bisher weiterhin.
Wenn du mich jedoch eines besseren belehren kannst , bin ich natürlich offen dafür die bessere Variante einzusetzen
Mfg Cyno
|
|
|
02/14/2013, 13:36
|
#709
|
elite*gold: 297
Join Date: Dec 2010
Posts: 1,129
Received Thanks: 1,687
|
Quote:
Originally Posted by Cyno™
Ehm ich weiß nicht was "besser" ist und da ich damals CreateThread kennengelernt habe und eigentlich noch keine Probleme damit gehabt habe , verwende ich es bisher weiterhin.
Wenn du mich jedoch eines besseren belehren kannst , bin ich natürlich offen dafür die bessere Variante einzusetzen
|
Ihr behauptet immer alle, C++ zu programmieren und doch nutzt ihr hauptsächlich Features von C. CreateThread ist eine Funktion aus der C Win32 API.
Die C++ Variante hat sehr, sehr viel mehr Features, die zwar irgendwo versteckt auch mit der Win32 API möglich sind, aber deshalb kaum einer nutzt.
Funktionen aus den Headern <future> und <thread> können ziemlich nützlich sein, wenn man Multithreading richtig machen will.
|
|
|
02/14/2013, 14:24
|
#710
|
elite*gold: 0
Join Date: Sep 2012
Posts: 182
Received Thanks: 223
|
Quote:
Originally Posted by __underScore
Ihr behauptet immer alle, C++ zu programmieren und doch nutzt ihr hauptsächlich Features von C. CreateThread ist eine Funktion aus der C Win32 API.
Die C++ Variante hat sehr, sehr viel mehr Features, die zwar irgendwo versteckt auch mit der Win32 API möglich sind, aber deshalb kaum einer nutzt.
Funktionen aus den Headern <future> und <thread> können ziemlich nützlich sein, wenn man Multithreading richtig machen will.
|
Das fängt doch schon beim Type Casting an .. ?
Es wird überall darauf hingewissen, das man die alte
C Methode nicht mehr verwenden soll & trotzdem
macht es noch jeder .. Oder sehe ich da was falsch ?
*(float*)(0x8B28C4) = 150.0F; /* C Style */
*reinterpret_cast<float*>(0x8B28C4) = 150.0F; /* C++ Style */
.. Natürlich gibt's jetzt verschiedene Casts
|
|
|
02/14/2013, 16:54
|
#711
|
elite*gold: 0
Join Date: Jun 2009
Posts: 11
Received Thanks: 0
|
if i may ask, noob question again Masters, where does "int index" comes in and how do i compute it in Cplayer that has a struct for x y z and nfd?
if ( i != pBase->m_pLocalPlayer->index )
why I said in Cplayer? because of this source:
struct CPlayer
{
int index;
float X;
float Y;
float Z;
};
all sources and codes from @Cyno™
Respect you Sir.
|
|
|
02/14/2013, 17:05
|
#712
|
elite*gold: 297
Join Date: Dec 2010
Posts: 1,129
Received Thanks: 1,687
|
It's your players index/slot in the room, which can ne found in what most people name CServer.
|
|
|
02/15/2013, 01:34
|
#713
|
elite*gold: 0
Join Date: Feb 2012
Posts: 82
Received Thanks: 18
|
int index; = myIndex? , Local_Index? or Global Index?
why when i use opk its to log...but i use
sleep ... but why logg again?
sleep(200);
i sue 200
Quote:
Originally Posted by R3d_L!n3
Seriously ?
Go back old old page and read what UnderSc.. said , just loop all player only u by doing if(Index != MyIndex)
|
i try but i get warrock crash
yes its w0rking
but after 5 mins in on
warrock crash XD! why?
|
|
|
02/15/2013, 03:03
|
#714
|
elite*gold: 0
Join Date: Jun 2009
Posts: 11
Received Thanks: 0
|
Quote:
Originally Posted by __underScore
It's your players index/slot in the room, which can ne found in what most people name CServer.
|
So how can i compute that Sir? thanks
Quote:
Originally Posted by __underScore
It's your players index/slot in the room, which can ne found in what most people name CServer.
|
Quote:
Originally Posted by babyiloveyou12
int index; = myIndex? , Local_Index? or Global Index?
why when i use opk its to log...but i use
sleep ... but why logg again?
sleep(200);
i sue 200
i try but i get warrock crash
yes its w0rking
but after 5 mins in on
warrock crash XD! why?
|
If i may ask, how did you got your index?
i have my Cplayer struct that have posxyz and nfd offsets... where does the index falls there?
if it is the slot in the room would i still need to place myself to that particular slot just to make myself move when in OPK.
thanks
Structs by @anythinga2
struct cPlayer
{
char Speaker13[20];//0x102EC
float PosX;//0x10300
char Speaker14[4];//0x10304
float PosY;//0x10310
char Speaker15[4];//0x10314
float PosZ;//0x10308
}; //size = 0x010310 (66320)
struct CBase
{
cPlayer* pLocal;//0xA4FEB0
char unknown0 [1212644];//0xA4FEB4
cPlayer** pGlobal;//0xB77F98
};CBase* p_Player = (CBase*)Adr_PlayerPointer;
i have a struct similar to this, sorry for the same question, how can get my index here? or this structs are incomplete for me the get the index in:
if ( i != pBase->m_pLocalPlayer->index )
thank you
edit: and it is for a no menu base
|
|
|
02/15/2013, 03:30
|
#715
|
elite*gold: 297
Join Date: Dec 2010
Posts: 1,129
Received Thanks: 1,687
|
Please learn programming using C or C++ from scratch, not from copy and pasting. Learn pointer arithmetics from scratch. Get to know the basics of Intel 80x86 Assembly (Intel Notation). From scratch.
Tips were given, explaining what to do. Look, if you didn't understand the english language you wouldn't be able to understand what I'm writing right here. Same applies to programming languages. Not understanding their syntax, semantics and paradigms makes you unable to understand what we are trying to tell you.
What do you really want? Us to give you perfectly copy- and pastable code or yourself to understand about the code?
|
|
|
02/15/2013, 04:21
|
#716
|
elite*gold: 0
Join Date: Feb 2012
Posts: 82
Received Thanks: 18
|
Quote:
Originally Posted by __underScore
Please learn programming using C or C++ from scratch, not from copy and pasting. Learn pointer arithmetics from scratch. Get to know the basics of Intel 80x86 Assembly (Intel Notation). From scratch.
Tips were given, explaining what to do. Look, if you didn't understand the english language you wouldn't be able to understand what I'm writing right here. Same applies to programming languages. Not understanding their syntax, semantics and paradigms makes you unable to understand what we are trying to tell you.
What do you really want? Us to give you perfectly copy- and pastable code or yourself to understand about the code?
|
rigth learn C++
now its w0rking on me
|
|
|
02/15/2013, 05:09
|
#717
|
elite*gold: 0
Join Date: Jun 2009
Posts: 11
Received Thanks: 0
|
Quote:
Originally Posted by __underScore
Please learn programming using C or C++ from scratch, not from copy and pasting. Learn pointer arithmetics from scratch. Get to know the basics of Intel 80x86 Assembly (Intel Notation). From scratch.
Tips were given, explaining what to do. Look, if you didn't understand the english language you wouldn't be able to understand what I'm writing right here. Same applies to programming languages. Not understanding their syntax, semantics and paradigms makes you unable to understand what we are trying to tell you.
What do you really want? Us to give you perfectly copy- and pastable code or yourself to understand about the code?
|
Got it... thanks
|
|
|
02/15/2013, 05:56
|
#718
|
elite*gold: 0
Join Date: Nov 2012
Posts: 51
Received Thanks: 21
|
About the Pink Thing its the Class of Player.
Code:
if ( ClassEsp )
{
char Class[100];
switch ( pInfo->pClass)
{
case 0: sprintf(Class,"Class :ENGINEER"); break;
case 1: sprintf(Class,"Class :MEDIC"); break;
case 2: sprintf(Class,"Class :SNIPER"); break;
case 3: sprintf(Class,"Class :ASSAULT"); break;
case 4: sprintf(Class,"Class :TROOPER"); break;
}
Bl4ck->DrawTextR(EspView.x,(EspView.y-100),aPink,Class,pFont);
EspView.y += 12;
}
This one should work
Code:
int pClass;//0x1BA0
|
|
|
02/15/2013, 15:10
|
#719
|
elite*gold: 0
Join Date: Jul 2011
Posts: 5
Received Thanks: 0
|
hi, i have a question about opk.
yes i have it working with structs, altough using it ingame gets me some strange results.
i go to the 0,0,0 point and all the players too, im not able to move but i expected that, but what happens is that the players keep getting send back and forth, (to the map back to 0,0,0) and you get like some sort of infinite loop thing, i tried adding while (true) to the opk code but that only resulted in a crash.
|
|
|
02/15/2013, 17:12
|
#720
|
elite*gold: 0
Join Date: Jun 2009
Posts: 11
Received Thanks: 0
|
I finally made it to work ... Thank you guys for the help Masters...
|
|
|
Similar Threads
|
WarRock EU - Code Snippets
07/12/2012 - WarRock - 7490 Replies
Hi Leute,
in diesem Thread könnt ihr:
-> Nach Sourcecodes fragen(Beispiel unten)
-> Eure Sourcecodes posten(Wenn sie nicht von euch sind mit Credits!)
-> Fragen ob eure Source evtl. einen Fehler hat
-> Fragen was welcher Fehler bedeuted
-> Sourcecodes entnehmen(Bitte beim Release dann Credits angeben!)
|
All times are GMT +1. The time now is 08:59.
|
|