Re: [TUT] Code Styling & Good Programming Habits
Because the post didn't mention it, and i didn't read all 9 pages of comments I shall say something (very short) on macros
Macros rock. Basically a really quick way of writing a static (as in nothing in it will change) one-line function. To make calculations easier to read, easier to put into your code, and even grab parts of code required to be used many times. If you are using a macro with more than one parameter you cannot separate them with commas (my main point) And each parameter will be prefixed with a % followed by an identifier. I'm not sure if this convention can change....but it seems to be accepted, so i'm going with it. For instance....you have three arrays. One holds indexes to each of the two other arrays. You can combine these two array indexes using a macro with some simple math in it. Then two other macros to retrieve them. See my code.... PHP Code:
Hope i helped. Good day. |
Re: [TUT] Code Styling & Good Programming Habits
Macros with commas work well, you can't put spaces in them that's all.
See : PHP Code:
|
Re: [TUT] Code Styling & Good Programming Habits
Quote:
Also note: you need to keep the same delimiter throughout your code. If you were to choose SET_DATA(%1,%2) you would not be able to call it with SET_DATA(%1 %2) and same goes the other way around. |
Re: [TUT] Code Styling & Good Programming Habits
I suggest you to read the Pawn Language Guide on page 92 "The preprocessor"
|
Re: [TUT] Code Styling & Good Programming Habits
Hey, why write "0"?
PunishUser( id ) { #if defined KILL_USER user_kill( id ) client_print( 0, print_chat, "[Kill] The user has been killed") #else // KILL_USER user_slap( id, 0 ) client_print( 0, print_chat, "[Kill] The user has been slapped") #endif // KILL_USER } |
Re: [TUT] Code Styling & Good Programming Habits
When instead of player ID you use 0, the function/native (as long as it's designed that way) is applied to all players.
|
Re: [TUT] Code Styling & Good Programming Habits
Quote:
|
Re: [TUT] Code Styling & Good Programming Habits
Awesome tutorial Hawk.
I also want to see updates! |
Re: [TUT] Code Styling & Good Programming Habits
Good old days :)
|
All times are GMT -4. The time now is 11:05. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.