Teleporting to a vehicle problem -
Libra_PL - 27.07.2011
Hello. I've got a little problem with minigame - teleporting to a vehicle... When the minigame starts, all players are teleporting to last vehicle. They see they are in a vehicle, but other players on/near this. I don't know what's wrong with my code, I it in many ways and no effect. Someone could help me is this code made correctly?
At first, creating a vehicle:
Код:
mVehicle[0] = CreateVehicle(...);
mVehicle[1] = CreateVehicle(...);
[...]
Numbers goes from 0 to 19, as there are 20 vehicles.
Then, teleporting player to a vehicle (it was made as TeleportToVehicle function):
Код:
stock TeleportToVehicle(playerid)
{
for(new i = 0; i < 20; i++)
{
if(!IsAnyoneInAVehicle(pdVehicle[i]) && !IsPlayerInAnyVehicle(playerid))
{
PutPlayerInVehicle(playerid,pdVehicle[i],0);
}
}
return 1;
}
Stock for IsAnyoneInAVehicle is made correctly, but to make sure to show all, here it is:
Код:
stock IsAnyoneInAVehicle(vehicleid)
{
new In;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == vehicleid) In++;
}
}
if(In > 0) return true;
else return false;
}
If everything here was made correctly, the problem is something, what I did before. I won't show what's before, I will check my code again, until I will get anwser what's problem in this code, which I pasted. The code should work that, every player teleports into another, empty vehicle.
Thanks for help.
Re: Teleporting to a vehicle problem -
Libra_PL - 27.07.2011
Sorry for bump, but it I would need this now... The problem is still not fixed, I tried it in many ways.
Re: Teleporting to a vehicle problem -
TouR - 27.07.2011
pawn Код:
stock TeleportToVehicle(playerid)
{
if(!IsAnyoneInAVehicle(pdVehicle[playerid]) && !IsPlayerInAnyVehicle(playerid))
{
PutPlayerInVehicle(playerid,pdVehicle[playerid],0);
}
return 1;
}
Try this
Re: Teleporting to a vehicle problem -
Libra_PL - 27.07.2011
No... I don't need to test this, because I see it's made wrong
I don't know what's wrong, I made it how I wanted to do. I did a loop which checks is vehicle empty or not. If it's empty (for example mVehicle[0] is not empty, system will search mVehicle[1], etc. to find empty vehicle to put player in) player should be teleported in. It looks like this system doesn't find is vehicle empty or not, it just puts all players in a last one (why last? I also don't understand this - it should find from 0 to 19, not from last(?) ). The problem would be IsAnyoneInAVehicle function, but I don't see anything wrong made here.
PS: Sorry, it should be mVehicle, not pdVehicle (I changed to don't tell what I'm already doing).