Raised This Month: $ Target: $400
 0% 

[HELP] Some questions to ask :D


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-14-2009 , 10:32   Re: [HELP] Some questions to ask :D
Reply With Quote #6

Quote:
Originally Posted by --kml-- View Post
1) What is the usefull of static?
2) when i put g_ to a code does it changes it to global or just labelling and same to sz does it make it string? or just labelling.
1. Using static variables
  • The function is being called very frequently.
  • If the variable requires a lot of memory allocation. Commonly used for large strings\arrays.
  • If you wish the data to remain static [stored in memory between function calls].

2. Pawn does not have different data types so keep that in mind; the language uses only a 4-byte data type called a cell for everything. You can tag a variable with 'Float:' or 'bool:' which tells Pawn how to handle the data stored in the cell but regardless of tagging, it is still a 4-byte cell. There is no string type; a string is only an array of cells, each cell holding a character.

Using g_ to prefix a variable is just to remind the scripter [or others looking at your code] that the variable is declared as global [is accessible throughout the script]. This will also prevent accidental use of the incorrect variable if you use the same name for a variable that is declared global and within a function. sz does not do any type of variable declaration either, it is just to signify what kind of data is stored in the variable. You may also see people tag other variables such as iValue [signifying integer] or fValue [signifying float] or bValue [signifying bool [true\false]]
__________________

Last edited by Bugsy; 05-14-2009 at 10:35.
Bugsy 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 01:28.


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