2020-12-21, 04:11 PM
(2020-12-21, 02:53 PM)Markski Wrote: There's a few things wrong here:
- You're receiving a string without knowing it's size. The compiler complains because you're then trying to return this same string.
The problem above can be solved by simply setting the size of the string being received.
Code:stock Adrian(playerid, string[SIZE], V)
{ [...]
If the size of the string is going to vary, you could do something like this
Code:[CODE]
stock Adrian(playerid, V, string[], max_len=sizeof(string))
{ [...]
However, there's a higher concept problem here: You don't need to return the string in the first place.
Arrays in Pawn are always passed by reference. From page 18 of the Pawn Language document:
Quote:When you are working with strings, or arrays in general, note
that pawn always passes arrays by reference. It does this to conserve memory
and to increase performance |arrays can be large data structures and passing
them by value requires a copy of this data structure to be made, taking both
memory and time.
This means that the string which is being passed is going to be modified by the function receiving it. You don't need to explicitly return it.
i do exactly but i have two errors:
error 047: array sizes do not match, or destination array is too small
la: OnPlayerLogin -?Adrian(playerid, password, PlayerInfo[playerid][pLoserLevel]);
la OnPlayerRegister -?Adrian(playerid, password, 0);
Quote:stock Adrian(playerid, string[33], V)