Difference on passing by reference?
#1

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?
Reply
#2

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
Reply
#3

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

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

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
Reply
#6

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

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?
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)