Raised This Month: $7 Target: $400
 1% 

Programming for starters


Post New Thread Reply   
 
Thread Tools Display Modes
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 01-02-2017 , 07:26   Re: Programming for starters
Reply With Quote #101

I read the article. Global do have one serious problem, 'memory allocation issues' but I saw a lot of plugins worked perfectly using global variables some of them even a high-traffic plugin; 'Zombie Plague'
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-02-2017 , 07:36   Re: Programming for starters
Reply With Quote #102

> I read the article.

What article, I am curios.

> Global do have one serious problem, 'memory allocation issues'

Try read this article: http://wiki.c2.com/?GlobalVariablesAreBad.
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
So you need to learn to know when you are reading wrong things, and half, full, only 10% wrong/dubious information.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 01-02-2017 , 07:46   Re: Programming for starters
Reply With Quote #103

http://wiki.c2.com/?GlobalVariablesAreBad

Doing my best, sir.

One more question. In 'Array of Strings' .
PHP Code:
//To define an array of strings that you will assign a value to when defining:
new szString[][] = { "this" "is" "an" "array" "of" "strings" }
//strings are then accessed via the index of string. example szString[0] = "this", szString[1] = "is"

//If values assigned during run-time (example, for storing player names or steamID's when they connect)
new szString[number of strings][length of longest string
should in the 2-dimension string be this?
PHP Code:
new szString[][] = { "this" "is" "an" "array" "of" "strings""0" 
As, Quin had said there is always a 'NULL' character. Should "0" be there too?
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.

Last edited by JoKeR LauGh; 01-02-2017 at 07:47.
JoKeR LauGh is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-02-2017 , 08:09   Re: Programming for starters
Reply With Quote #104

> //If values assigned during run-time (example, for storing player names or steamID's when they connect)
> new szString[number of strings][length of longest string]

You cannot change the number of strings on run time for static arrays. It its because they are static so its size must to be know on compile time.
If you want to change the size on run time, consider Dynamic Arrays or create a static array which should be big enough.
For example, if you want to save a string for each server player, you can declare a array like:
Code:
new players[ MAX_PLAYERS + 1 ][ MAXIMUM_STRING_SIZE_YOU_WILL_EVER_SAVE_HERE ]

> As, Quin had said there is always a 'NULL' character.

Yes, however here "0" is not 0, it is a string within the values as 44 and 0.
When you do "Hi", pawn null terminate it for. The string will with the values as 65, 53 and 0.
String is pawn are just a chain of numbers, where the last one is always 0.
The "0" you see in strings on your screen are not the value 0 on the string array, but something like
the value 46. It is because the actual 0 is used to flag the end of the string.


> Should "0" be there too?

No, you do terminate strings, not arrays of strings. You do need to null terminate if you write you string like this.
Code:
new szString[][] = { {'s','t','r','i','g','s','^0'}, {'0','^0'} }
But only each one of the strings, not create one last string empty.

I barely strached the surface of real contents here. If I would explain to you all, it would be written a complete tutorial.
But there is not need to me to do it, there are already very good ones out there. Search for tutorials about strings in pawn.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 01-02-2017 at 08:11.
addons_zz is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 01-02-2017 , 08:30   Re: Programming for starters
Reply With Quote #105

Thank you, sir. Your explanation indeed really useful and informative. Thank you for your time.
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-10-2020 , 12:22   Re: Programming for starters
Reply With Quote #106

please post more tutorials
Grovliom is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-10-2020 , 20:53   Re: Programming for starters
Reply With Quote #107

What do you need help with
__________________
Bugsy is offline
rabbit111
Junior Member
Join Date: Nov 2020
Old 03-02-2023 , 22:32   Re: Programming for starters
Reply With Quote #108

Why it says PHP code in every sentence? isn't this Pawn Programming language"? *facepalm

Last edited by rabbit111; 03-02-2023 at 22:33.
rabbit111 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-02-2023 , 23:22   Re: Programming for starters
Reply With Quote #109

Quote:
Originally Posted by rabbit111 View Post
Why it says PHP code in every sentence? isn't this Pawn Programming language"? *facepalm
That is just the type of code block that is being used. The forum doesn't have syntax highlighting for more than just HTML and PHP. The PHP syntax highlighting works quite well for Pawn code so we use that often on these forums.
__________________
fysiks is offline
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 06:29.


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