SA-MP Forums Archive
Difference on passing by reference? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Difference on passing by reference? (/showthread.php?tid=374326)



Difference on passing by reference? - TheArcher - 02.09.2012

Hi, i was wondering the difference in a function if it has to pass by reference or not.

E.g
pawn Код:
GetPlayerVehiclePos(playerid, vehicleid, Float:x, Float:y, Float:z) // its just an example of the function

GetPlayerVehiclePos(playerid, vehicleid, &Float:x, &Float:y, &Float:z)
Yes i know on the 2nd example you have to create variable to pass by reference, but also in the first function you have to create variables to get the vehicle position? Any difference?


Re: Difference on passing by reference? - TheArcher - 02.09.2012

Well, i was looking for an answer and since this is a scripting Help, this is the place to get help, so please calm down, i didn't kill anyone, i've just done a question....Gosh


Re: Difference on passing by reference? - leonardo1434 - 02.09.2012

stop being lazy and go search for "pawn-lang.pdf".


Re: Difference on passing by reference? - TheArcher - 02.09.2012

I didn't know there were a file called "pawn-lang.pdf"...i can't ask here right?


Re: Difference on passing by reference? - leonardo1434 - 02.09.2012

pawn Код:
public OnFilterScriptInit()
{
   new
      a = 5,
      b = 5,
      c = 5,
      d = 5;
   something(a,b,c,d);
   printf(#%d - %d - %d - %d,a,b,c,d);
}

something(a , &b , c)
{
   a = 1;
   c = 2;
   b = a + c;  
}
// it should output : 5 - 3 - 5
The variable passed by reference won't have his value modified, since his value is passed to the function. Basically, it allows the function to change his value.

Again, i recommend you to stop being lazy and read more the pawn-lang.pdf


Re: Difference on passing by reference? - TheArcher - 02.09.2012

Alright thanks.......however this is the first time i hear about thay pdf man..
ual for pawn


Re: Difference on passing by reference? - TheArcher - 03.09.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
You have been here for YEARS - you would have to be hiding under a rock to have not seen that being mentioned time and time again!
Yes my account was registred in 2009, but i started to use it since 2011. I haven't seen that file around. Just to do an example did you know that AMX stands for Abstract Machine eXecutor? Yes you know that since February 2012. So my answer could be go read the .pdf file?


Re: Difference on passing by reference? - Babul - 03.09.2012

scroll down to "Documentation", i think its the second pdf:
http://www.compuphase.com/pawn/pawn.htm#DOWNLOAD_DOCS