Saving a string into a variable.
#1

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

I think that it should be

pawn Код:
sscanf(SQL_Get("name","objects",oid),"p<|>s[/*oName size*/]",ObjectInfo[oid][oName]);
Reply
#3

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.
Reply
#4

help??
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)