Need help with vehicle system -
Universal - 03.01.2011
Hey guys, so I got the problem:
when i use the command /v lock i always get that i need to get closer to my vehicle, the command is:
pawn Код:
new vehid = GetPlayerVehicleId(playerid);
new Float:X,Float:Y,Float:Z;
GetVehiclePos(vehid,X,Y,Z);
if(IsPlayerInRangeOfPoint(playerid,2,X,Y,Z))
{
SendClientMessage(playerid,CLR_GREY,"!");
printf("%d %s",vehid,carDB[vehid][cOwner]);
} else
{
SendClientMessage(playerid,CLR_GREY,"You need to get closer to your vehicle.");
printf("%d %s",vehid,carDB[vehid][cOwner]);
}
return 1;
I load vehicles with the command LoadVehicle(playerid), here it is:
pawn Код:
new file[70];
format(file,sizeof(file),"*******/vehicles/%s.ini",playerDB[playerid][name]);
new vehid = SetVehicleNumberPlate(CreateVehicle(dini_Int(file,"model"),
dini_Float(file,"x"),
dini_Float(file,"y"),
dini_Float(file,"z"),
dini_Float(file,"a"),
dini_Int(file,"color1"),
dini_Int(file,"color2"),
0), dini_Get(file,"number"));
format(carDB[vehid][cOwner],MAX_PLAYER_NAME,"%s",dini_Get(file,"owner"));
carDB[vehid][cLocked] = 1;
carDB[vehid][cParked] = 0;
carDB[vehid][cColorOne] = dini_Int(file,"color1");
carDB[vehid][cColorTwo] = dini_Int(file,"color2");
format(carDB[vehid][cNumber],9,"%s",dini_Get(file,"number"));
I have static vehicles too, made with AddStaticVehicleEx on GameModeInit, and the thing is, that when i type /v lock i got you must get closer which means i am not close enough to my vehicle, BUT when i go to the police car, and its the 1st AddStaticVehicleEx on GameModeInit, i get the "!" which means it should be my vehicle. So what the? I dont know, maybe the vehicleids mixed up or something. I even made a small debug code, so when i am near that police vehicle i get that "vehicleid: 1 owner: Billy_Mace" <- thats me. Its very strange. And i dont really know how to fix this? Could please some one help me? Or is there other way of loading a vehicle and assigning it to a player?
OH AND BTW, the vehicle loads perfectly from the file, with the color, and position and the model even with right numbers on the number plate. So any ideas?
Re: Need help with vehicle system -
Universal - 03.01.2011
Very looking forward for a reply..
Re: Need help with vehicle system -
azzerking - 03.01.2011
I dont see what you mean?
Re: Need help with vehicle system -
Universal - 03.01.2011
I mean that somethings wrong with the system, did you evean read the bottom of the post becouse i wrote everything?
Re: Need help with vehicle system -
Mence™ - 03.01.2011
Код:
new vehid = GetPlayerVehicleId(playerid);
new Float:X,Float:Y,Float:Z;
GetVehiclePos(vehid,X,Y,Z);
The above code will get vehicle id player are in not near vehicle.
Make loop to get pos of all cars like.
Код:
for(new i = 1;i < MAX_VEHICLES;i++)
{
GetVehiclePos(i,X,Y,Z);
}
Re: Need help with vehicle system -
Universal - 03.01.2011
Quote:
Originally Posted by Mence™
Код:
new vehid = GetPlayerVehicleId(playerid);
new Float:X,Float:Y,Float:Z;
GetVehiclePos(vehid,X,Y,Z);
The above code will get vehicle id player are in not near vehicle.
Make loop to get pos of all cars like.
Код:
for(new i = 1;i < MAX_VEHICLES;i++)
{
GetVehiclePos(i,X,Y,Z);
}
|
But you see, i use the custom code GetPlayerVehicleId(playerid) :
pawn Код:
stock GetPlayerVehicleId(playerid) {
for(new i=0; i<MAX_VEHICLES; i++)
{
if(carDB[i][cOwner] == playerDB[playerid][name])
{
return i;
}
}
return MAX_VEHICLES;
}
So, i do:
pawn Код:
new vehid = GetPlayerVehicleId(playerid);
GetVehiclePos(vehid,X,Y,Z);
And as i typed above, it gets the pos of police vehicle i made with AddStaticVehicleEx on GameModeInit.
But why? Is the vehicleids mixed?