Help with a stock... - 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: Help with a stock... (
/showthread.php?tid=287220)
Help with a stock... -
Jack_Leslie - 02.10.2011
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:
( 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.
Re: Help with a stock... -
Pharrel - 02.10.2011
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...
Re: Help with a stock... -
Jack_Leslie - 02.10.2011
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?
Re: Help with a stock... -
Pharrel - 02.10.2011
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.
Re: Help with a stock... -
DRIFT_HUNTER - 02.10.2011
pawn Код:
printf("setcar is: %d", setcar);