SA-MP Forums Archive
function only returning first character of string - 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: function only returning first character of string (/showthread.php?tid=420063)



function only returning first character of string - thefatshizms - 03.03.2013

pawn Код:
GetInteriorName(intname[])
{
    for(new i = 0;i < 47;i++)
    {
        if(strfind(Interiors[i][InteriorName], intname, true) != -1)
        printf("%s, Interior Name (Function: GetInteriorName()", Interiors[i][InteriorName]);
        return Interiors[i][InteriorName];
    }
    return -1;
}



Re: function only returning first character of string - Rock - 03.03.2013

Maybe this?
pawn Код:
GetInteriorName(intname[])
{
    for(new i = 0;i < 47;i++)
    {
        if(strfind(Interiors[i][InteriorName], intname, true) != -1)
        printf("%s, Interior Name (Function: GetInteriorName()", Interiors[i][InteriorName]);
    }
    return Interiors[i][InteriorName];
}



Re: function only returning first character of string - thefatshizms - 03.03.2013

Nope, it's outside the loop so it wont know what i is.


Re: function only returning first character of string - Catalyst- - 03.03.2013

This should sort it...
pawn Код:
stock GetInteriorName(intname[])
{
    new name[128];
    for(new i = 0;i < 47;i++)
    {
        if(strfind(Interiors[i][InteriorName], intname, true) != -1) {
            format(name,sizeof(name),"%s", Interiors[i][InteriorName]);
            break;
        }
    }
    return name;
}