Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Snippet Exchange

Joined
Aug 14, 2009
Messages
2,304
Reaction score
1,189
Did you found a piece of code that would be useful to share? Or a line that is interesting? Share it here!

Example:

AI_Player.cpp, Line 2800:
Code:
while(true)
{
r3dOutToLog("Still here?\n");
sleep(2000);
}

Explanation:
Stupid little code ;)

Change item hover color:
r3dObj.cpp, Line ~1554:
Code:
SetFillGBufferConstantPixelShader([COLOR="#FF0000"] r3dColor::blue[/COLOR], 1.0f, normal, 0.0f, 0.0f, r_highlight_glow->GetFloat(), 0.f );
 
Last edited:
Junior Spellweaver
Joined
Aug 13, 2014
Messages
100
Reaction score
38
[Snippet] Login with Username! No more email login!

Changing launcher email to username.

Note: Usernames can contain most characters such as username$!*

Search for the code below in RSUpdate.sln

Code:
int spc_email_isvalid(const char *address) 
{
  int        count = 0;
  const char *c, *domain;
  static char *rfc822_specials = "()<>@,;:\\\"[]";


  // first we validate the name portion (name@domain)
  for (c = address;  *c;  c++) {
    if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == 
        '\"')) {
      while (*++c) {
        if (*c == '\"') break;
        if (*c == '\\' && (*++c == ' ')) continue;
        if (*c <= ' ' || *c >= 127) return 0;
      }
      if (!*c++) return 0;
      if (*c == '@') break;
      if (*c != '.') return 0;
      continue;
    }
    if (*c == '@') break;
    if (*c <= ' ' || *c >= 127) return 0;
    if (strchr(rfc822_specials, *c)) return 0;
  }
  if (c == address || *(c - 1) == '.') return 0;


  // next we validate the domain portion (name@domain)
  if (!*(domain = ++c)) return 0;
  do {
    if (*c == '.') {
      if (c == domain || *(c - 1) == '.') return 0;
      count++;
    }
    if (*c <= ' ' || *c >= 127) return 0;
    if (strchr(rfc822_specials, *c)) return 0;
  } while (*++c);


  return (count >= 1);
}

Then simply replace with this code below.

Code:
/*
int spc_email_isvalid(const char *address) 
{
  int        count = 0;
  const char *c, *domain;
  static char *rfc822_specials = "()<>@,;:\\\"[]";


  // first we validate the name portion (name@domain)
  for (c = address;  *c;  c++) {
    if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == 
        '\"')) {
      while (*++c) {
        if (*c == '\"') break;
        if (*c == '\\' && (*++c == ' ')) continue;
        if (*c <= ' ' || *c >= 127) return 0;
      }
      if (!*c++) return 0;
      if (*c == '@') break;
      if (*c != '.') return 0;
      continue;
    }
    if (*c == '@') break;
    if (*c <= ' ' || *c >= 127) return 0;
    if (strchr(rfc822_specials, *c)) return 0;
  }
  if (c == address || *(c - 1) == '.') return 0;


  // next we validate the domain portion (name@domain)
  if (!*(domain = ++c)) return 0;
  do {
    if (*c == '.') {
      if (c == domain || *(c - 1) == '.') return 0;
      count++;
    }
    if (*c <= ' ' || *c >= 127) return 0;
    if (strchr(rfc822_specials, *c)) return 0;
  } while (*++c);


  return (count >= 1);
}
*/
 
Last edited:
Junior Spellweaver
Joined
Aug 13, 2014
Messages
100
Reaction score
38
[Snippet] Player Join / Left Game!

How to enable "Player1 Joined" and "Player2 Left" game when they join or leave.

Open WarZ.sln

Find the code below and simply untoggle it same for the left function also below.

Code:
        wchar_t tempStr[64];
        char plrUserName[64]; GetUserName(plrUserName);
        swprintf(tempStr, 64, gLangMngr.getString("$HUD_Msg_JoinedGame"), utf8ToWide(plrUserName));
        if(hudMain)
            hudMain->showMessage(tempStr);

And the left function.

Code:
    wchar_t tempStr[64];
    char plrUserName[64]; GetUserName(plrUserName);
    swprintf(tempStr, 64, gLangMngr.getString("$HUD_Msg_LeftGame"), utf8ToWide(plrUserName));
    if(hudMain)
        hudMain->showMessage(tempStr);
 
Last edited:
Joined
Aug 14, 2009
Messages
2,304
Reaction score
1,189
Function to make print screen screenshots / full screen screenshots, captures the whole desktop.

Please be aware: If you don't point to a TOS saying that you're taking Full screen / print screen screenshots it's in some countries ILLEGAL to do so!

Code:
int r3dMakePrintScreenScreenshot()
{
	SAFE_RELEASE(_r3d_screenshot_copy);

	IDirect3DSurface9* BBuf;
	r3dRenderer->GetRT( 0, &BBuf);

	HRESULT hr = r3dRenderer->pd3ddev->CreateTexture(_r3d_sscopy_width, _r3d_sscopy_height, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &_r3d_screenshot_copy, NULL);

	r3dRenderer->CheckOutOfMemory( hr );

	int success = 0;

	if( D3D_OK == hr )
	{
		IDirect3DTexture9* sysmemBBTex = r3dRenderer->GetTempTextureForFrontBufferCopy();

		D3DSURFACE_DESC copySurfDesc;

		D3D_V( sysmemBBTex->GetLevelDesc( 0, &copySurfDesc ) );

		struct ReleaseSurface
		{
			~ReleaseSurface()
			{
				SAFE_RELEASE( surf );
			}

			IDirect3DSurface9* surf;
		} fbSurf = { 0 }; (void)fbSurf;

		D3D_V( sysmemBBTex->GetSurfaceLevel( 0, &fbSurf.surf ) );

		HRESULT getRTHR = r3dRenderer->pd3ddev->GetFrontBufferData( 0, fbSurf.surf );

		if( getRTHR == D3DERR_DEVICELOST )
		{
			r3dRenderer->SetDeviceLost();
		}

		if( getRTHR != S_OK )
		{
			BBuf->Release();
			return 0;
		}

		IDirect3DSurface9* pSurf0 = NULL;
		_r3d_screenshot_copy->GetSurfaceLevel(0, &pSurf0);

		RECT srcRect;
		GetWindowRect(GetDesktopWindow(), &srcRect); // FrontBuffer / PrintScreen images!

		if( srcRect.left != srcRect.right 
				&&
			srcRect.top != srcRect.bottom 
			)
		{
			if( D3DXLoadSurfaceFromSurface(pSurf0, NULL, NULL, fbSurf.surf, NULL, &srcRect, D3DX_FILTER_TRIANGLE, 0) ==  S_OK )
			{
				success = 1;
			}
		}

		SAFE_RELEASE(pSurf0);
	}

	BBuf->Release();

	return success;
}
 
Skilled Illusionist
Joined
May 17, 2013
Messages
309
Reaction score
206
Re: [Snippet] Player Join / Left Game!

How to enable "Player1 Joined" and "Player2 Left" game when they join or leave.

Open WarZ.sln

Find the code below and simply untoggle it same for the left function also below.

Code:
        wchar_t tempStr[64];
        char plrUserName[64]; GetUserName(plrUserName);
        swprintf(tempStr, 64, gLangMngr.getString("$HUD_Msg_JoinedGame"), utf8ToWide(plrUserName));
        if(hudMain)
            hudMain->showMessage(tempStr);

And the left function.

Code:
    wchar_t tempStr[64];
    char plrUserName[64]; GetUserName(plrUserName);
    swprintf(tempStr, 64, gLangMngr.getString("$HUD_Msg_LeftGame"), utf8ToWide(plrUserName));
    if(hudMain)
        hudMain->showMessage(tempStr);

This only works if player are near you.
 
Experienced Elementalist
Joined
Aug 20, 2015
Messages
205
Reaction score
43
Go Navicat -> Functions -> WZ_ClanCreateCheckParams ->
Search :
select 29 as ResultCode, 'time played' as ResultMsg

Change :
-- kaldırdım kodumun timesini burak ----[]
if(@timePlayed < 0) begin
select 29 as ResultCode, 'time played' as ResultMsg
return
end

WAR TURKEY DEVELOPERs

:junglejane: Go Navicat and -> Functions -> WZ_ServerGetPrices

Server Prices on this area :)
-- GAMESERVER prices
select
0 as 'Base_US', -- 8500 base price per server per month in US region. 0 if region is disabled
0 as 'Base_EU', -- 8500 base price per server per month in europe region. 0 if region is disabled
0 as 'Base_RU', -- 8500 base price per server per month in russian region. 0 if region is disabled
0 as 'Base_SA', -- South america. Should be 3x price of US\EU server due to high cost of renting
and
0 as 'Base_US', -- base price per server per month in US region. 0 if region is disabled
0 as 'Base_EU', -- base price per server per month in europe region. 0 if region is disabled
0 as 'Base_RU', -- base price per server per month in russian region. 0 if region is disabled
0 as 'Base_SA',
 
Last edited by a moderator:
Joined
Aug 14, 2009
Messages
2,304
Reaction score
1,189
Helper function to detect a VMWare environment:
Code:
bool IsInsideVMWare()
{
	bool rc = true;

	__try
	{
		__asm
		{
			push   edx
				push   ecx
				push   ebx

				mov    eax, 'VMXh'
				mov    ebx, 0 // any value but not the MAGIC VALUE
				mov    ecx, 10 // get VMWare version
				mov    edx, 'VX' // port number

				in     eax, dx // read port
				// on return EAX returns the VERSION
				cmp    ebx, 'VMXh' // is it a reply from VMWare?
				setz   [rc] // set return value

			pop    ebx
				pop    ecx
				pop    edx
		}
		return true;
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
	}
	unsigned int	a	= 0;

	__try {
		__asm {

			// save register values on the stack
			push eax
				push ebx
				push ecx
				push edx

				// perform fingerprint
				mov eax, 'VMXh'		// VMware magic value (0x564D5868)
				mov ecx, 14h		// get memory size command (0x14)
				mov dx, 'VX'		// special VMware I/O port (0x5658)

				in eax, dx			// special I/O cmd

				mov a, eax			// data 

				// restore register values from the stack
				pop edx
				pop ecx
				pop ebx
				pop eax
		}
		if(a > 0)
			return true;
	} __except (EXCEPTION_EXECUTE_HANDLER) {}
	unsigned char	idtr[6];
	unsigned long	idt	= 0;

	_asm sidt idtr
	idt = *reinterpret_cast<unsigned long *>(&idtr[2]);
	if ((idt >> 24) == 0xff)
		return true;
	unsigned char   gdtr[6];
	unsigned long   gdt	= 0;

	_asm sgdt gdtr
	gdt = *reinterpret_cast<unsigned long *>(&gdtr[2]);
	if ((gdt >> 24) == 0xff)
		return true;

	return false;
}
 
Skilled Illusionist
Joined
Jan 22, 2014
Messages
310
Reaction score
323
[FIX] FrontEnd color correction bug fix (when player health <30)

FrontEnd color correction bug fix (when player health <30)

Removes the black and white effect in frontend

Search in WarZ.sln:
Code:
SetLoadStage([COLOR=#8b4513]"Player Model"[/COLOR]);
 {
Add this:
Code:
[COLOR=#008080]PFX_3DLUTColorCorrection[/COLOR]::s_damageHitColorCorrectionVal = [COLOR=#008000]0.0f[/COLOR];
 
Last edited by a moderator:
☆Dying Dawn☆
Joined
Jan 30, 2012
Messages
971
Reaction score
727
Barricade color Placement

Code:
m_BarricadeMeshPlacement->AppendTransparentRenderables( render_arrays[rsDrawTransparents], m_canPlaceConsumableItem?r3dColor::[COLOR=#0000CD]blue[/COLOR]:r3dColor::[COLOR=#FF8C00]orange[/COLOR], dist, 1 );
barricade - Snippet Exchange - RaGEZONE Forums barricade2 - Snippet Exchange - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Last edited:
Elite Diviner
Joined
Apr 3, 2013
Messages
476
Reaction score
204
To Put a game First Person Only Change

Code:
REG_VAR_C( g_camera_mode        , 1,    0, 2, VF_SAVE|VF_CONSTRAINT );

to

Code:
REG_VAR_C( g_camera_mode        , 2,    2, 2, VF_SAVE|VF_CONSTRAINT );

Due i found the Side note

Code:
// 0 - TPS mode, crosshair in center, 1- TPS mode, crosshair off-center, 2 - FPS mode

Just search for the Side note

(Quick and Dirty and it Works :D)
 
Elite Diviner
Joined
Apr 3, 2013
Messages
476
Reaction score
204
To Change Chat Colors or Names Search for

Code:
char tmpMsg[1024];
    const char* tabNames[] =
    const char* tabNamesColor[] =
    const char* userNameColor[] =

it should looks like this

Code:
char tmpMsg[1024];
    const char* tabNames[] = {"[Proximity]", "[Global]", "[Clan]", "[Group]"};
    const char* tabNamesColor[] = {"#b20101", "#0194b2", "#f0ee00", "#0004db"};
    const char* userNameColor[] = {"#ffffff", "#ffa800"};

Its easy to Understand what u have to Change u also can rename them it works ingame aswell

This is my
Code:
char tmpMsg[1024];
	const char* tabNames[] = {"[Local Chat]", "[Global Chat]", "[Friends]", "[System]"};
	const char* tabNamesColor[] = {"#b20101", "#0194b2", "#f0ee00", "#0004db"};
	const char* userNameColor[] = {"#ffffff", "#ffa800"};

FfbN4iM - Snippet Exchange - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Last edited:
☆Dying Dawn☆
Joined
Jan 30, 2012
Messages
971
Reaction score
727
Fix Player Gender Sound When Die

search for this
Code:
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/MainMenu GUI/UI_player_death"), GetPosition());

and replace with this
Code:
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath(m_isFemaleHero?"Sounds/WarZ/PlayerSounds/PLAYER_OVERUN_F":"Sounds/WarZ/PlayerSounds/PLAYER_OVERUN_M"), GetPosition()); //Fix By:: Bombillo

Your Female Char have the same sound than Male?

Then add your female character code here
Code:
m_isFemaleHero = CurLoadout.HeroItemID==20184||CurLoadout.HeroItemID==20194||CurLoadout.HeroItemID==20195;

Thanks
 
Joined
Apr 23, 2013
Messages
1,172
Reaction score
1,786
Re: Show dollar reward kill zumbies

if your warz has auto gain US dollars to kill zombies, put this for look dollar reward

search: sprintf(tmpStr, gLangMngr.getString("InfoMsg_XPAdded"), n.XP);
Code:
if(n.GD > 0)
{
    char tmpStr[64];
    sprintf(tmpStr, gLangMngr.getString("InfoMsg_GDAdded"), n.GD);
    hudMain->showMessage(tmpStr);
}
 
Skilled Illusionist
Joined
Jan 22, 2014
Messages
310
Reaction score
323
Fix FPS drops while shooting

Hello guys,

does maybe someone know how to fix the bug that you get low fps when youre shooting?
Would be awesome if someone would help me with this!
Find in BulletShellManager.cpp
Code:
const float BULLET_LIFETIME = [COLOR=#b22222]15.0f[/COLOR];
and change to
Code:
const float BULLET_LIFETIME = [COLOR=#b22222]0.5f[/COLOR];
It should help
 
Joined
Apr 23, 2013
Messages
1,172
Reaction score
1,786
Crosshair color
Code:
r3dDrawBox2D(float(cx-(rw/2)), float(yy-(rh/2)), rw, rh, r3dColor::[COLOR=#ff0000][B]white[/B][/COLOR], scopeConfig->reticule);

Used for options change color

gSxbWKG - Snippet Exchange - RaGEZONE Forums

48bQVGK - Snippet Exchange - RaGEZONE Forums

GigaToni - Snippet Exchange - RaGEZONE Forums

GigaToni - Snippet Exchange - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Last edited:
Back
Top