Raised This Month: $ Target: $400
 0% 

I need an explanation of a define


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-13-2010 , 03:44   I need an explanation of a define
Reply With Quote #1

Hi,

Well, nothing... i just don't understand this code:

PHP Code:
#define MAX_ENTS    900 +  MAX_PLAYERS * 15
#define HOLDING_ENTS_ARRAY_SIZE    (MAX_ENTS / 32) + _:!!(MAX_ENTS % 32) 
Something can explain me this?

Also, apart of this... i see in some codes using two "!!", like in the code above... what means that?

Thanks
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 06-13-2010 , 04:26   Re: I need an explanation of a define
Reply With Quote #2

MAX_ENTS simply tells how many entities can possibly be in the map. So instead of writing "900 + MAX_PLAYERS * 15" all the time, you use MAX_ENTS.

!! means "no" to "no", but giving you a bool value (1 or 0). If you had number 10, it will return number 1, if you had 0, you'll get 0.
Code:
new Number = 20;
Code:
Number = !Number // Number is now 0 ("not 20")
Code:
Number = 20; Number = !!Number; // Number is now 1 ("not 20" is 0, "not 0" is 1)
The "HOLDING_ENTS_ARRAY_SIZE" define is probably used to set the side of an array which holds the data of (all?) entities.

I'm not really familiar with "%", I'm afraid.
__________________

Last edited by hleV; 06-13-2010 at 04:30.
hleV is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-13-2010 , 04:45   Re: I need an explanation of a define
Reply With Quote #3

According to arkshine,

900 + MAX_PLAYERS * 15

should be replaced with :

900 + (MAX_PLAYERS-1) * 15

not that in plugins you can see, MAX_PLAYERS is 32 because they are public, but if you make a private plugin you can replace it with the real maxplayer amount of your server.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-13-2010 , 05:20   Re: I need an explanation of a define
Reply With Quote #4

Don't why they remove -1 ; it would make sense to use MAX_PLAYERS.
__________________
Arkshine is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-13-2010 , 10:06   Re: I need an explanation of a define
Reply With Quote #5

I know the basic things -.- like define and others... i added the first define so you can understand the second define.

The part that i didn't understand at all is exactly this:

PHP Code:
_:!!(MAX_ENTS 32
Thanks hleV for the !! explanation...

@ Connor

The code is used in your plugin kz buttonlocs xd

Thanks to all
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-13-2010 , 12:26   Re: I need an explanation of a define
Reply With Quote #6

@Alucard^
The % operator is the modulo operator. It returns the remainder after division. So if you did 8 % 5, you'd get 3 as a return value. The _: "untags" certain things. For example, if you did something like
PHP Code:
new iTeam _:cs_get_user_teamid )

// tag mismatch
if( cs_get_user_teamid ) == CS_TEAM_T ) {}

// untagged, so it is not a mismatch
if( cs_get_user_teamid ) == ) {} 
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Old 06-13-2010, 15:02
Bugsy
This message has been deleted by Bugsy. Reason: Oops
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-13-2010 , 12:34   Re: I need an explanation of a define
Reply With Quote #8

Oh thanks...

About the _: thing... if i understand is for not use the enum things right?

Thanks
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-13-2010 , 12:39   Re: I need an explanation of a define
Reply With Quote #9

Yes, it's more commonly used to detag members of an enum (don't know the pawn terminology for member).

No problem.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-13-2010 , 18:37   Re: I need an explanation of a define
Reply With Quote #10

Quote:
// no tag mismatch whether iTeam is tagged or not.
if( iTeam == CS_TEAM_T )
For your information, CS_TEAM_T is tagged, you will get a tag mismatch since iTeam is not tagged.
__________________
Arkshine 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 14:55.


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