SA-MP Forums

SA-MP Forums (http://forum.sa-mp.com/index.php)
-   Discussion (http://forum.sa-mp.com/forumdisplay.php?f=84)
-   -   Today I learned - Share your newly found knowledge! (http://forum.sa-mp.com/showthread.php?t=359953)

Slice 15/07/2012 10:01 PM

Today I learned - Share your newly found knowledge!
 
Yes, just like reddit.

Simple. If you learned something new related to SA-MP scripting, share it here!

Please:
  • Explain what it is you learned, don't just say you learned something. <----
  • Try keeping it concise.
  • Don't post stupid pictures or otherwise annoying, non-related stuff.
  • Don't link to or quote posts then say you learned that.

I'll start..


Today I learned the proper way to forward public functions is this:
Code:

forward public OnSomethingHappen(a, b, c);
I've always done it without "public". The only difference, it seems, is it enforces some extra restrictions (such as not being able to assign default values).

Lorenc_ 15/07/2012 10:03 PM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned that you can use a hash sign (#) instead of quote marks. E.G: SetPVarInt( playerid, #slice, 1 );

CaHbKo 15/07/2012 10:19 PM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned, that...
Quote:

Originally Posted by Mauzen (Post 1989327)
Converting variabes "downwards" isnt a big problem btw. Just use normal cells, and if it really depends on being just 1/2 bytes long, you could do this:
cell & 0x0000FFFF (2 byte/16 bit value)
cell & 0x000000FF (1 byte/8 bit value)


Slice 17/07/2012 09:25 PM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned the compiler accepts trailing commas in enums.

Code:

// Valid:
enum {
    ABC,
    DEF,
    GHI,
}


Drebin 17/07/2012 09:47 PM

AW: Today I learned - Share your newly found knowledge!
 
Today I learned that color embeddings can be defined ontop of the script.

Code:

#define BLUE_EMBED "{0000FF}"
 
 
SendClientMessage(playerid, -1, "White turns into"BLUE_EMBED" blue.");


leonardo1434 17/07/2012 09:48 PM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned that strcat is 2x more fast than format and with a simple definition you can make a new model of format.

RebeloX 17/07/2012 09:56 PM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned that dialogs can be defined inside the enumerator

Code:

enum {
    DIALOG_1,
    DIALOG_2
};


Ricop522 17/07/2012 10:02 PM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned how to #emit

Ironboy 17/07/2012 10:16 PM

Re: Today I learned - Share your newly found knowledge!
 
Today i learned Enumerators (enums).

Universal 18/07/2012 08:07 AM

Re: Today I learned - Share your newly found knowledge!
 
Today I learned that OnGameModeExit is not being called when you shutdown the server console.


All times are GMT. The time now is 10:58 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.