Raised This Month: $ Target: $400
 0% 

[Help]Why does ppl use this and when?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-12-2011 , 14:25   [Help]Why does ppl use this and when?
Reply With Quote #1

Why does ppl making things like

PHP Code:
new somting [32][33etc 
and when do u use them and why

2reason2kill is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2011 , 15:04   Re: [Help]Why does ppl use this and when?
Reply With Quote #2

It is just a multi-dimensional array. There are many uses for them. Commonly in Pawn they are used for arrays of strings (since a string is just an array of characters).

Code:
new strings[][] = {
    "hello",
    "good bye",
    "good day"
}
__________________
fysiks is online now
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-12-2011 , 15:18   Re: [Help]Why does ppl use this and when?
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
It is just a multi-dimensional array. There are many uses for them. Commonly in Pawn they are used for arrays of strings (since a string is just an array of characters).

Code:
new strings[][] = {
    "hello",
    "good bye",
    "good day"
}
i saw somting like


PHP Code:
new g_team[33
why is it number 33?


is it same?
2reason2kill is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-12-2011 , 15:22   Re: [Help]Why does ppl use this and when?
Reply With Quote #4

Quote:
Originally Posted by 2reason2kill View Post
i saw somting like


PHP Code:
new g_team[33
why is it number 33?


is it same?
That is a single dimension array containing 33 cells. 33 is used most often when it will be index by player entity index and there are at most 32 players in a server at any given time.

So, in a function they can retrieve a number stored for that person:

PHP Code:
public saycommand(id)
{
    
client_print(idprint_chat"Your team is %d"g_team[id])

If you look at other plugins you will see that it is used often and you will see for what they use it for.
__________________
fysiks is online now
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-12-2011 , 15:27   Re: [Help]Why does ppl use this and when?
Reply With Quote #5

Tnx all
2reason2kill is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 06-12-2011 , 15:21   Re: [Help]Why does ppl use this and when?
Reply With Quote #6

33 is the amount of cells that it has, or the number or items that it can hold. Since CS 1.6 servers can only have a max of 32 players, they make it 33 ( 32 + 1 ). Player id's cannot be 0, where the array starts at, so they want to be able to just use an id as is, instead of having to do id - 1
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Reply


Thread Tools
Display Modes

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 23:29.


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