SA-MP Forums Archive
Can someone explain this code to me? - 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: Can someone explain this code to me? (/showthread.php?tid=469246)



Can someone explain this code to me? - lramos15 - 12.10.2013

I have
PHP код:
format(FactionInfo[fID][fName],100,inputtext); 
But I don't know why you need the 100 there or the format? I was thinking just
PHP код:
FactionInfo[fID][fName] = inputtext
but that gives me this error
Quote:

array sizes do not match, or destination array is too small




Re: Can someone explain this code to me? - Pottus - 12.10.2013

It specifies the size of the array.


Re: Can someone explain this code to me? - Jefff - 12.10.2013

100 is the size of fName[HERE] in enum, inputtext has undefined size so error because u can't set array[100] = inputtext[undefined_size];


Re: Can someone explain this code to me? - lramos15 - 12.10.2013

So Jeff you're saying that code won't work?


Re: Can someone explain this code to me? - Konstantinos - 12.10.2013

The second method would only work if both strings had the same size. If their lenghts do not match, then it gives the warning.

You format to FactionInfo[fID][fName] with max lenght of the string to 100 what inputtext "holds" in it. format is a bit slower than other methods, for example strcat or strins is faster.


Re: Can someone explain this code to me? - Jefff - 12.10.2013

In format works


Re: Can someone explain this code to me? - lramos15 - 12.10.2013

So the format allows for the inputtext to be equal to 100 characters?


Re: Can someone explain this code to me? - Konstantinos - 12.10.2013

The inputtext can be even higher on lenght; however FactionInfo[fID][fName] will only store 99 characters + NULL.


Re: Can someone explain this code to me? - lramos15 - 12.10.2013

Okay thanks for the help