Passing back strings
#1

I have a function, and I want in the parameters a reference to a string.

So just like:

pawn Код:
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid,name,sizeof(name));
I have:
pawn Код:
stock getFreePlateID(&plateID,&plate[]) {
  ..... some code
  format(plate,8,"%s",plateFromDatabase);
  ..... some more code
  return 1;
}


new plateID, plateText[8];
getFreePlateID(playeID,plateText);
But I get the error: "variable cannot be both a reference and an array (variable 'plate')"

Any ideas?

Thanks, Grim.
Reply
#2

Strings are always passed by reference. So there is no need to use an ampersand (&) there as well.
Reply
#3

I did, it was causing me errors for some reason I though the errors was because I was not passing the string as a reference, but after looking my code over I missed a line.

Thanks anyway, its working now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)