SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 15/07/2012, 10:01 PM   #1
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,896
Reputation: 1590
Default 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:
pawn 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).

Last edited by Slice; 27/05/2013 at 01:58 PM.
Slice is offline   Reply With Quote
Old 15/07/2012, 10:03 PM   #2
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 4,262
Reputation: 1137
Default 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 );
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 15/07/2012, 10:19 PM   #3
CaHbKo
Huge Clucker
 
Join Date: Nov 2007
Posts: 446
Reputation: 41
Default Re: Today I learned - Share your newly found knowledge!

Today I learned, that...
Quote:
Originally Posted by Mauzen View Post
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)
CaHbKo is offline   Reply With Quote
Old 17/07/2012, 09:25 PM   #4
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,896
Reputation: 1590
Default Re: Today I learned - Share your newly found knowledge!

Today I learned the compiler accepts trailing commas in enums.

pawn Code:
// Valid:
enum {
    ABC,
    DEF,
    GHI,
}
Slice is offline   Reply With Quote
Old 17/07/2012, 09:47 PM   #5
Drebin
High-roller
 
Drebin's Avatar
 
Join Date: Oct 2010
Location: Germany
Posts: 1,164
Reputation: 560
Default AW: Today I learned - Share your newly found knowledge!

Today I learned that color embeddings can be defined ontop of the script.

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


GamerX - The SA-MP legend.
Online since 2006.

188.165.219.63:8800
www.gamerxserver.com
Drebin is offline   Reply With Quote
Old 17/07/2012, 09:48 PM   #6
leonardo1434
High-roller
 
leonardo1434's Avatar
 
Join Date: Mar 2012
Posts: 1,673
Reputation: 179
Default 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.
__________________
c++
leonardo1434 is offline   Reply With Quote
Old 17/07/2012, 09:56 PM   #7
RebeloX
High-roller
 
RebeloX's Avatar
 
Join Date: Jul 2011
Location: Portugal
Posts: 2,257
Reputation: 442
Default Re: Today I learned - Share your newly found knowledge!

Today I learned that dialogs can be defined inside the enumerator

pawn Code:
enum {
    DIALOG_1,
    DIALOG_2
};
__________________
RebeloX is offline   Reply With Quote
Old 17/07/2012, 10:02 PM   #8
Ricop522
High-roller
 
Ricop522's Avatar
 
Join Date: Feb 2010
Location: ES
Posts: 2,658
Reputation: 159
Default Re: Today I learned - Share your newly found knowledge!

Today I learned how to #emit
__________________
"Any fool can write code that a
computer can understand. Good
programmers write code that
humans can understand."

AJUDA! Programação
Github
Ricop522 is offline   Reply With Quote
Old 17/07/2012, 10:16 PM   #9
Ironboy
High-roller
 
Ironboy's Avatar
 
Join Date: Nov 2010
Location: Isle of Man
Posts: 1,957
Reputation: 429
Default Re: Today I learned - Share your newly found knowledge!

Today i learned Enumerators (enums).
__________________
Ironboy is offline   Reply With Quote
Old 18/07/2012, 08:07 AM   #10
Universal
Huge Clucker
 
Universal's Avatar
 
Join Date: Jan 2010
Posts: 472
Reputation: 27
Default Re: Today I learned - Share your newly found knowledge!

Today I learned that OnGameModeExit is not being called when you shutdown the server console.
Universal is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Things you learned from GTA SA Toni Everything and Nothing 212 20/08/2011 07:07 AM
How you learned to script Bam23 Help Archive 9 11/04/2011 10:21 AM
What did u learned today ? rafay Everything and Nothing 170 30/03/2010 04:06 PM


All times are GMT. The time now is 08:16 AM.


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