[SOLVED]Multiple vehicles -
Joe_ - 24.05.2010
Hi all, I've made a Car Rental system, it all works as it is supposed to, but only for ONE vehicle.
It creates the other vehicles, but does not set them as a hire car, even though I have.
I haven't shown full code due to it is going to be a release.
pawn Код:
new HireID = -1, Hire[MAX_RENTABLE_VEHICLES];
pawn Код:
stock CreateHireVehicle(Modelid, Float:x, Float:y, Float:z, Float:a, Color1, Color2, price)
{
HireID++;
printf("Hire[HireID] %d", Hire[HireID]);
hData[HireID][HirePrice] = price;
hData[HireID][Hiree] = 501;
hData[HireID][Hired] = 0;
Hire[HireID] = CreateVehicle(Modelid, x, y, z, a, Color1, Color2, -1);
printf("Hire[HireID] %d", Hire[HireID]);
return 1;
}
Re: Multiple vehicles -
Joe_ - 24.05.2010
Bump (Sorry for less than 12 Hour bump, but Scripting Discussion is fl00ded quickly.)
Re: Multiple vehicles -
juice.j - 24.05.2010
In which way does the result for the first car getting created by this code differ from the second car getting created by this code?
Re: Multiple vehicles -
Joe_ - 25.05.2010
The fact that it is not a hire vehicle when It should be, and that it skips a number ( I think that's due to vehicles in my GM )
pawn Код:
CreateHireVehicle(451, 524.259704, -1290.022094, 16.948589, 310.302642, -1, -1, 3000); //1
CreateHireVehicle(451, 534.313842, -1290.038574, 16.948661, 314.290283, -1, -1, 3000); //2
When I get in the first one, it returns "This is a hire vehicle");
Although when I get in the second one (Or any other vehicles created by CreateHireVehicle, other than the first) I get "This is not a hire vehicle."
pawn Код:
if(new a = 0; a < MAX_HIRE_VEHICLES; a++)
{
if(v != Hire[a])
{
SendClientMessage(playerid, yellow, "This is not a hire vehicle.");
}
else if(v == Hire[a])
{
SendClientMessage(playerid, yellow, "This Is a hire vehicle.");
}
// other stuff
}
return 1;
Re: Multiple vehicles -
Grim_ - 25.05.2010
That would probably be because the variable 'v's value does not change.
Re: Multiple vehicles -
Joe_ - 25.05.2010
Quote:
Originally Posted by Grim_
That would probably be because the variable 'v's value does not change.
|
Mhh..
pawn Код:
new v = GetPlayerVehicleID(playerid);
That is above the MAX_HIRE_VEHICLES loop, I will try and make it more local.
EDIT - Nothing's changed.
Re: Multiple vehicles -
Grim_ - 25.05.2010
You're code is always going to send the "not" message first, because you always check Hire[0] first. (The first vehicle)
Just do:
pawn Код:
new v = GetPlayerVehicleID(playerid);
if(v == Hire[1])
{
//valid vehicle
}
And make sure you're in the second vehicle when you do it.
Re: Multiple vehicles -
Joe_ - 25.05.2010
But then I would need
pawn Код:
if(v == hire[1])
{
stuff
}
else if(v == hire[2])
{
//stuff
}
I thaught the loop would automaticly do the numbers (0-100)
Re: Multiple vehicles -
juice.j - 25.05.2010
Yeah but with a for loop ( not sure what the code in your 3rd post is supposed to do )
Код:
for(new i=1;i<MAX_VEHICLES;i++) // or MAX_HIRE_VEHICLES
{
if(v == Hire[i])
// some code
}
Re: Multiple vehicles -
Joe_ - 25.05.2010
mh?