Raised This Month: $ Target: $400
 0% 

Optimizing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Storas1337
Senior Member
Join Date: Apr 2009
Location: Lithuania
Old 05-25-2014 , 14:40   Optimizing
Reply With Quote #1

Hey guys anybody can give me an example how to optimize these part of code (with switch statement)

Code:
else if(equali(arg_cmd, "slay")) 
	{ 
		if(!(get_user_flags(id) & ADMIN_SLAY)) 
		{ 
			ColorChat(id, NORMAL, "^4Only ADMINS can use the command!^4", Prefix) 
			return 
		} 
		
		if(equali(arg2, "")) 
		{ 
			ColorChat(id, NORMAL, "^4You should enter some name!^4", Prefix) 
			return 
		} 
		
		if(!target) 
		{ 
			ColorChat(id, NORMAL, "^4There is not a player wit this name!^4", Prefix, arg2) 
			return 
		} 
		
		client_cmd(id, "amx_slay ^"%s^"", arg2) 
	}
Storas1337 is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 05-25-2014 , 14:48   Re: Optimizing
Reply With Quote #2

PHP Code:
switch(get_user_flags(id))
{
    case 
blabla:

?
Torge is offline
Storas1337
Senior Member
Join Date: Apr 2009
Location: Lithuania
Old 05-25-2014 , 15:34   Re: Optimizing
Reply With Quote #3

I need more detailed example there is more code for ex

PHP Code:
  if(equali(arg_cmd"/hp")) 
    { 
   
        if(!(
get_user_flags(id) & ADMIN_BAN)) 
        { 
            
ColorChat(idNORMAL"%s^1Only ^3admins^1 can use the command^4!"Prefix
            return 
        } 
         
  
        if(
equali(arg2"")) 
        { 
            
ColorChat(idNORMAL"%s^1You should enter some name^4!"Prefix
            return 
        } 
Storas1337 is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 05-25-2014 , 17:57   Re: Optimizing
Reply With Quote #4

This can't be done with switch statement. Your code is fine.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Storas1337
Senior Member
Join Date: Apr 2009
Location: Lithuania
Old 05-25-2014 , 18:35   Re: Optimizing
Reply With Quote #5

Quote:
Originally Posted by GuskiS View Post
This can't be done with switch statement. Your code is fine.
Yes i know that fine, i just want to load less cpu
Storas1337 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-25-2014 , 18:59   Re: Optimizing
Reply With Quote #6

Well, I have already thought about that, when sent it to you, but there is no other way to make it. Only way, I guess, is by these 'if' statements to check the conditions.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Storas1337
Senior Member
Join Date: Apr 2009
Location: Lithuania
Old 05-25-2014 , 19:26   Re: Optimizing
Reply With Quote #7

ok thank you guys i was curious ;)
Storas1337 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 15:22.


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