rc vehicles enter in script
#1

hello together, I dont understand as I can I make the bandit into a tiger rc or enter can in the script, I'm a normal addstaticvehicle ... it isnt functionaly pls help thx
Reply
#2

My functions may help you a lot:
pawn Код:
stock Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ) return floatsqroot(floatpower(floatsub(X, PointX), 2.0) + floatpower(floatsub(Y, PointY), 2.0) + floatpower(floatsub(Z, PointZ), 2.0));

stock GetVehicleDriver(vehicleid)
{
for(new i; i<MAX_PLAYERS; i++) if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i;
return INVALID_PLAYER_ID;
}

stock GetNearestVehicle(playerid, Float:Distance = 1000.0)
{
Distance = floatabs(Distance);
if(!Distance) Distance = 1000.0;
new Float:X[2], Float:Y[2], Float:Z[2];
new Float:NearestPos = Distance;
new NearestVehicle = INVALID_VEHICLE_ID;
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
for(new i; i<MAX_VEHICLES; i++)
{
if(!IsVehicleStreamedIn(i, playerid) || IsPlayerInVehicle(playerid, i)) continue;
GetVehiclePos(i, X[1], Y[1], Z[1]);
if(NearestPos > GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1])) NearestPos = GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]), NearestVehicle = i;
}
return NearestVehicle;
}

stock GetNearestEmptyVehicle(playerid, bool:Mode, Float:Distance = 1000.0)
{
Distance = floatabs(Distance);
if(!Distance) Distance = 1000.0;
new Float:X[2], Float:Y[2], Float:Z[2];
new Float:NearestPos = Distance;
new NearestVehicle = INVALID_VEHICLE_ID;
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
for(new i; i<MAX_VEHICLES; i++)
{
if(!IsVehicleStreamedIn(i, playerid) || IsPlayerInVehicle(playerid, i)) continue;
if(Mode && GetVehicleDriver(i) != INVALID_PLAYER_ID) continue;
else if(!Mode && IsAnyPlayerInVehicle(i)) continue;
GetVehiclePos(i, X[1], Y[1], Z[1]);
if(NearestPos > GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1])) NearestPos = GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]), NearestVehicle = i;
}
return NearestVehicle;
}
Reply
#3

ok thx =)
and you can say me how to shot with a goblin or raider pls then is closed
Reply
#4

Oh, you can only shot with baron
Reply
#5

i have seen a a scrip to shot with a tiger and its functionaly and you can script that to goblin ?
Код:
#include <a_samp>
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Einstellungen=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#define RC_BANDIT	441
#define RC_BARON	464
#define RC_GOBLIN	501
#define RC_RAIDER	465
#define D_TRAM		449
#define RC_TANK		564
#define RC_CAM		594
//=-=-=-=-=-=-Wie weit soll man mit dem RC Panzer schieЯen kцnnen?=-=-=-=-=-=-=-
#define MAX_SHOOT_DISTANCE 30.0

public OnFilterScriptInit() {
	print("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
	print("RC/Tram Enter & RC Tank Shoot by alex Loaded");
	print("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new getvid = GetPlayerVehicleID(playerid);
	if((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE) && getvid && GetVehicleModel(getvid) == 564 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		new Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:az,player,Float:angletmp;
		GetPlayerPos(playerid,x,y,z);
		GetVehicleZAngle(GetPlayerVehicleID(playerid), az);
		player = GetTankVictim(playerid);

		if(player >= 0)
		  GetPlayerPos(player, x2, y2, angletmp);
		else
		{
			x2 = x + (MAX_SHOOT_DISTANCE * floatsin(-az, degrees));
			y2 = y + (MAX_SHOOT_DISTANCE * floatcos(-az, degrees));
		}

		CreateExplosion(x2,y2,z,12,0.0625);
	}
	
	if(newkeys == KEY_SECONDARY_ATTACK)
 	{
		new Float:x, Float:y, Float:z, vehicle;
		new vehicleID = GetPlayerVehicleID(playerid);
		if(vehicleID == 0)
	 	{
			GetPlayerPos(playerid, x, y, z);
			GetVehicleWithinDistance(x, y, z, 20.0, vehicle);
			if(IsVehicleRcTram(vehicle)) PutPlayerInVehicle(playerid, vehicle, 0);
		}
	 	else if(GetVehicleModel(vehicleID) != D_TRAM && (IsVehicleRcTram(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM))
	 	{
			GetPlayerPos(playerid, x, y, z);
			SetPlayerPos(playerid, x+0.5, y, z+1.0);
		}
	}
}

GetVehicleWithinDistance(Float:x1, Float:y1, Float:z1, Float:dist, &veh)
{
	new Float:x2, Float:y2, Float:z2, Float:d;
	for(new i = 1; i < MAX_VEHICLES; i++)
 	{
		if(GetVehicleModel(i) > 0)
	 	{
			GetVehiclePos(i, x2, y2, z2);
			x2 -= x1; y2 -= y1; z2 -= z1;
			d = x2*x2 + y2*y2 + z2*z2;
			if(d < dist)
		 	{
				veh = i;
				dist = d;
			}
		}
	}
}

IsVehicleRcTram(vehicleid)
{
	switch(GetVehicleModel(vehicleid))
 	{
		case D_TRAM, RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_TANK: return 1;
	}
	return 0;
}
stock GetTankVictim(playerid)
{
  new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:a;
  new Float:dx, Float:dy;
  new Float:tmpdis;
  new Float:dist = MAX_SHOOT_DISTANCE * MAX_SHOOT_DISTANCE;
  new player = -1;
  new Float:angle;
  new MaxPlayers = GetMaxPlayers();

  GetPlayerPos(playerid, x1, y1, z1);

	if(IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	else GetPlayerFacingAngle(playerid, a);

  for(new i = 0; i < MaxPlayers; i++)
  {
    if(IsPlayerConnected(i) && i != playerid)
    {
      GetPlayerPos(i, x2, y2, z2);

      angle = 180.0 - atan2(x1-x2, y1-y2);

      if(IsAngleInsideSector(a, angle, 15.0))
      {
        dx = x2-x1;
				dx *= dx;
				dy = y2-y1;
				dy *= dy;

				tmpdis = dx+dy;

				if(dist > tmpdis)
				{
					dist = tmpdis;
					player = i;
				}
			}
		}
	}

	return player;
}

stock IsAngleInsideSector(Float:angle, Float:sectormid, Float:size)
{
	new Float:tmp[4];

	if(size > 180.0) return false;

	while(angle < 0.0) angle += 360.0;
	while(angle > 360.0) angle -= 360.0;
	while(sectormid < 0.0) sectormid += 360.0;
	while(sectormid > 360.0) sectormid -= 360.0;

	tmp[0] = sectormid + size;
	tmp[1] = sectormid - size;
	tmp[2] = sectormid + size;
	tmp[3] = sectormid - size;

	while(tmp[2] > 360.0) tmp[2] -= 360.0;
	while(tmp[3] < 0.0) tmp[3] += 360.0;

	if(angle >= tmp[1] && angle <= tmp[0]) return true;
	if(angle >= tmp[3] && angle <= tmp[0]) return true;
	if(angle >= tmp[1] && angle <= tmp[2]) return true;
	if(angle >= tmp[3] && angle <= tmp[2]) return true;

	return false;
}
Reply
#6

oh shit, it is really strange
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)