21.04.2009, 12:45
PlayerVehicleToPoint
By Pyrokid
Credits go to whoever made PlayerToPoint. All I did was modify it to work for vehicles so you can use it for pickups.
By Pyrokid
Credits go to whoever made PlayerToPoint. All I did was modify it to work for vehicles so you can use it for pickups.
pawn Код:
stock PlayerVehicleToPoint(playerid,Float:x,Float:y,Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if(IsPlayerInAnyVehicle(playerid))
{
GetVehiclePos(GetPlayerVehicleID(playerid), oldposx, oldposy, oldposz);
if (((tempposx < 3) && (tempposx > -3)) && ((tempposy < 3) && (tempposy > -3)) && ((tempposz < 3) && (tempposz > -3)))
{
return 1;
}
} else {
if (((tempposx < 3) && (tempposx > -3)) && ((tempposy < 3) && (tempposy > -3)) && ((tempposz < 3) && (tempposz > -3)))
{
return 1;
}
}
}
return false;
}
Usage
I did this basically for picking up pickups if you're in a vehicle.
I did this basically for picking up pickups if you're in a vehicle.
pawn Код:
//Top of script
forward timer1();
//OnGameModeInit
SetTimer("timer1", 1000, 1); //Every second
CreatePickup(1550,23,2302.2800,1387.9668,42.4453); //Example pickup
//Anywhere
public timer1()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerVehicleToPoint(i,2302.2800,1387.9668,42.4453)) //Is the same coordinates of the example pickup
{
new vehid = GetPlayerVehicleID(i);
SetVehiclePos(vehid,5555,5555,5555);
PutPlayerInVehicle(i,vehid,0);
}
}
}
return 1;
}
That's it. Now you can do vehicle pickups. Tested and works. This is my first attempt at making a function so if there is a more efficient or better way to do it, please do it! Again credits go to whoever made PlayerToPoint because all I did was modify it a tiny bit.
* Revision 1 on 4/23/09
* Revision 1 on 4/23/09