Posts: 84
Threads: 25
Joined: Aug 2010
Reputation:
0
I just wanted to test some stuff before do something with this code, but for some reason it allways returns ID -1 and the distance its like 11600(and then numbers that changes) even when im inside the car it gives a really long number, isnt supossed when im very closer to the car it must have distance 0 or something?....
if (strcmp(cmdtext, "/test", true)==0)
{
new carids = GetClosestCar(playerid);
new Float:dist= GetDistanceFromPlayerToVehicle(playerid,carids);
new stringa[256];
format(stringa, sizeof stringa, "Distancia a vehiculo mas cercano: %i Id:[%i]", dist,carids);
SendClientMessage(playerid, 0xCCFFDD56, stringa);
return 1;
}
Posts: 84
Threads: 25
Joined: Aug 2010
Reputation:
0
thanks, but why the car ID is allways -1 ? thats important, im trying to make omething like a cmomand to spawn a car, only if there is no cars closer to the player...but since it allways gives id -1 it will not detect any car closer so it will spawn cars anywais
Posts: 84
Threads: 25
Joined: Aug 2010
Reputation:
0
i have this version: (didnt maded this one)
stock GetClosestVehicle(playerid) //By Darkrealm (edited by Gabrie "Larcius" Cordes)
{
if(IsPlayerConnected(playerid) && IsVehicleConnected(0))
{
new closestvehicle=0;
new Float:closestdist=GetDistanceToVehicle(playerid,0) ;
for(new vehicleid=0; vehicleid<MAX_VEHICLES; vehicleid++)
{
new Float:dist = GetDistanceToVehicle(playerid,vehicleid);
if ((dist < closestdist))
{
closestdist = dist;
closestvehicle = vehicleid;
}
}
return closestvehicle;
}
return -1;
}
Posts: 1,130
Threads: 77
Joined: Jan 2010
Reputation:
0
Yes, it always returns -1 if there is no vehicle?
Use TheCrazyKiller stock.
Posts: 84
Threads: 25
Joined: Aug 2010
Reputation:
0
19.10.2010, 02:49
(
Последний раз редактировалось JulietaZ; 19.10.2010 в 03:28.
)
Not working stills does not gives the id...now its 0
Posts: 84
Threads: 25
Joined: Aug 2010
Reputation:
0
it gives 0 even when im inside a car....XD...Im just trying to get distance between player and most closer car, but since this thing allways gives -1 or 0 then i cant use the distance function until i get the ID ..