Raised This Month: $ Target: $400
 0% 

How does pawn handle arrays and which way is better.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-30-2013 , 18:55   How does pawn handle arrays and which way is better.
Reply With Quote #1

Hello, Im pretty curious about arrays like this
PHP Code:
new something[256
now there is
PHP Code:
new something[4// lets do small array for example, i ofcourse prefer always the big ones :)

public myfunction(posvalue)
{
     
something[pos] = value


is it same like this?
PHP Code:
new something0,something1,something2,something3
public myfunction(posvalue)
{
     switch(
pos)
    {
        case 
0something0 value
        
case 1something1 value
        
case 2something2 value
        
case 3something3 value

    
}


the way i understand things right now is that the first code is better and faster way and it does not matter if the array size is big or small, it does not effect the cpu speed.

I was an idea for creating big array like this Float:chuckdata[8000][3]
so inside of chuckdata are costom areas ( values are in bit )
so i can just easily check that if player is in costom area
PHP Code:
static Float:o[3],ab
pev
(idpev_origino)
for( 
03a++ )  
{
floatround(o[a] + 4000.0)
// i dont know that if its right, i dont know about bits, never tested them and i was thinking that they are useless what is very wrong. I want to check here like if( o[a] != mybit) you know what i mean with that... :)
if( chuckdata[b][a] ~ mybit) return
}

// and now if cpu is here then player is standing in area what is in my database.
// i need to use bits because then i can but more than one areas in one place for example ( and also if area is inside of ohter area, bits will help me. ) 
2years ago i didn't care about coding methods for example it was fine to me to check what weapon player is holding in prethink. If that was working then it was just fine to me but now i want that everything is perfect.

I hope i can get some feedback ( my "string checking in prethink" topic is like an empty desert : /)
Thanks!

Last edited by .Dare Devil.; 04-30-2013 at 18:57.
.Dare Devil. is offline
 



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 10:57.


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