Raised This Month: $51 Target: $400
 12% 

Solved How to allow empty statements?


Post New Thread Reply   
 
Thread Tools Display Modes
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 10-21-2018 , 20:22   Re: How to allow empty statements?
Reply With Quote #11

Empty statements are pretty useless, honestly. If it's gonna be empty, why not change the conditions inside the statement to be the opposite, so that it does NOT stay empty? Having an empty statement is the equivalent of not having a statement at all, in terms of usage.

PHP Code:
// Empty statement
if (!foo(0a) && !foo(1a) && !foo(2a))
{
    
//
}

// Not empty
if (foo(0a) || foo(1a) || foo(2a))
{
    
dummy();

__________________
Psyk0tik is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-21-2018 , 21:06   Re: How to allow empty statements?
Reply With Quote #12

KliPPy, hmm, sure, it's an option. Though, logic is now less intuitive readable.

Quote:
Originally Posted by MasterMind420
i'm not even really sure what this guys trying to do.
Just a matter of convenience, like if I have these lines:

Code:
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_M16, g_bForbid_M16, "weapon_rifle"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_Sniper, g_bForbid_Sniper, "weapon_hunting_rifle"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_AutoShot, g_bForbid_AutoShot, "weapon_autoshotgun"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_PumpShot, g_bForbid_PumpShot, "weapon_pumpshotgun"))
		GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_SMG, g_bForbid_SMG, "weapon_smg");
And at some point of time if I would like to swap a couple of lines between each other (like, first and last line). I can't do that. I need to to add "if (" to the last line and remove "if (" from 1-st line, then swap.

But, in this sample:
Code:
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_M16, g_bForbid_M16, "weapon_rifle"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_Sniper, g_bForbid_Sniper, "weapon_hunting_rifle"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_AutoShot, g_bForbid_AutoShot, "weapon_autoshotgun"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_PumpShot, g_bForbid_PumpShot, "weapon_pumpshotgun"))
	if (!GiveOrRemoveWeaponOnCondition(client, 0, g_bStartItem_SMG, g_bForbid_SMG, "weapon_smg"))
{ dummy() }
I can swap any lines without modification.

--------------------------------

MasterMind420, thank you. I see my mistake. I have extra semicolon after {} in my 1-st post. Really stupid mistake.
Topic is resolved. Thanks for all.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 10-21-2018 at 21:09.
Dragokas is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode