SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 18/10/2017, 04:49 PM   #631
GaByM
Big Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Location: Romania
Posts: 112
Reputation: 10
Default Re: Today I learned - Share your newly found knowledge!

TIL that

PHP Code:
#include <a_samp>
main()
{
    {
        new 
k;
        new 
bla[3][3];
        new 
z;
        
printf(""kbla[1], z);
    }
    {
        new 
z//ok
        
new bla//not ok, symbol already defined
        
new k//symbol already defined
        
printf(""kblaz);
    }
    return 
1;

the code above won't work

If you declare a matrix then any try of defining a variable(in other scope) with the same name with the ones that are above the matrix won't work
GaByM is offline   Reply With Quote
Old 20/10/2017, 12:05 PM   #632
OneDay
Huge Clucker
 
Join Date: Sep 2015
Posts: 294
Reputation: 139
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by GaByM View Post
TIL that

PHP Code:
#include <a_samp>
main()
{
    {
        new 
k;
        new 
bla[3][3];
        new 
z;
        
printf(""kbla[1], z);
    }
    {
        new 
z//ok
        
new bla//not ok, symbol already defined
        
new k//symbol already defined
        
printf(""kblaz);
    }
    return 
1;

the code above won't work

If you declare a matrix then any try of defining a variable(in other scope) with the same name with the ones that are above the matrix won't work
Use this https://github.com/Zeex/pawn
OneDay is offline   Reply With Quote
Old 04/11/2017, 06:30 PM   #633
AgusZ
Big Clucker
 
Join Date: Nov 2014
Location: Earth
Posts: 148
Reputation: 7
Default Re: Today I learned - Share your newly found knowledge!

Today I Learned I can make a new function without forward.
Quote:
#if !defined function
#define function%0(%1) \
forward%0(%1); public%0(%1)
#endif

Function Time(playerid)
AgusZ is offline   Reply With Quote
Old 07/11/2017, 06:35 PM   #634
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,077
Reputation: 283
Default Re: Today I learned - Share your newly found knowledge!

Today I learned that you can specify more than one tag to variables.
PHP Code:
{Float,_}:something
quoted from http://forum.sa-mp.com/showpost.php?...16&postcount=2
__________________

|===[Web taxi]===|
List of my work
Github
Pastebin

|===[Interesting topics]===|
Semantic Versioning
Eoussama is offline   Reply With Quote
Old 17/11/2017, 08:16 PM   #635
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by AgusZ View Post
Today I Learned I can make a new function without forward.
Just thought I should inform you that you are actually forwarding this callback into a public function. You're just using a macro definition to shorten your code up.




Today I learned that the YSI library has a lot to offer that is more useful than I thought, for examply the y_timers, y_iterates, y_stringhash, y_bit to just name a few.
Meller is offline   Reply With Quote
Old 24/11/2017, 06:20 PM   #636
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Today I learned - Share your newly found knowledge!

Today I learned that states are a thing in PAWN;
PHP Code:
#include <a_samp>

#define MACRO_FLAG_A (0)
#define MACRO_FLAG_B (1)

new flag = -1;

forward @stateCheck();

main() {
    
state STATE_FLAG_A;
    @
stateCheck();
    
    
flag MACRO_FLAG_A;
    @
stateCheck();

    
flag MACRO_FLAG_B;
    
state STATE_FLAG_B;
    @
stateCheck();
}

@
stateCheck() <STATE_FLAG_A> {
    
printf("@stateCheck says: variable 'flag' are (%i) and stage are static 'STATE_FLAG_A'"flag);
}

@
stateCheck() <STATE_FLAG_B> {
    
printf("@stateCheck says: variable 'flag' are (%i) and stage are static 'STATE_FLAG_B'"flag);

Which outputs
Quote:
@stateCheck says: variable 'flag' are (-1) and stage are static 'STATE_FLAG_A'
@stateCheck says: variable 'flag' are (0) and stage are static 'STATE_FLAG_A'
@stateCheck says: variable 'flag' are (1) and stage are static 'STATE_FLAG_B'
Now this hasn't got a direct useful usage (in this example) but I can surely think of uses of this.
Meller is offline   Reply With Quote
Old 04/12/2017, 05:49 AM   #637
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: The Strip
Posts: 154
Reputation: 16
Default Re: Today I learned - Share your newly found knowledge!

Today i Learned - how to spilt the chat

example

Code:
player (0): blablbaajh
__________________
WARNING IM NOT HERE
Mobtiesgangsa is offline   Reply With Quote
Old 24/12/2017, 09:40 AM   #638
xMoBi
Banned
 
Join Date: Jul 2017
Location: Islamic Republic of Pakistan
Posts: 98
Reputation: 26
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by iAmir View Post
Today I Learned that I can set ExtraID for streamer items like area , objects , checkpoint and etc
and use it when I want to find them instead of setting a variable and make huge loop to find it

Example :

Code:
CreateHouse(h) { // Let's say this is where the house is created.

         House[h][iAreaID]= CreateDynamicSphere(blah, blah, blah, somevalue, somevalue);
	Streamer_SetIntData(STREAMER_TYPE_AREA, House[h][iAreaID], E_STREAMER_EXTRA_ID, h);
}
And then instead of making a loop in House variable and check for areaid == i matches you can easily do this :

Code:
public OnPlayerEnterDynamicArea(playerid, areaid) {

	new h = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
	if(0 <= h < MAX_HOUSES) { 
	      // here it is! player is in house h !
	}
}
Thatís lit! I learned from here : http://forum.sa-mp.com/showthread.php?t=611692
this thread is not for this kind of things its about things you learn yourself
xMoBi is offline   Reply With Quote
Old 26/12/2017, 03:05 AM   #639
admantis
High-roller
 
Join Date: Sep 2009
Posts: 2,524
Reputation: 449
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by jlalt View Post
Today learnt how to get the distance between two points ;-;, with / without Z.



which would use
http://wiki.sa-mp.com/wroot/index.php?title=Floatsqroot
and
http://wiki.sa-mp.com/wiki/Floatpower
This also works for 3D spaces (with the Z vector) using the Pythagoras theorem.
admantis is offline   Reply With Quote
Old 28/12/2017, 10:03 PM   #640
mirou123
Huge Clucker
 
Join Date: Jul 2013
Posts: 362
Reputation: 22
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by admantis View Post
This also works for 3D spaces (with the Z vector) using the Pythagoras theorem.
It works in any dimension.
mirou123 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 211 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 07:52 AM.


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