Saving a string into a variable. - 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: Saving a string into a variable. (
/showthread.php?tid=516022)
Saving a string into a variable. -
printer - 29.05.2014
I have a problem with a furniture system that I program, when it shows the list I make it show the name of the object, and it doesn't after re-starting the server. So I've made a debug and found a problem.
pawn Код:
sscanf(SQL_Get("name","objects",oid),"p<|>s",ObjectInfo[oid][oName]);
print(ObjectInfo[oid][oName]);
printf("LOADOBJ STOCK DEBUG: %i %i %f %f %f %f %f %f %s",ObjectInfo[oid][oID],ObjectInfo[oid][oModel],ObjectInfo[oid][oXP],ObjectInfo[oid][oYP],ObjectInfo[oid][oZP],ObjectInfo[oid][rXP],ObjectInfo[oid][rYP],ObjectInfo[oid][rZP],ObjectInfo[oid][oName]);
It shows everything except ObjectInfo[oid][oName] and shows some weird "smiley" thing instead, like there's a problem with that's the in string variable. ObjectInfo[oid][oName] has 48 cells. And it's supposed to show "Plain Table[$120]". Need help.
Re: Saving a string into a variable. -
]Rafaellos[ - 29.05.2014
I think that it should be
pawn Код:
sscanf(SQL_Get("name","objects",oid),"p<|>s[/*oName size*/]",ObjectInfo[oid][oName]);
Re: Saving a string into a variable. -
printer - 29.05.2014
Quote:
Originally Posted by ]Rafaellos[
I think that it should be
pawn Код:
sscanf(SQL_Get("name","objects",oid),"p<|>s[/*oName size*/]",ObjectInfo[oid][oName]);
|
Doesn't work yet.
Re: Saving a string into a variable. -
printer - 30.05.2014
help??
Re: Saving a string into a variable. -
Koala818 - 30.05.2014
What ]Rafaellos[ wanted to say is that you need to specify the length of the "ObjectInfo[oid][oName]" array in the sscanf function. Like you replace [/*oName size*/] with the size of that array. Example if you have something like
pawn Код:
enum oInfo
{
oName[50],
};
new ObjectInfo[MAX_OBJECTS][oInfo];
You'll have to put in the sscanf
pawn Код:
sscanf(SQL_Get("name","objects",oid),"p<|>s[49]",ObjectInfo[oid][oName]);
https://github.com/Y-Less/sscanf/wiki/%22s%22-Specifier