Returning but still a warning
#1

This code does work! it does return the value as it should but pawno returns a warning saying this function should return a value... any id's?

pawn Код:
stock readownedprop(playerid)
{
    new file[LENGTH];
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        format(file, sizeof(file), PATH, i);
        if(dini_Exists(file))
        {
            if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
            {
                return i;
            }
        }
    }
}
Reply
#2

pawn Код:
stock readownedprop(playerid)
{
    new file[LENGTH];
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        format(file, sizeof(file), PATH, i);
        if(dini_Exists(file))
        {
            if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
            {
                return i;
            }
        }
    }
    return -1;
}
Reply
#3

Quote:
Originally Posted by Rizard
Посмотреть сообщение
This code does work! it does return the value as it should but pawno returns a warning saying this function should return a value... any id's?

pawn Код:
stock readownedprop(playerid)
{
    new file[LENGTH];
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        format(file, sizeof(file), PATH, i);
        if(dini_Exists(file))
        {
            if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
            {
                return i;
            }
        }
    }
}
You to check ?
simple:

pawn Код:
stock readownedprop(playerid)
{
    new file[LENGTH];
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        format(file, sizeof(file), PATH, i);
        if(dini_Exists(file))
        {
            if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
            {
                return true;
            }
            else return false;
        }
    }
}
Reply
#4

Quote:
Originally Posted by [Full]Garfield[XDB]
Посмотреть сообщение
You to check ?
simple:

pawn Код:
stock readownedprop(playerid)
{
    new file[LENGTH];
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        format(file, sizeof(file), PATH, i);
        if(dini_Exists(file))
        {
            if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
            {
                return true;
            }
            else return false;
        }
    }
}
euh... no, I need the value from the for loop

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
stock readownedprop(playerid)
{
    new file[LENGTH];
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        format(file, sizeof(file), PATH, i);
        if(dini_Exists(file))
        {
            if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
            {
                return i;
            }
        }
    }
    return -1;
}
Tyvm but can you also explain this? Is it just a 'bug-/warningcatcher' for pawno? I never saw this before.

Grts
Reply
#5

pawn Код:
new houseID;
if(((houseID = readownedprop(playerid)) != -1))
{

}else SCM("You dont have any house");
not bug just normal warning xd
Reply
#6

1. This warning means that you have to set a return right before the last closing bracket in function.
2. Jefff said "return -1;" because if he had put "return 0;" the server would think you wanted the function to return ID 0 when all house files had been read.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)