Vehicle pickups - 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: Vehicle pickups (
/showthread.php?tid=430319)
Vehicle pickups -
newbienoob - 13.04.2013
I have a problem with my vehicle pickups. I know that vehicle pickup(id 14) is bugged on a custom objects/out of SA. So I'm creating it with IsPlayerInRangeOfPoint. But the problem is;
pawn Код:
enum PickupInfo
{
Float:Range[3],
Pickups[3]
}
new pData[100][PickupInfo];
stock CreateVehicleRepair(Float:X, Float:Y, Float:Z)
{
for(new p = 0; p < sizeof(pData); p++)
{
pData[p][Pickups][0] = CreateDynamicPickup(1239, 23, X, Y, Z);
pData[p][Range][0] = X;// for IsPlayerInRangeOfPoint
pData[p][Range][1] = Y;// for IsPlayerInRangeOfPoint
pData[p][Range][2] = Z;// for IsPlayerInRangeOfPoint
printf("Range = X: %f | Y: %f | Z: %f", pData[p][Range][0], pData[p][Range][1], pData[p][Range][2]);
//Printed X, Y, Z. No problems were found.
return 1;
}
return 0;
}
And then, I set a repeated timer(200 ms) to check IsPlayerInRangeOfPoint.
pawn Код:
//Under the timer callback.
for(new p = 0; p < sizeof(pData); p++)
{
if(IsPlayerInRangeOfPoint(i, 3.5, pData[p][Range][0], pData[p][Range][1], pData[p][Range][2]) && IsPlayerInAnyVehicle(i))
{
RepairVehicle(VID);
SetVehicleHealth(VID, 1000);
SendClientMessage(i, -1, "Vehicle repaired!");
}
}
So I did this;
CreateVehicleRepair(0,0,5);
CreateVehicleRepair(0,0,10);
CreateVehicleRepair(0,0,15);
CreateVehicleRepair(0,0,20);
The pickups were there. But the problem is, only the last one(0,0,20) was working. The other pickups were not working.
Re: Vehicle pickups -
Pottus - 13.04.2013
Factor in lag, and speed when your driving 3.5 meter range on a 200ms will only be sporadically called. 100km/h is 27 meters per second divide by 5 which is 5.4 meters per 200ms. Also consider your timer times are inaccurate so about 894ms is about 1 second approximately you need to set your timer to 178ms for 200ms.