03.12.2015, 16:00
Something like this?
Does what you asked, adjust to your needs.
PHP код:
forward startairrecon(playerid, laptop_objid, Float:x, Float:y, Float:z, Float:a);
forward endar(playerid, laptop_objid);
CMD:ar(playerid, params[])
{
if(GetPVarInt(playerid,"AirReconOnline")) return SendClientMessage(playerid,COLOR_RED,"ERROR: You have already set the Air Recon Online!");
if(gTeam[playerid] != TEAM_Internationalforces) return SendClientMessage(playerid,COLOR_RED,"ERROR: Your team dosent have Satellite!");
if(gTeam[playerid] == TEAM_Internationalforces)
{
if(GetPlayerMoney(playerid) < 90000) return SendClientMessage(playerid,0xFF0000FF,"You dont have money to use Satellite!");
SendClientMessage(playerid,COLOR_BLUE,"i need air recon online!");
SendClientMessage(playerid,COLOR_BLUE,"copy that we are coming to your position in 2 sec!");
SendClientMessage(playerid,COLOR_RED,"You lost $90000 for air recon.");
GivePlayerMoney(playerid, -90000);
new Float:x, Float:y, Float:z, Float:a, laptop_objid;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
laptop_objid = CreateObject(19894,
x + (0.5 * floatsin(-a, degrees)),
y + (0.5 * floatcos(-a, degrees)),
z + 0.15, 0.0, 0.0, a);
SetTimerEx("startairrecon", 2000, false, "iiffff", playerid, laptop_objid, x, y, z, a);
}
return 1;
}
public startairrecon(playerid, laptop_objid, Float:x, Float:y, Float:z, Float:a)
{
SetPVarInt(playerid,"AirReconOnline",true);
SendClientMessage(playerid,COLOR_BLUE,"We are in your position you can use Satellite!");
if (IsValidObject(laptop_objid)) DestroyObject(laptop_objid);
new objid;
objid = CreateObject(19893,
x + (0.5 * floatsin(-a, degrees)),
y + (0.5 * floatcos(-a, degrees)),
z + 0.15, 0.0, 0.0, a);
SetPlayerCameraPos(playerid, x, y, z+30.0);
SetPlayerCameraLookAt(playerid, x, y, z);
SetTimerEx("endar", 60000, false, "ii", playerid, objid);
return 1;
}
public endar(playerid, laptop_objid)
{
if (IsValidObject(laptop_objid)) DestroyObject(laptop_objid);
new Float:x, Float:y, Float:z, Float:a, obj;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
// trigonometry "magic", adjust numbers at will
x += 0.5 * floatsin(-a, degrees);
y += 0.5 * floatcos(-a, degrees);
z += 0.15;
// optionally you may want to save the object id
// so you can remove the object afterwards
CreateObject(19894, x, y, z, 0.0, 0.0, a);
// presumably you want this too + SetCameraBehindPlayer()
TogglePlayerControllable(playerid, 1);
return 1;
}