SHARE
TWEET

Untitled

a guest Aug 25th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. int plyvehicle[65];
  6.  
  7. public void OnPluginStart()
  8. {
  9.     RegConsoleCmd("stuck",stuckblck);
  10.     RegConsoleCmd("sm_airboat",airboatcreate);
  11.     HookEventEx("entity_killed",Event_EntityKilled,EventHookMode_Post);
  12. }
  13.  
  14. public void OnMapStart()
  15. {
  16.     for (int i = 1;i<MaxClients+1;i++)
  17.     {
  18.         plyvehicle[i] = 0;
  19.     }
  20. }
  21.  
  22. public Action Event_EntityKilled(Handle event, const char[] name, bool Broadcast)
  23. {
  24.     int killed = GetEventInt(event, "entindex_killed");
  25.     if ((killed > 0) && (killed < MaxClients+1))
  26.     {
  27.         if ((plyvehicle[killed] != 0) && (IsValidEntity(plyvehicle[killed])))
  28.         {
  29.             char clschk[32];
  30.             GetEntityClassname(plyvehicle[killed],clschk,sizeof(clschk));
  31.             if (StrContains(clschk,"prop_vehicle",false) != -1)
  32.             {
  33.                 if (HasEntProp(plyvehicle[killed],Prop_Data,"m_hPlayer"))
  34.                 {
  35.                     int plychk = GetEntPropEnt(plyvehicle[killed],Prop_Data,"m_hPlayer");
  36.                     if (plychk == -1)
  37.                     {
  38.                         AcceptEntityInput(plyvehicle[killed],"kill");
  39.                         plyvehicle[killed] = 0;
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
  46.  
  47. public Action stuckblck(int client, int args)
  48. {
  49.     if (!IsValidEntity(client)) return Plugin_Handled;
  50.     if ((client == 0) || (!IsPlayerAlive(client))) return Plugin_Handled;
  51.     int vckent = GetEntPropEnt(client, Prop_Send, "m_hVehicle");
  52.     if (vckent != -1)
  53.     {
  54.         SetEntPropEnt(client,Prop_Data,"m_hMoveParent",-1);
  55.         SetEntPropEnt(client,Prop_Data,"m_hParent",-1);
  56.         SetEntPropEnt(client,Prop_Data,"m_pParent",-1);
  57.         SetEntProp(client,Prop_Data,"m_fFlags",257);
  58.         SetEntProp(client,Prop_Data,"m_iEFlags",38011920);
  59.         SetEntProp(client,Prop_Data,"m_MoveType",2);
  60.         SetEntProp(client,Prop_Data,"m_bDrawViewmodel",1);
  61.         SetEntProp(client,Prop_Data,"m_iHideHUD",2048);
  62.         setupvehicle(vckent,client,false);
  63.         int clweap = GetEntPropEnt(client,Prop_Data,"m_hActiveWeapon");
  64.         if (clweap != -1)
  65.             if (HasEntProp(clweap,Prop_Data,"m_fEffects")) SetEntProp(clweap,Prop_Data,"m_fEffects",161);
  66.     }
  67.     return Plugin_Continue;
  68. }
  69.  
  70. public Action airboatcreate(int client, int args)
  71. {
  72.     if (!IsValidEntity(client)) return Plugin_Handled;
  73.     if ((client == 0) || (!IsPlayerAlive(client))) return Plugin_Handled;
  74.     int curvchk = GetEntPropEnt(client,Prop_Data,"m_hVehicle");
  75.     if (curvchk == -1)
  76.     {
  77.         if ((IsValidEntity(plyvehicle[client])) && (plyvehicle[client] != 0))
  78.         {
  79.             char clschk[32];
  80.             GetEntityClassname(plyvehicle[client],clschk,sizeof(clschk));
  81.             if (StrContains(clschk,"prop_vehicle",false) != -1)
  82.             {
  83.                 if (HasEntProp(plyvehicle[client],Prop_Data,"m_hPlayer"))
  84.                 {
  85.                     int plychk = GetEntPropEnt(plyvehicle[client],Prop_Data,"m_hPlayer");
  86.                     if (plychk == -1)
  87.                     {
  88.                         AcceptEntityInput(plyvehicle[client],"kill");
  89.                         plyvehicle[client] = 0;
  90.                     }
  91.                 }
  92.             }
  93.         }
  94.         float plyorg[3];
  95.         float plyang[3];
  96.         GetClientAbsOrigin(client,plyorg);
  97.         GetClientEyeAngles(client,plyang);
  98.         int vehiclenext = CreateEntityByName("prop_vehicle_airboat");
  99.         if ((vehiclenext != -1) && ((!IsValidEntity(plyvehicle[client])) || (plyvehicle[client] == 0)))
  100.         {
  101.             DispatchKeyValue(vehiclenext,"EnableGun","0");
  102.             DispatchKeyValue(vehiclenext,"VehicleScript","scripts/vehicles/airboat.txt");
  103.             DispatchKeyValue(vehiclenext,"model","models/airboat.mdl");
  104.             DispatchKeyValue(vehiclenext,"solid","6");
  105.             plyorg[2]+=10.0;
  106.             plyang[0] = 0.0;
  107.             plyang[2] = 0.0;
  108.             plyang[1]-=90.0;
  109.             TeleportEntity(vehiclenext,plyorg,plyang,NULL_VECTOR);
  110.             DispatchSpawn(vehiclenext);
  111.             ActivateEntity(vehiclenext);
  112.             plyvehicle[client] = vehiclenext;
  113.             SetVariantString("!activator");
  114.             AcceptEntityInput(vehiclenext,"EnterVehicleImmediate",client);
  115.             SetEntPropEnt(client,Prop_Data,"m_hVehicle",vehiclenext);
  116.             SetEntPropEnt(client,Prop_Data,"m_hParent",vehiclenext);
  117.             SetEntPropEnt(client,Prop_Data,"m_pParent",vehiclenext);
  118.             SetEntPropEnt(client,Prop_Data,"m_hMoveParent",vehiclenext);
  119.             SetEntProp(client,Prop_Data,"m_iHideHUD",3328);
  120.             SetEntProp(client,Prop_Data,"m_fFlags",256);
  121.             SetEntProp(client,Prop_Data,"m_iEFlags",38016016);
  122.             SetEntProp(client,Prop_Data,"m_MoveType",8);
  123.             SetEntProp(client,Prop_Data,"m_bDrawViewmodel",0);
  124.             SetEntProp(client,Prop_Data,"m_CollisionGroup",11);
  125.             setupvehicle(vehiclenext,client,true);
  126.             float orgoverride[3];
  127.             orgoverride[0] = -0.08;
  128.             orgoverride[1] = -10.99;
  129.             orgoverride[2] = 34.29;
  130.             SetEntProp(vehiclenext,Prop_Data,"m_iEFlags",9175056);
  131.             SetEntPropFloat(vehiclenext,Prop_Data,"m_maxThrottle",2.3);
  132.             SetEntPropFloat(vehiclenext,Prop_Data,"m_flMaxRevThrottle",-2.0);
  133.             SetEntPropVector(client,Prop_Data,"m_vecOrigin",orgoverride);
  134.             int clweap = GetEntPropEnt(client,Prop_Data,"m_hActiveWeapon");
  135.             if (clweap != -1)
  136.                 if (HasEntProp(clweap,Prop_Data,"m_fEffects")) SetEntProp(clweap,Prop_Data,"m_fEffects",161);
  137.         }
  138.     }
  139.     return Plugin_Handled;
  140. }
  141.  
  142. public void OnEntityDestroyed(int entity)
  143. {
  144.     for (int i = 1;i<MaxClients+1;i++)
  145.     {
  146.         if (plyvehicle[i] == entity) plyvehicle[i] = 0;
  147.     }
  148. }
  149.  
  150. public OnClientDisconnect_Post(int client)
  151. {
  152.     plyvehicle[client] = 0;
  153. }
  154.  
  155. setupvehicle(int vehicle, int client, bool enterexit)
  156. {
  157.     if ((!enterexit) && (IsValidEntity(vehicle)))
  158.     {
  159.         if (HasEntProp(vehicle,Prop_Data,"m_hPlayer")) SetEntPropEnt(vehicle,Prop_Data,"m_hPlayer",-1);
  160.         if (HasEntProp(vehicle,Prop_Data,"m_hMoveChild")) SetEntPropEnt(vehicle,Prop_Data,"m_hMoveChild",-1);
  161.         if (HasEntProp(vehicle,Prop_Data,"m_bIsOn")) SetEntProp(vehicle,Prop_Data,"m_bIsOn",0);
  162.         if (HasEntProp(vehicle,Prop_Data,"m_iOnlyUser")) SetEntProp(vehicle,Prop_Data,"m_iOnlyUser",-1);
  163.         if (HasEntProp(vehicle,Prop_Data,"bRunningEnterExit")) SetEntProp(vehicle,Prop_Data,"bRunningEnterExit",1);
  164.         if (HasEntProp(vehicle,Prop_Data,"m_controls.throttle")) SetEntPropFloat(vehicle,Prop_Data,"m_controls.throttle",0.0);
  165.         if (HasEntProp(vehicle,Prop_Data,"m_controls.steering")) SetEntPropFloat(vehicle,Prop_Data,"m_controls.steering",0.0);
  166.         if (HasEntProp(vehicle,Prop_Data,"m_controls.brake")) SetEntPropFloat(vehicle,Prop_Data,"m_controls.brake",0.0);
  167.         if (HasEntProp(vehicle,Prop_Data,"m_controls.boost")) SetEntPropFloat(vehicle,Prop_Data,"m_controls.boost",0.0);
  168.         if (HasEntProp(vehicle,Prop_Data,"m_controls.handbrake")) SetEntProp(vehicle,Prop_Data,"m_controls.handbrake",1);
  169.         if (HasEntProp(vehicle,Prop_Data,"m_controls.handbrakeLeft")) SetEntProp(vehicle,Prop_Data,"m_controls.handbrakeLeft",0);
  170.         if (HasEntProp(vehicle,Prop_Data,"m_controls.handbrakeRight")) SetEntProp(vehicle,Prop_Data,"m_controls.handbrakeRight",0);
  171.         if (HasEntProp(vehicle,Prop_Data,"m_controls.brakepedal")) SetEntProp(vehicle,Prop_Data,"m_controls.brakepedal",0);
  172.         if (IsValidEntity(client))
  173.         {
  174.             if (IsClientConnected(client))
  175.             {
  176.                 if (IsClientInGame(client))
  177.                 {
  178.                     if (IsPlayerAlive(client))
  179.                     {
  180.                         CreateTimer(0.1,resetclvec,client,TIMER_FLAG_NO_MAPCHANGE);
  181.                     }
  182.                 }
  183.             }
  184.         }
  185.     }
  186.     else if ((enterexit) && (IsValidEntity(vehicle)) && (IsValidEntity(client)))
  187.     {
  188.         if (HasEntProp(vehicle,Prop_Data,"m_hPlayer")) SetEntPropEnt(vehicle,Prop_Data,"m_hPlayer",client);
  189.         if (HasEntProp(vehicle,Prop_Data,"m_hMoveChild")) SetEntPropEnt(vehicle,Prop_Data,"m_hMoveChild",client);
  190.         if (HasEntProp(vehicle,Prop_Data,"m_bIsOn")) SetEntProp(vehicle,Prop_Data,"m_bIsOn",1);
  191.         if (HasEntProp(vehicle,Prop_Data,"m_iNumberOfEntries")) SetEntProp(vehicle,Prop_Data,"m_iNumberOfEntries",1);
  192.         if (HasEntProp(vehicle,Prop_Data,"m_bSequenceLoops")) SetEntProp(vehicle,Prop_Data,"m_bSequenceLoops",1);
  193.         if (HasEntProp(vehicle,Prop_Data,"bWasRunningAnim")) SetEntProp(vehicle,Prop_Data,"bWasRunningAnim",1);
  194.         if (HasEntProp(vehicle,Prop_Data,"bRunningEnterExit")) SetEntProp(vehicle,Prop_Data,"bRunningEnterExit",0);
  195.         if (HasEntProp(vehicle,Prop_Data,"m_controls.handbrake")) SetEntProp(vehicle,Prop_Data,"m_controls.handbrake",0);
  196.         HookSingleEntityOutput(vehicle,"PlayerOff",EntityOutput:exitspawnvehicle,true);
  197.     }
  198. }
  199.  
  200. public Action resetclvec(Handle timer, int client)
  201. {
  202.     if (IsValidEntity(client))
  203.     {
  204.         if (IsClientConnected(client))
  205.         {
  206.             if (IsClientInGame(client))
  207.             {
  208.                 if (IsPlayerAlive(client))
  209.                 {
  210.                     float resetvec[3];
  211.                     SetEntPropVector(client,Prop_Data,"m_vecViewOffset",resetvec);
  212.                 }
  213.             }
  214.         }
  215.     }
  216. }
  217.  
  218. public Action exitspawnvehicle(const char[] output, int caller, int activator, float delay)
  219. {
  220.     if ((IsValidEntity(activator)) && (activator <= MaxClients) && (activator > 0))
  221.     {
  222.         if (IsClientInGame(activator))
  223.         {
  224.             float orgs[3];
  225.             if (HasEntProp(activator,Prop_Data,"m_vecAbsOrigin")) GetEntPropVector(activator,Prop_Data,"m_vecAbsOrigin",orgs);
  226.             SetEntPropEnt(activator,Prop_Data,"m_hMoveParent",-1);
  227.             SetEntPropEnt(activator,Prop_Data,"m_hParent",-1);
  228.             SetEntProp(activator,Prop_Data,"m_fFlags",257);
  229.             SetEntProp(activator,Prop_Data,"m_iEFlags",38011920);
  230.             SetEntProp(activator,Prop_Data,"m_MoveType",2);
  231.             SetEntProp(activator,Prop_Data,"m_bDrawViewmodel",1);
  232.             float resetvec[3];
  233.             SetEntPropVector(activator,Prop_Data,"m_vecViewOffset",resetvec);
  234.             TeleportEntity(activator,orgs,NULL_VECTOR,NULL_VECTOR);
  235.         }
  236.     }
  237. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top