Raised This Month: $ Target: $400
 0% 

some questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tomusaki
Junior Member
Join Date: Nov 2011
Old 11-10-2011 , 13:50   some questions
Reply With Quote #1

Hello all,
As i said in another theme i'm learning scripting, and i need help from you.
So my questions are:
1.) what does the number in new variables means ? For example: new guns[33], new grenades[33], new maxplayers[33] and etc..
2.) What does cid means ?
Thats all for now, if i have more questions i will post them in to this theme.
Thank you for answers!
Tomusaki is offline
KillLikoe
BANNED
Join Date: Nov 2010
Location: Paraguay
Old 11-10-2011 , 19:34   Re: some questions
Reply With Quote #2

1- the size of the cells, in that variables the size is 33 because it have to contain all the player`s index, start from 1 until 32 and you have to left a cell i dont know why
KillLikoe is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 11-10-2011 , 19:37   Re: some questions
Reply With Quote #3

http://wiki.amxmodx.org/Pawn_Tutorial#Arrays
Devil259 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-10-2011 , 20:08   Re: some questions
Reply With Quote #4

Quote:
Originally Posted by KillLikoe View Post
1- the size of the cells, in that variables the size is 33 because it have to contain all the player`s index, start from 1 until 32 and you have to left a cell i dont know why
Arrays start from 0.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
KillLikoe
BANNED
Join Date: Nov 2010
Location: Paraguay
Old 11-10-2011 , 20:20   Re: some questions
Reply With Quote #5

Quote:
Originally Posted by drekes View Post
Arrays start from 0.
i was talking about, why to use number 33 for global variables, but yes it starts from zero
KillLikoe is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-10-2011 , 20:35   Re: some questions
Reply With Quote #6

Quote:
Originally Posted by KillLikoe View Post
1- the size of the cells, in that variables the size is 33 because it have to contain all the player`s index, start from 1 until 32 and you have to left a cell i dont know why
@KillLikoe

The size of a cell is 4-bytes which cannot be changed, it would be better to say 33 is the size of the array. I know what you meant to say but its best to try and not confuse people.

"and you have to left a cell i dont know why"

See below, though you are correct, a cell is wasted which is index 0 since 0 is not a valid player index, only 1-32 is.

@KillLikoe & Tomusaki

The most common reason for seeing arrays sized at 33 (or MAXPLAYERS+1) is for storing data for each individual player using the player-index as the array index. When you need to index an array you start at 0 and go up to size-1, so if an array is sized at var[33] you can do var[0] up to var[32] to access each item; index 0 counts as an item in the array so index 32 is the 33rd cell. Player indexes in HL\CS range from 1 to 32 so you need an array sized at 33 (or larger) to make it possible to store/retrieve player info like var[ player-id ].
__________________

Last edited by Bugsy; 11-10-2011 at 20:38.
Bugsy 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:25.


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