How to make a function that returns a string
#2

Not sure, but perhaps every string has to be the same size. First of all name should be 25 cells because a name can be 24 characters but there's also the null character. Try this:

pawn Код:
stock GetPropertyOwnerName(property[])
{
    new file[256];
    new name[25] = "Nobody";
   
    format(file, sizeof(file), "gamemode/config/properties/%s.txt", property);
    if(strcmp(dini_Get(file, "Property_Owner"), "~") != 0)
    {
        format(name, sizeof(name), "%s", dini_Get(file, "Property_Owner"));
    }
    return name;
}
I would personally set the name to ~ or something if nobody uses the house (you can't have 1-character names).
Also, put spaces after commas it looks a hell of a lot clearer to read, trust me. Just compare my code and yours.
Reply


Messages In This Thread
How to make a function that returns a string - by mrcoolballs - 24.06.2012, 09:53
Re: How to make a function that returns a string - by MP2 - 24.06.2012, 10:02

Forum Jump:


Users browsing this thread: 1 Guest(s)