GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
Gamer_Z - 30.06.2009
So i want to make an script that puts the player in the nearest vehicle but i am stuck at getting the nearest vehicle id.
for now I have this that needs to be done:
Code:
#include <a_samp>
#include <strtok>
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx = 0;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/nearest-car", true))
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, 0xFF0000FF, "* You are already in a Vehicle!");
}
else
{
if(!IsVehicleInUse(vehicleid))
{
GetNearestVehicleDistance(playerid,vehposx,vehposy,vehposz);
SetPlayerPos(playerid,vehposx,vehposy,vehposz);
SendClientMessage(playerid, 0xA8FF36FF, "* You have been teleported to the nearest vehicle!");
}else{
SendClientMessage(playerid, 0xA8FF36FF, "* Unable to find a nearest empty car!");
}
}
return 1;
}
return 0;
}
stock GetNearestVehicleDistance(playerid,vehposx,vehposy,vehposz)
{
new Float:vehposx,Float:vehposy,Float:vehposz;
GetVehiclePos(nearestvehicleid,vehposx,vehposy,vehposz);
/*if(!IsVehicleInUse(vehicleid))
{
PutPlayerInVehicle(playerid,nearestvehicleid,0);
}*/
return 1;
}
IsVehicleInUse(vehicleid)
{
new temp;
for(new i=0;i<200;i++)
{
if(IsPlayerConnected(i) && IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i)==PLAYER_STATE_DRIVER)
{
temp++;
}
}
if(temp > 0){ return true; } else return false;
}
So if anybody can help thanks!
Re: GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
dice7 - 30.06.2009
Try combining with the PlayerToPoint function
Re: GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
Gamer_Z - 30.06.2009
em ok i got maybe an idea..but now how to do that lol xD?...
Re: GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
Grim_ - 30.06.2009
Look at the GetClosestPlayer function. I'm sure after looking at it you'll be able to make up a GetClosestVehicle function
Re: GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
Gamer_Z - 30.06.2009
Quote:
Originally Posted by Swift_
Look at the GetClosestPlayer function. I'm sure after looking at it you'll be able to make up a GetClosestVehicle function
|
is this in a_player.inc or where? I think i can't find it ;l
Edit: eh lol undefinied.. k i search for it xD
Re: GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
Grim_ - 30.06.2009
Search for it.
Re: GetPlayerNearestVehicle(vehicleid) or GetPlayerNearestVehiclePos(vehicleid,pos)? -
Gamer_Z - 30.06.2009
okay i got an idea but instead of
GetDistanceBetweenPlayers(x,p1);
I need
GetDistanceToVehicle(x,v1);
...
EDIT : ok got it now i need to create it and .. test :P
EDIT: YEEEEEES, it works
now only some stuff.. for ex !isvehicleinuse ...
next step.. Atach veh to veh xD
you can expect i ask help :]
thank you all.