Szerző Téma: Half-Life 2 féle Gravity gun  (Megtekintve 1265 alkalommal)

Half-Life 2 féle Gravity gun
« Dátum: 2014. május 25. - 09:21:05 »
+2 Show voters
Üdvözölek a topicban!
 
Leírás:
- Ez a filterszkript ara szolgál, hogy az adott fegyvered úgy viselkedhesen mint a Half-Life 2-ben lévõ Gravity gun. Alkalmass FUN szerverekre, de RP szervere viszont már nem alkalmass, és nem ajánlott!

- Ez az FS csak is Deagle pisztolyal mûküdik.



Készítõk:
Gravity Gun - Matz
Szerkesztette/Javította - whatthefuck123
 

Kód:
 
#include <a_samp>
native IsValidVehicle(vehicleid);
#define PRESSED(%0) \\
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \\
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
new Float:GUNDISTANCE[MAX_PLAYERS] = {10.0,...};
new check_timer[MAX_PLAYERS];
new aiming[MAX_PLAYERS];
//new movetimer[MAX_PLAYERS];
new liftimer[MAX_PLAYERS];
new lifting[MAX_PLAYERS];
new lifttype[MAX_PLAYERS]; // 0 = vehicle, 1 = human
public OnFilterScriptInit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    lifting = -1;
    lifttype = -1;
}
return 1;
}
public OnFilterScriptExit()
{
    KillTimer(liftimer[0]);
    KillTimer(check_timer[0]);
}
public OnPlayerConnect(playerid)
{
aiming[playerid]=0;
    lifting[playerid] = -1;
    lifttype[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(liftimer[playerid]);
    KillTimer(check_timer[playerid]);
    lifting[playerid] = -1;
return 1;
}
stock movecar(vehid, playerid)
{
    new Float:vector[3];
      GetPlayerCameraFrontVector(playerid, vector[0], vector[1], vector[2]);
new Float:lx,Float:ly,Float:lz;
GetPlayerPos(playerid, lx,ly,lz);
PutPlayerInVehicle(playerid, vehid, 0);
SetVehicleVelocity(vehid,vector[0], vector[1], vector[2]);
SetPlayerPos(playerid, lx,ly,lz);
//RemovePlayerFromVehicle(playerid);
}
stock getcar(vehid, playerid)
{
    new Float:vector[3];
      GetPlayerCameraFrontVector(playerid, vector[0], vector[1], vector[2]);
new Float:lx,Float:ly,Float:lz;
GetPlayerPos(playerid, lx,ly,lz);
PutPlayerInVehicle(playerid, vehid, 0);
SetVehicleVelocity(vehid, -vector[0], -vector[1], -vector[2]);
SetPlayerPos(playerid, lx,ly,lz);
check_timer[playerid] = SetTimerEx(\"checkyet\",50,1,\"ii\",playerid,vehid);
//RemovePlayerFromVehicle(playerid);
}
forward checkyet(playerid,vehid);
public checkyet(playerid,vehid)
{
    new Float:x,Float:y,Float:z;
    GetVehiclePos(vehid, x,y,z);
if(GetPlayerDistanceFromPoint(playerid, x,y,z)<15.0)
{
KillTimer(check_timer[playerid]);
SetTimerEx(\"enablegravity\", 10, 0, \"iii\", playerid, vehid, 0);
//   SendClientMessage(playerid, -1, \"ok\");
}
else
{
//   printf(\"%f\",GetPlayerDistanceFromPoint(playerid, x,y,z));
//SendClientMessage(playerid, -1, \"nope\");
}
}
forward Lift(playerid);
public Lift(playerid)
{
if(lifttype[playerid] == 0)//vehicle
{
    new Float:X2, Float:Y2, Float:Z2;
GetPlayerCameraLookAt(playerid, X2, Y2, Z2);
SetVehiclePos(lifting[playerid],X2, Y2, Z2);
}
if(lifttype[playerid] == 1)//player
{
    new Float:X2, Float:Y2, Float:Z2;
GetPlayerCameraLookAt(playerid, X2, Y2, Z2);
SetPlayerPos(lifting[playerid],X2, Y2, Z2);
}
if(lifttype[playerid] == 2)//object
{
    new Float:X2, Float:Y2, Float:Z2;
GetPlayerCameraLookAt(playerid, X2, Y2, Z2);
SetObjectPos(lifting[playerid],X2, Y2, Z2);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(128))
{
aiming[playerid]^=1;//toggle
}
if(RELEASED(128))//KEY_AIM
{
    if(lifting[playerid]!=-1)
    {
        KillTimer(liftimer[playerid]);
        KillTimer(check_timer[playerid]);
    lifting[playerid] = -1;
    PlayerPlaySound(playerid, 1140, 0,0,0);//SOUND_CAR_SMASH_CAR
    }
}
if(PRESSED(KEY_LOOK_BEHIND)&&lifting[playerid]==-1)
{
    if(lifting[playerid] == -1)
    {
    new Float:X, Float:Y, Float:Z, vehicleid;
   for(new i = 0; i < MAX_VEHICLES; i++)
   {
       if(IsValidVehicle(i))
       {
         GetVehiclePos(i, X, Y, Z);
         if(IsPlayerAimingAt(playerid, X, Y, Z, 2.5))
         {
              vehicleid = i;
          }
       }
   }
   if(vehicleid > 0)
   {
                new Float:x,Float:y,Float:z;
                GetVehiclePos(vehicleid, x,y,z);
                new Float: dist = GetPlayerDistanceFromPoint(playerid, x,y,z);
                //SetTimerEx(\"enablegravity\", floatround(dist)/5, 0, \"iii\", playerid, vehicleid, 0);
                lifting[playerid]=vehicleid;
               //printf(\"%d\",floatround(dist)/5);
                if(dist>12.0) getcar(vehicleid, playerid);
                else
                {
                    SetTimerEx(\"enablegravity\", 10, 0, \"iii\", playerid, vehicleid, 0);
                }
       }
        }
if(lifting[playerid] == -1)
    {
        new Float:X, Float:Y, Float:Z, targetid=INVALID_PLAYER_ID;
       for(new i = 0; i < MAX_PLAYERS; i++)
   {
       if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
       {
           if(i == playerid) continue;
         GetPlayerPos(i, X, Y, Z);
         if(IsPlayerAimingAt(playerid, X, Y, Z, 2.5))
         {
              targetid = i;
          }
       }
   }
   if(targetid!=INVALID_PLAYER_ID)
   {
       lifting[playerid] = targetid;
       lifttype[playerid] = 1;
       liftimer[playerid] = SetTimerEx(\"Lift\", 50, 1, \"i\", playerid);
       PlayerPlaySound(playerid, 1148, 0,0,0);//SOUND_MAGNET_VEHICLE_COLLISION
       }
}
if(lifting[playerid] == -1)
    {
        new Float:X, Float:Y, Float:Z, targetid=INVALID_OBJECT_ID;
       for(new i = 0; i < MAX_OBJECTS; i++)
   {
       if(IsValidObject(i))
       {
           if(i == INVALID_OBJECT_ID) continue;
         GetObjectPos(i, X, Y, Z);
         if(IsPlayerAimingAt(playerid, X, Y, Z, 2.5))
         {
             if(IsObjectMoving(i))
              {
               StopObject(i);
              }
              targetid = i;
          }
       }
   }
   if(targetid!=INVALID_OBJECT_ID)
   {
       new Float:ox,Float:oy,Float:oz;
       GetObjectPos(targetid, ox,oy,oz);
       new Float:px,Float:py,Float:pz;
       GetPlayerPos(playerid, px,py,pz);
       new Float:angle;
                lifting[playerid]=targetid;
      GetPlayerFacingAngle(playerid,angle);
                new Float:dist = GetPlayerDistanceFromPoint(playerid, ox,oy,oz);
       new time = MoveObject(targetid, px+(5.0*floatsin(-angle, degrees)),py+(5.0*floatcos(-angle, degrees)),pz+1.0, dist*1.7);//
      SetTimerEx(\"enablegravity\", time, 0, \"iii\", playerid, targetid, 2);
      //printf(\"%d\", time);
       }
}
/*   if(lifting[playerid]!=-1)
{
    PlayerPlaySound(playerid, 1148, 0,0,0);//SOUND_MAGNET_VEHICLE_COLLISION
}*/
}
if(PRESSED(KEY_FIRE))
{
    if(lifting[playerid] != -1)
    {
          new Float:vector[3];
       GetPlayerCameraFrontVector(playerid, vector[0], vector[1], vector[2]);
        if(lifttype[playerid]==1)//player
        {
            SetPlayerVelocity(lifting[playerid], vector[0],vector[1],vector[2]);
            new str[128];
            new name[24]; GetPlayerName(playerid, name,sizeof(name));
            format(str,sizeof(str),\"You have been thrown by %s (%d)\",name,playerid);
      SendClientMessage(lifting[playerid], -1, str);
   }
        if(lifttype[playerid]==0)//car
        {
            //movetimer[playerid] = SetTimerEx(\"movecar\", 50, 0, \"i\", lifting[playerid], vector[0],vector[1], vector[2]);//create move Timer here....
            movecar(lifting[playerid], playerid);
      //PlayerPlaySound(playerid, 1140, 0,0,0);//SOUND_CAR_SMASH_CAR
        }
        if(lifttype[playerid]==2)//obj
   {
                //PlayerPlaySound(playerid, 1141, 0,0,0);//SOUND_CAR_SMASH_GATE
       new Float:Vector[3], Float:x,Float:y,Float:z;
       GetPlayerCameraFrontVector(playerid, Vector[0], Vector[1], Vector[2]);
       GetObjectPos(lifting[playerid], x,y,z);
       //I removed this part, u can make it exact if u want
       new Float:vertical=0.0, Float:horizontal=0.0;
       switch (GetPlayerWeapon(playerid))
      {
         case 34,35,36:
         {
            //if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
            //return false;
         }
         case 30,31: { vertical = 4.0; horizontal = -1.6; }
         case 33: { vertical = 2.7; horizontal = -1.0; }
         default: { vertical = 6.0; horizontal = -2.2; }
      }
          MoveObject(lifting[playerid], x+(Vector[0]*200.0)+horizontal,y+(Vector[1]*200.0)+horizontal,z+(Vector[2]*200.0)+vertical, 35.0);
   }
        KillTimer(liftimer[playerid]);
    lifting[playerid] = -1;
    }
}
return 1;
}
forward enablegravity(playerid, targetId, lift_type);
public enablegravity(playerid, targetId, lift_type)
{
    PlayerPlaySound(playerid, 1148, 0,0,0);//SOUND_MAGNET_VEHICLE_COLLISION
lifting[playerid] = targetId;
lifttype[playerid] = lift_type;
liftimer[playerid] = SetTimerEx(\"Lift\", 50, 1, \"i\", playerid);
}
stock IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
    static
        Float:pX, Float:pY, Float:pZ;
    GetVehiclePos(vehicleid, pX, pY, pZ);
    return x - range / 2 < pX > x + range / 2 && y - range / 2 < pY > y + range / 2 && z - range / 2 < pZ > z + range / 2;
}
GetPlayerCameraLookAt(playerid, &Float:X, &Float:Y, &Float:Z)
{
    new Float:Destination[3], Float:Camera[3], Float:Vector[3];
    GetPlayerPos(playerid, Destination[0], Destination[1], Destination[2]);
    GetPlayerCameraPos(playerid, Camera[0], Camera[1], Camera[2]);
    GetPlayerCameraFrontVector(playerid, Vector[0], Vector[1], Vector[2]);
    new Float: posAngle = atan2(floatsub(Destination[1],Camera[1]),floatsub(Destination[0],Camera[0]));
    if(posAngle > 360) posAngle-=360; posAngle+=270; posAngle *= -1;
    Destination[0] += GUNDISTANCE[playerid] * floatsin(posAngle, degrees);
    Destination[1] += GUNDISTANCE[playerid] * floatcos(posAngle, degrees);
    new Float:dis = floatsqroot((Camera[0] - Destination[0]) * (Camera[0] - Destination[0]) + (Camera[1] - Destination[1]) * (Camera[1] - Destination[1]) + (Camera[2] - Destination[2]) * (Camera[2] - Destination[2]));
    X = Vector[0] * dis + Camera[0]; Y = Vector[1] * dis + Camera[1];       Z = Vector[2] * dis + Camera[2];
}
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
{
new Float:TGTDistance;
TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
new Float:tmpX, Float:tmpY, Float:tmpZ;
tmpX = FrX * TGTDistance + CamX;
tmpY = FrY * TGTDistance + CamY;
tmpZ = FrZ * TGTDistance + CamZ;
return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y)
{
new Float:DX, Float:DY;
new Float:angle;
DX = floatabs(floatsub(x2,X));
DY = floatabs(floatsub(y2,Y));
if (DY == 0.0 || DX == 0.0) {
if(DY == 0 && DX > 0) angle = 0.0;
else if(DY == 0 && DX < 0) angle = 180.0;
else if(DY > 0 && DX == 0) angle = 90.0;
else if(DY < 0 && DX == 0) angle = 270.0;
else if(DY == 0 && DX == 0) angle = 0.0;
}
else {
angle = atan(DX/DY);
if(X > x2 && Y <= y2) angle += 90.0;
else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
else if(X < x2 && Y >= y2) angle -= 90.0;
else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
}
return floatadd(angle, 90.0);
}
stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
{
x += (distance * floatsin(-angle, degrees));
y += (distance * floatcos(-angle, degrees));
}
stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
{
new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;
GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);
new Float:vertical, Float:horizontal;
switch (GetPlayerWeapon(playerid))
{
case 34,35,36:
{
   if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
   return false;
}
case 30,31: { vertical = 4.0; horizontal = -1.6; }
case 33: { vertical = 2.7; horizontal = -1.0; }
default: { vertical = 6.0; horizontal = -2.2; }
}
new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));
if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
return false;
}

Half-Life 2 féle Gravity gun
« Válasz #1 Dátum: 2014. május 25. - 09:21:05 »
0 Show voters
Üdvözölek a topicban!
 
Leírás:
- Ez a filterszkript ara szolgál, hogy az adott fegyvered úgy viselkedhesen mint a Half-Life 2-ben lévõ Gravity gun. Alkalmass FUN szerverekre, de RP szervere viszont már nem alkalmass, és nem ajánlott!

- Ez az FS csak is Deagle pisztolyal mûküdik.



Készítõk:
Gravity Gun - Matz
Szerkesztette/Javította - whatthefuck123
 

Kód:
 
#include <a_samp>
native IsValidVehicle(vehicleid);
#define PRESSED(%0) \\
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \\
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
new Float:GUNDISTANCE[MAX_PLAYERS] = {10.0,...};
new check_timer[MAX_PLAYERS];
new aiming[MAX_PLAYERS];
//new movetimer[MAX_PLAYERS];
new liftimer[MAX_PLAYERS];
new lifting[MAX_PLAYERS];
new lifttype[MAX_PLAYERS]; // 0 = vehicle, 1 = human
public OnFilterScriptInit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
    lifting = -1;
    lifttype = -1;
}
return 1;
}
public OnFilterScriptExit()
{
    KillTimer(liftimer[0]);
    KillTimer(check_timer[0]);
}
public OnPlayerConnect(playerid)
{
aiming[playerid]=0;
    lifting[playerid] = -1;
    lifttype[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(liftimer[playerid]);
    KillTimer(check_timer[playerid]);
    lifting[playerid] = -1;
return 1;
}
stock movecar(vehid, playerid)
{
    new Float:vector[3];
      GetPlayerCameraFrontVector(playerid, vector[0], vector[1], vector[2]);
new Float:lx,Float:ly,Float:lz;
GetPlayerPos(playerid, lx,ly,lz);
PutPlayerInVehicle(playerid, vehid, 0);
SetVehicleVelocity(vehid,vector[0], vector[1], vector[2]);
SetPlayerPos(playerid, lx,ly,lz);
//RemovePlayerFromVehicle(playerid);
}
stock getcar(vehid, playerid)
{
    new Float:vector[3];
      GetPlayerCameraFrontVector(playerid, vector[0], vector[1], vector[2]);
new Float:lx,Float:ly,Float:lz;
GetPlayerPos(playerid, lx,ly,lz);
PutPlayerInVehicle(playerid, vehid, 0);
SetVehicleVelocity(vehid, -vector[0], -vector[1], -vector[2]);
SetPlayerPos(playerid, lx,ly,lz);
check_timer[playerid] = SetTimerEx(\"checkyet\",50,1,\"ii\",playerid,vehid);
//RemovePlayerFromVehicle(playerid);
}
forward checkyet(playerid,vehid);
public checkyet(playerid,vehid)
{
    new Float:x,Float:y,Float:z;
    GetVehiclePos(vehid, x,y,z);
if(GetPlayerDistanceFromPoint(playerid, x,y,z)<15.0)
{
KillTimer(check_timer[playerid]);
SetTimerEx(\"enablegravity\", 10, 0, \"iii\", playerid, vehid, 0);
//   SendClientMessage(playerid, -1, \"ok\");
}
else
{
//   printf(\"%f\",GetPlayerDistanceFromPoint(playerid, x,y,z));
//SendClientMessage(playerid, -1, \"nope\");
}
}
forward Lift(playerid);
public Lift(playerid)
{
if(lifttype[playerid] == 0)//vehicle
{
    new Float:X2, Float:Y2, Float:Z2;
GetPlayerCameraLookAt(playerid, X2, Y2, Z2);
SetVehiclePos(lifting[playerid],X2, Y2, Z2);
}
if(lifttype[playerid] == 1)//player
{
    new Float:X2, Float:Y2, Float:Z2;
GetPlayerCameraLookAt(playerid, X2, Y2, Z2);
SetPlayerPos(lifting[playerid],X2, Y2, Z2);
}
if(lifttype[playerid] == 2)//object
{
    new Float:X2, Float:Y2, Float:Z2;
GetPlayerCameraLookAt(playerid, X2, Y2, Z2);
SetObjectPos(lifting[playerid],X2, Y2, Z2);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(128))
{
aiming[playerid]^=1;//toggle
}
if(RELEASED(128))//KEY_AIM
{
    if(lifting[playerid]!=-1)
    {
        KillTimer(liftimer[playerid]);
        KillTimer(check_timer[playerid]);
    lifting[playerid] = -1;
    PlayerPlaySound(playerid, 1140, 0,0,0);//SOUND_CAR_SMASH_CAR
    }
}
if(PRESSED(KEY_LOOK_BEHIND)&&lifting[playerid]==-1)
{
    if(lifting[playerid] == -1)
    {
    new Float:X, Float:Y, Float:Z, vehicleid;
   for(new i = 0; i < MAX_VEHICLES; i++)
   {
       if(IsValidVehicle(i))
       {
         GetVehiclePos(i, X, Y, Z);
         if(IsPlayerAimingAt(playerid, X, Y, Z, 2.5))
         {
              vehicleid = i;
          }
       }
   }
   if(vehicleid > 0)
   {
                new Float:x,Float:y,Float:z;
                GetVehiclePos(vehicleid, x,y,z);
                new Float: dist = GetPlayerDistanceFromPoint(playerid, x,y,z);
                //SetTimerEx(\"enablegravity\", floatround(dist)/5, 0, \"iii\", playerid, vehicleid, 0);
                lifting[playerid]=vehicleid;
               //printf(\"%d\",floatround(dist)/5);
                if(dist>12.0) getcar(vehicleid, playerid);
                else
                {
                    SetTimerEx(\"enablegravity\", 10, 0, \"iii\", playerid, vehicleid, 0);
                }
       }
        }
if(lifting[playerid] == -1)
    {
        new Float:X, Float:Y, Float:Z, targetid=INVALID_PLAYER_ID;
       for(new i = 0; i < MAX_PLAYERS; i++)
   {
       if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
       {
           if(i == playerid) continue;
         GetPlayerPos(i, X, Y, Z);
         if(IsPlayerAimingAt(playerid, X, Y, Z, 2.5))
         {
              targetid = i;
          }
       }
   }
   if(targetid!=INVALID_PLAYER_ID)
   {
       lifting[playerid] = targetid;
       lifttype[playerid] = 1;
       liftimer[playerid] = SetTimerEx(\"Lift\", 50, 1, \"i\", playerid);
       PlayerPlaySound(playerid, 1148, 0,0,0);//SOUND_MAGNET_VEHICLE_COLLISION
       }
}
if(lifting[playerid] == -1)
    {
        new Float:X, Float:Y, Float:Z, targetid=INVALID_OBJECT_ID;
       for(new i = 0; i < MAX_OBJECTS; i++)
   {
       if(IsValidObject(i))
       {
           if(i == INVALID_OBJECT_ID) continue;
         GetObjectPos(i, X, Y, Z);
         if(IsPlayerAimingAt(playerid, X, Y, Z, 2.5))
         {
             if(IsObjectMoving(i))
              {
               StopObject(i);
              }
              targetid = i;
          }
       }
   }
   if(targetid!=INVALID_OBJECT_ID)
   {
       new Float:ox,Float:oy,Float:oz;
       GetObjectPos(targetid, ox,oy,oz);
       new Float:px,Float:py,Float:pz;
       GetPlayerPos(playerid, px,py,pz);
       new Float:angle;
                lifting[playerid]=targetid;
      GetPlayerFacingAngle(playerid,angle);
                new Float:dist = GetPlayerDistanceFromPoint(playerid, ox,oy,oz);
       new time = MoveObject(targetid, px+(5.0*floatsin(-angle, degrees)),py+(5.0*floatcos(-angle, degrees)),pz+1.0, dist*1.7);//
      SetTimerEx(\"enablegravity\", time, 0, \"iii\", playerid, targetid, 2);
      //printf(\"%d\", time);
       }
}
/*   if(lifting[playerid]!=-1)
{
    PlayerPlaySound(playerid, 1148, 0,0,0);//SOUND_MAGNET_VEHICLE_COLLISION
}*/
}
if(PRESSED(KEY_FIRE))
{
    if(lifting[playerid] != -1)
    {
          new Float:vector[3];
       GetPlayerCameraFrontVector(playerid, vector[0], vector[1], vector[2]);
        if(lifttype[playerid]==1)//player
        {
            SetPlayerVelocity(lifting[playerid], vector[0],vector[1],vector[2]);
            new str[128];
            new name[24]; GetPlayerName(playerid, name,sizeof(name));
            format(str,sizeof(str),\"You have been thrown by %s (%d)\",name,playerid);
      SendClientMessage(lifting[playerid], -1, str);
   }
        if(lifttype[playerid]==0)//car
        {
            //movetimer[playerid] = SetTimerEx(\"movecar\", 50, 0, \"i\", lifting[playerid], vector[0],vector[1], vector[2]);//create move Timer here....
            movecar(lifting[playerid], playerid);
      //PlayerPlaySound(playerid, 1140, 0,0,0);//SOUND_CAR_SMASH_CAR
        }
        if(lifttype[playerid]==2)//obj
   {
                //PlayerPlaySound(playerid, 1141, 0,0,0);//SOUND_CAR_SMASH_GATE
       new Float:Vector[3], Float:x,Float:y,Float:z;
       GetPlayerCameraFrontVector(playerid, Vector[0], Vector[1], Vector[2]);
       GetObjectPos(lifting[playerid], x,y,z);
       //I removed this part, u can make it exact if u want
       new Float:vertical=0.0, Float:horizontal=0.0;
       switch (GetPlayerWeapon(playerid))
      {
         case 34,35,36:
         {
            //if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
            //return false;
         }
         case 30,31: { vertical = 4.0; horizontal = -1.6; }
         case 33: { vertical = 2.7; horizontal = -1.0; }
         default: { vertical = 6.0; horizontal = -2.2; }
      }
          MoveObject(lifting[playerid], x+(Vector[0]*200.0)+horizontal,y+(Vector[1]*200.0)+horizontal,z+(Vector[2]*200.0)+vertical, 35.0);
   }
        KillTimer(liftimer[playerid]);
    lifting[playerid] = -1;
    }
}
return 1;
}
forward enablegravity(playerid, targetId, lift_type);
public enablegravity(playerid, targetId, lift_type)
{
    PlayerPlaySound(playerid, 1148, 0,0,0);//SOUND_MAGNET_VEHICLE_COLLISION
lifting[playerid] = targetId;
lifttype[playerid] = lift_type;
liftimer[playerid] = SetTimerEx(\"Lift\", 50, 1, \"i\", playerid);
}
stock IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
    static
        Float:pX, Float:pY, Float:pZ;
    GetVehiclePos(vehicleid, pX, pY, pZ);
    return x - range / 2 < pX > x + range / 2 && y - range / 2 < pY > y + range / 2 && z - range / 2 < pZ > z + range / 2;
}
GetPlayerCameraLookAt(playerid, &Float:X, &Float:Y, &Float:Z)
{
    new Float:Destination[3], Float:Camera[3], Float:Vector[3];
    GetPlayerPos(playerid, Destination[0], Destination[1], Destination[2]);
    GetPlayerCameraPos(playerid, Camera[0], Camera[1], Camera[2]);
    GetPlayerCameraFrontVector(playerid, Vector[0], Vector[1], Vector[2]);
    new Float: posAngle = atan2(floatsub(Destination[1],Camera[1]),floatsub(Destination[0],Camera[0]));
    if(posAngle > 360) posAngle-=360; posAngle+=270; posAngle *= -1;
    Destination[0] += GUNDISTANCE[playerid] * floatsin(posAngle, degrees);
    Destination[1] += GUNDISTANCE[playerid] * floatcos(posAngle, degrees);
    new Float:dis = floatsqroot((Camera[0] - Destination[0]) * (Camera[0] - Destination[0]) + (Camera[1] - Destination[1]) * (Camera[1] - Destination[1]) + (Camera[2] - Destination[2]) * (Camera[2] - Destination[2]));
    X = Vector[0] * dis + Camera[0]; Y = Vector[1] * dis + Camera[1];       Z = Vector[2] * dis + Camera[2];
}
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
{
new Float:TGTDistance;
TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
new Float:tmpX, Float:tmpY, Float:tmpZ;
tmpX = FrX * TGTDistance + CamX;
tmpY = FrY * TGTDistance + CamY;
tmpZ = FrZ * TGTDistance + CamZ;
return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y)
{
new Float:DX, Float:DY;
new Float:angle;
DX = floatabs(floatsub(x2,X));
DY = floatabs(floatsub(y2,Y));
if (DY == 0.0 || DX == 0.0) {
if(DY == 0 && DX > 0) angle = 0.0;
else if(DY == 0 && DX < 0) angle = 180.0;
else if(DY > 0 && DX == 0) angle = 90.0;
else if(DY < 0 && DX == 0) angle = 270.0;
else if(DY == 0 && DX == 0) angle = 0.0;
}
else {
angle = atan(DX/DY);
if(X > x2 && Y <= y2) angle += 90.0;
else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
else if(X < x2 && Y >= y2) angle -= 90.0;
else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
}
return floatadd(angle, 90.0);
}
stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
{
x += (distance * floatsin(-angle, degrees));
y += (distance * floatcos(-angle, degrees));
}
stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
{
new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;
GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);
new Float:vertical, Float:horizontal;
switch (GetPlayerWeapon(playerid))
{
case 34,35,36:
{
   if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
   return false;
}
case 30,31: { vertical = 4.0; horizontal = -1.6; }
case 33: { vertical = 2.7; horizontal = -1.0; }
default: { vertical = 6.0; horizontal = -2.2; }
}
new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));
if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
return false;
}

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal