Help with a stock...
#1

I'm having a bit of trouble.
I have this stock made by Jeffrey:
pawn Код:
stock GetCarIDFromPlayer_Enum(playerid)
{
    for(new i=0; i<sizeof(CarInfo); i++)
    {
        if(!strcmp(CarInfo[i][vOwner], PlayerName(playerid))) return i; //Returns the ID of the Ownership
    }
    return -1;
}
I need to detect if it returned -1...
I've tried multiple things before requesting help.

I tried:
Код:
if(setcar == -1)
Код:
if(!setcar)
( setcar being new setcar = GetCarIDFromPlayer_Enum(playerid); )

But none of them have worked. So basically I wanna ask if setcar returned -1 do this, else do that.
Reply
#2

pawn Код:
stock GetCarIDFromPlayer_Enum(playerid)
{
    for(new i=1; i<MAX_VEHICLES; i++)//if you use a sizeof you dont will get all the vehicles becouse you must have other cars before the owned vehicles...
    {
        if(!strcmp(CarInfo[i][vOwner], PlayerName(playerid),false)) return i;
    }
    return 0;
}

if(GetCarIDFromPlayer_Enum(playerid) == 0)//he dont have a car...
Reply
#3

Quote:
Originally Posted by Pharrel
Посмотреть сообщение
pawn Код:
stock GetCarIDFromPlayer_Enum(playerid)
{
    for(new i=1; i<MAX_VEHICLES; i++)//if you use a sizeof you dont will get all the vehicles becouse you must have other cars before the owned vehicles...
    {
        if(!strcmp(CarInfo[i][vOwner], PlayerName(playerid),false)) return i;
    }
    return 0;
}

if(GetCarIDFromPlayer_Enum(playerid) == 0)//he dont have a car...
"//if you use a sizeof you dont will get all the vehicles becouse you must have other cars before the owned vehicles..." - Nah I only want it for owned vehicles...

if == 0 would work why doesn't == -1?
Reply
#4

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
"//if you use a sizeof you dont will get all the vehicles becouse you must have other cars before the owned vehicles..." - Nah I only want it for owned vehicles...

if == 0 would work why doesn't == -1?
I know that you only need the owned vehicles but think about it... you got 100 vehicles for jobs (not owned) and 50 cars owneds... the loop will start in 0 and go to 50 but all this cars are not owned so your functiou will fail

about the -1 doesnt change anything.
Reply
#5

pawn Код:
printf("setcar is: %d", setcar);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)