AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help]Why does ppl use this and when? (https://forums.alliedmods.net/showthread.php?t=159066)

2reason2kill 06-12-2011 14:25

[Help]Why does ppl use this and when?
 
Why does ppl making things like

PHP Code:

new somting [32][33etc 

and when do u use them and why

:crab::crab::crab::crab:

fysiks 06-12-2011 15:04

Re: [Help]Why does ppl use this and when?
 
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"
}


2reason2kill 06-12-2011 15:18

Re: [Help]Why does ppl use this and when?
 
Quote:

Originally Posted by fysiks (Post 1486599)
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?

nikhilgupta345 06-12-2011 15:21

Re: [Help]Why does ppl use this and when?
 
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

fysiks 06-12-2011 15:22

Re: [Help]Why does ppl use this and when?
 
Quote:

Originally Posted by 2reason2kill (Post 1486622)
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.

2reason2kill 06-12-2011 15:27

Re: [Help]Why does ppl use this and when?
 
Tnx all


All times are GMT -4. The time now is 23:29.

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