Well i found that function and tried it, but doesnt work for me, can you help me please ?
Код:
#include <a_samp>
new hydra1;
new hydra2;
forward streamhydra1(playerid);
forward streamhydra2(playerid);
new escort;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Hydra escort [FS] By Gamer931215 ");
print("--------------------------------------\n");
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,0x00B9FFFF,"This server is running gamer's escort mod [beta 0.1b].");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/escort on", cmdtext, true, 10) == 0)
{
if (escort == 0) {
if (GetVehicleModel(GetVehicleModel(GetPlayerVehicleID(playerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 577 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 511 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 592 ||
GetVehicleModel(GetPlayerVehicleID(playerid)) == 512 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 513 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 519 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 593 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 553)) {
new Float:x,Float:y,Float:z;
GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
hydra1 = AddStaticVehicle(520,x,y,z+50,0,0);
hydra2 = AddStaticVehicle(520,x,y,z+80,0,0);
SetTimerEx("streamhydras",10,true,"i",playerid);
escort = 1;
KillTimer(streamhydras(playerid));
} else return SendClientMessage(playerid,0x00B9FFFF,"The hydras are already escorting an plane!");
} else return SendClientMessage(playerid,0x00B9FFFF,"You are not in a plane!");
return 1;
}
if (strcmp("/escort off", cmdtext, true, 10) == 0)
{
DestroyVehicle(hydra1);
DestroyVehicle(hydra2);
escort = 0;
KillTimer(streamhydras(playerid));
return 1;
}
return 0;
}
public streamhydras(playerid){
if (IsPlayerInAnyVehicle(playerid) == 1) {
new Float:x,Float:y,Float:z,Float:rot;
GetPlayerPos(playerid,x,y,z);
GetXYBehindPlayer(playerid,x,y,30);
GetVehicleZAngle(GetPlayerVehicleID(playerid),rot);
SetVehiclePos(hydra1,x,y,z);SetVehicleZAngle(hydra1,rot);
SetVehiclePos(hydra2,x,y,z);SetVehicleZAngle(hydra2,rot);
} else {
DestroyVehicle(hydra1);
DestroyVehicle(hydra2);
escort = 0;
KillTimer(streamhydras(playerid));
}}
stock GetXYBehindPlayer(playerid,&Float:x,&Float:y,Float:dis)
{
new Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
GetPlayerFacingAngle(playerid,pos[2]);
GetXYBehindPoint(pos[0],pos[1],x,y,pos[2],dis);
}
stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:angle,Float:distance)
{
x2 = x - (distance * floatsin(-angle,degrees));
y2 = y - (distance * floatcos(-angle,degrees));
}
Rotation isnt fixed, but thats not the biggest problem, also it doenst update the player position BEHIND the player so still the same story