Advertisement
macquid123560

Top Jailbreak | Ball

Mar 23rd, 2016
3,395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PCRE 32.63 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <cstrike>
  6. #include <fun>
  7. #include <fakemeta_util>
  8.  
  9. #define MAX_NETS 2
  10.  
  11. new g_Trail;
  12.  
  13. new const PLUGIN_NAME[] = "Jailbreak football"
  14. new const PLUGIN_AUTHOR[] = "CreePs & lolz123 & @f0rce"
  15. new const PLUGIN_VERSION[] = "2.0"
  16. new const PLUGIN_PREFIX[] = "Top-Clan"
  17. new const cluster_trail[] = "sprites/Top/flame.spr"
  18.  
  19.  
  20. static const g_szBallBounce[] = "Top/JB/bounce.wav"
  21. static const g_szBallModel[] = "models/Top/JB/kickball/ball.mdl"
  22. static const g_szBallName[] = "ball"
  23.  
  24. enum
  25. {
  26.     FIRST_POINT = 0,
  27.     SECOND_POINT
  28. }
  29.  
  30. new g_szFile[128]
  31. new g_szMapname[32]
  32. new g_buildingstage[33]
  33.  
  34. new gBall
  35. new g_iTrailSprite
  36. new ball_speed
  37. new ball_distance
  38. new countnets = 0
  39.  
  40. new bool:g_bHighlight[33][2]
  41. new bool:g_buildingNet[33]
  42. new bool:g_bNeedBall
  43. new bool:g_bScored
  44.  
  45. new Float:g_vOrigin[3]
  46. new Float:g_fOriginBox[33][2][3]
  47. new Float:g_fLastTouch
  48. new g_OwnerOrigin[3]
  49.  
  50. new g_Owner
  51.  
  52. new g_iMainMenu
  53. new g_iBallMenu
  54. new g_iNetMenu
  55.  
  56. new g_SayText
  57.  
  58. public plugin_init()
  59. {
  60.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  61.    
  62.     ball_speed = register_cvar("jb_ball_speed", "200.0")
  63.     ball_distance = register_cvar("jb_ball_distance", "600")
  64.    
  65.     register_logevent("EventRoundStart", 2, "1=Round_Start")
  66.     register_event("CurWeapon", "CurWeapon", "be")
  67.    
  68.     register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
  69.     register_forward(FM_Touch, "FwdTouch", 0)
  70.    
  71.     RegisterHam(Ham_ObjectCaps, "player", "FwdHamObjectCaps", 1)
  72.    
  73.     register_think(g_szBallName, "FwdThinkBall")
  74.     register_touch(g_szBallName, "player", "FwdTouchPlayer")
  75.     //register_touch(g_szBallName, "JailNet",    "touchNet")
  76.    
  77.     remove_entity_name("func_pushable")
  78.    
  79.     new const szEntity[][] = {
  80.         "worldspawn", "func_wall", "func_door",  "func_door_rotating",
  81.         "func_wall_toggle", "func_breakable", "func_pushable", "func_train",
  82.         "func_illusionary", "func_button", "func_rot_button", "func_rotating"
  83.     }
  84.    
  85.     for(new i; i < sizeof(szEntity); i++)
  86.         register_touch(g_szBallName, szEntity[i], "FwdTouchWorld")
  87.        
  88.     CreateMenus()
  89.    
  90.     register_clcmd("say /ball", "ShowMainMenu")
  91.     register_clcmd("say /reset", "UpdateBall")
  92.    
  93.     g_SayText = get_user_msgid("SayText")
  94. }
  95.  
  96. public CreateMenus()
  97. {
  98.     g_iMainMenu = register_menuid("Soccer Main")
  99.     g_iBallMenu = register_menuid("Soccer Ball")
  100.     g_iNetMenu = register_menuid("Soccer Net")
  101.  
  102.     register_menucmd(g_iMainMenu, 1023, "HandleMainMenu")
  103.     register_menucmd(g_iBallMenu, 1023, "HandleBallMenu")
  104.     register_menucmd(g_iNetMenu, 1023, "HandleNetMenu")
  105. }
  106.  
  107. public ShowMainMenu(id)
  108. {
  109.     new szBuffer[512], iLen
  110.     new col[3], col2[3]
  111.    
  112.     col =  get_user_flags(id) & ADMIN_RCON ? "\r" : "\d"
  113.     col2 =  get_user_flags(id) & ADMIN_RCON ? "\w" : "\d"
  114.    
  115.     iLen = formatex(szBuffer, sizeof szBuffer - 1, "\r[\y%s`\r] \wJail Football^n^n", PLUGIN_PREFIX)
  116.    
  117.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "\r1. \wBall Menu^n")
  118.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "\r2. \wNet Menu^n^n")
  119.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s3. %sLoad All^n", col, col2)
  120.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s4. %sDelete All^n", col, col2)
  121.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s5. %sSave All^n^n^n^n", col, col2)
  122.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "\r0. \yExit", col, col2)
  123.    
  124.     new iKeys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<9 )
  125.     show_menu(id, iKeys, szBuffer, -1, "Soccer Main")
  126. }
  127.  
  128. public ShowBallMenu(id)
  129. {
  130.     new szBuffer[512], iLen
  131.     new col[3], col2[3]
  132.    
  133.     col =  get_user_flags(id) & ADMIN_RCON ? "\r" : "\d"
  134.     col2 =  get_user_flags(id) & ADMIN_RCON ? "\w" : "\d"
  135.    
  136.     iLen = formatex(szBuffer, sizeof szBuffer - 1, "\r[\y%s`\r] \wJail Ball^n^n", PLUGIN_PREFIX)
  137.    
  138.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s1. %sCreate Ball^n", col, col2)
  139.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s2. %sHighlight Ball^n", col, col2)
  140.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s3. %sDelete Ball^n^n^n^n^n^n^n", col, col2)
  141.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "\r0. \yBack")
  142.    
  143.     new iKeys = ( 1<<0 | 1<<1 | 1<<2 | 1<<9 )
  144.     show_menu(id, iKeys, szBuffer, -1, "Soccer Ball")
  145. }
  146.  
  147. public ShowNetMenu(id)
  148. {
  149.     new szBuffer[512], iLen
  150.     new col[3], col2[3]
  151.  
  152.     col =  get_user_flags(id) & ADMIN_RCON ? "\r" : "\d"
  153.     col2 =  get_user_flags(id) & ADMIN_RCON ? "\w" : "\d"
  154.    
  155.     iLen = formatex(szBuffer, sizeof szBuffer - 1, "\r[\y%s`\r] \wJail Net^n^n", PLUGIN_PREFIX)
  156.    
  157.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s1. %sCreate Net^n", col, col2)
  158.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s2. %sHighlight Net^n", col, col2)
  159.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s3. %sDelete Net^n^n", col, col2)
  160.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%s4. %sNet Move^n^n^n^n^n", col, col2)
  161.     iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "\r0. \yBack")
  162.    
  163.     new iKeys = ( 1<<0 | 1<<1 | 1<<2 | 1<<9 )
  164.     show_menu(id, iKeys, szBuffer, -1, "Soccer Net")
  165. }
  166. public PlayerPreThink(id)
  167. {
  168.     if(!is_user_alive(id))
  169.         return PLUGIN_CONTINUE
  170.    
  171.     if(pev(id, pev_button) & IN_USE && !(pev(id, pev_oldbuttons) & IN_USE) && g_buildingNet[id]) {
  172.         new Float:fOrigin[3], fOriginn[3]
  173.         get_user_origin(id, fOriginn, 3)
  174.    
  175.         IVecFVec(fOriginn, fOrigin)
  176.         if(g_buildingstage[id] == FIRST_POINT)
  177.         {
  178.             g_buildingstage[id] = SECOND_POINT
  179.            
  180.             g_fOriginBox[id][FIRST_POINT] = fOrigin
  181.            
  182.             ColorChat(id, "Now set the origin for the bottom left corner of the box.")
  183.         }
  184.         else
  185.         {
  186.             g_buildingstage[id] = FIRST_POINT
  187.             g_buildingNet[id] = false
  188.            
  189.             g_fOriginBox[id][SECOND_POINT] = fOrigin
  190.            
  191.             CreateNet(g_fOriginBox[id][FIRST_POINT], g_fOriginBox[id][SECOND_POINT])
  192.            
  193.             ColorChat(id, "Successfully created net #%d", ++countnets)
  194.         }
  195.     }
  196.     if(is_valid_ent(gBall)) {
  197.         static iOwner
  198.        
  199.         iOwner = pev(gBall, pev_iuser1)
  200.        
  201.         if(iOwner != id)
  202.             ResetMaxspeed(id)
  203.     }
  204.    
  205.     return PLUGIN_HANDLED
  206. }
  207.  
  208. public CurWeapon(id)
  209. {
  210.     if(!is_user_alive(id))
  211.         return PLUGIN_CONTINUE
  212.     if(is_valid_ent(gBall)) {
  213.         static iOwner
  214.        
  215.         iOwner = pev(gBall, pev_iuser1)
  216.  
  217.         if(iOwner == id)
  218.             entity_set_float(id, EV_FL_maxspeed, get_pcvar_float(ball_speed))
  219.     }
  220.    
  221.     return PLUGIN_HANDLED
  222. }
  223.  
  224. public UpdateBall(id)
  225. {
  226.     if(!id ||  get_user_flags(id) & ADMIN_KICK)
  227.     {
  228.         if(is_valid_ent(gBall))
  229.         {
  230.             entity_set_vector(gBall, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 })
  231.             entity_set_origin(gBall, g_vOrigin)
  232.            
  233.             entity_set_int(gBall, EV_INT_movetype, MOVETYPE_BOUNCE)
  234.             entity_set_size(gBall, Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 })
  235.             entity_set_int(gBall, EV_INT_iuser1, 0)
  236.         }
  237.     }
  238.    
  239.     return PLUGIN_HANDLED
  240. }
  241.  
  242. public MoveBall(where)
  243. {
  244.     if(!is_valid_ent(gBall))
  245.         return PLUGIN_HANDLED
  246.    
  247.     switch(where)
  248.     {
  249.         case 0:
  250.         {
  251.             new Float:orig[3]
  252.    
  253.             for(new x=0;x<3;x++)
  254.                 orig[x] = -9999.9
  255.             entity_set_origin(gBall,orig)
  256.         }
  257.         case 1:
  258.         {
  259.             if(is_valid_ent(gBall)) {
  260.                 new vOrigin[3]
  261.                
  262.                 entity_set_vector(gBall, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 })
  263.                 entity_set_origin(gBall, g_vOrigin )
  264.                
  265.                 entity_set_int(gBall, EV_INT_movetype, MOVETYPE_BOUNCE)
  266.                 entity_set_size(gBall, Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 })
  267.                 entity_set_int(gBall, EV_INT_iuser1, 0)
  268.                 g_bScored = false
  269.                
  270.                 FVecIVec(g_vOrigin, vOrigin)
  271.                 flameWave(vOrigin, 0, 255, 0, 15)
  272.             }
  273.         }
  274.     }
  275.     return PLUGIN_HANDLED
  276. }
  277.  
  278. public plugin_precache()
  279. {
  280.     precache_model(g_szBallModel)
  281.     precache_sound(g_szBallBounce)
  282.    
  283.     g_Trail     = precache_model(cluster_trail)
  284.     precache_sound( "Top/JB/goal.wav" );
  285.    
  286.     get_mapname(g_szMapname, 31)
  287.     strtolower(g_szMapname )
  288.    
  289.     new szDatadir[64]
  290.     get_localinfo("amxx_datadir", szDatadir, charsmax(szDatadir))
  291.    
  292.     formatex(szDatadir, charsmax( szDatadir ), "%s", szDatadir)
  293.    
  294.     if(!dir_exists( szDatadir))
  295.         mkdir(szDatadir)
  296.    
  297.     formatex(g_szFile, charsmax(g_szFile), "%s/ball.ini", szDatadir)
  298.    
  299.     if(!file_exists(g_szFile))
  300.     {
  301.         write_file(g_szFile, "// Soccerjam Ball/Nets Spawn Editor", -1)
  302.         write_file(g_szFile, "// Credits to us ", -1)
  303.        
  304.         return
  305.     }
  306.    
  307.     LoadAll(0)
  308. }
  309.  
  310. public LoadAll(id)
  311. {
  312.     new szData[512]
  313.     new szMap[32]
  314.     new szOrigin[3][16]
  315.     new szfPoint[2][3][16], szlPoint[2][3][16]
  316.     new iFile = fopen(g_szFile, "rt")
  317.    
  318.     while(!feof(iFile))
  319.     {
  320.         fgets(iFile, szData, charsmax(szData))
  321.        
  322.         if(!szData[0] || szData[0] == ';' || szData[0] == ' ' || ( szData[0] == '/' && szData[1] == '/' ))
  323.             continue
  324.  
  325.         parse(szData, szMap, 31, szOrigin[0], 15, szOrigin[1], 15, szOrigin[2], 15,\
  326.             szfPoint[0][0], 15, szfPoint[0][1], 15, szfPoint[0][2], 15,\
  327.             szlPoint[0][0], 15, szlPoint[0][1], 15, szlPoint[0][2], 15,\
  328.             szfPoint[1][0], 15, szfPoint[1][1], 15, szfPoint[1][2], 15,\
  329.             szlPoint[1][0], 15, szlPoint[1][1], 15, szlPoint[1][2], 15)
  330.        
  331.         if(equal(szMap, g_szMapname))
  332.         {
  333.             new Float:vOrigin[3]
  334.             new Float:fPoint[2][3]
  335.             new Float:lPoint[2][3]
  336.            
  337.             vOrigin[0] = str_to_float(szOrigin[0])
  338.             vOrigin[1] = str_to_float(szOrigin[1])
  339.             vOrigin[2] = str_to_float(szOrigin[2])
  340.            
  341.             for(new i = 0; i < 2; i++)
  342.             {
  343.                 for(new j = 0; j < 3; j++)
  344.                 {
  345.                     fPoint[i][j] = str_to_float(szfPoint[i][j])
  346.                     lPoint[i][j] = str_to_float(szlPoint[i][j])
  347.                 }
  348.             }
  349.            
  350.             CreateBall(0, vOrigin)
  351.            
  352.             CreateNet(fPoint[0], lPoint[0])
  353.             CreateNet(fPoint[1], lPoint[1])
  354.            
  355.             g_vOrigin = vOrigin
  356.             countnets = 2
  357.            
  358.             break
  359.         }
  360.     }
  361.    
  362.     fclose(iFile)
  363. }
  364.  
  365. public SaveAll(id)
  366. {
  367.     new iBall, iNets[2], ent, i
  368.     new Float:vOrigin[3]
  369.     new Float:fMaxs[3]
  370.     new Float:fOrigin[3]
  371.     new Float:vfPoint[2][3]
  372.     new Float:vlPoint[2][3]
  373.    
  374.     while((ent = find_ent_by_class(ent, g_szBallName)) > 0)
  375.         iBall = ent
  376.          
  377.     while((ent = find_ent_by_class(ent, "JailNet")) > 0)
  378.         iNets[i++] = ent
  379.        
  380.     if(iBall > 0 && iNets[0] > 0 && iNets[1] > 0 && countnets == 2)
  381.     {
  382.         entity_get_vector(iBall, EV_VEC_origin, vOrigin)
  383.        
  384.         for(new i = 0; i < 2; i++)
  385.         {
  386.             entity_get_vector(iNets[i], EV_VEC_origin, fOrigin)
  387.             entity_get_vector(iNets[i], EV_VEC_maxs, fMaxs)
  388.            
  389.             for(new j = 0; j < 3; j++)
  390.             {
  391.                 vfPoint[i][j] = fOrigin[j] + fMaxs[j]
  392.                 vlPoint[i][j] = fOrigin[j] - fMaxs[j]
  393.             }
  394.         }
  395.     }
  396.     else
  397.         return PLUGIN_HANDLED
  398.        
  399.     new bool:bFound, iPos, szData[32], iFile = fopen(g_szFile, "r+")
  400.            
  401.     if(!iFile)
  402.         return PLUGIN_HANDLED
  403.            
  404.     while(!feof(iFile)) {
  405.         fgets(iFile, szData, 31)
  406.         parse(szData, szData, 31)
  407.                
  408.         iPos++
  409.                
  410.         if(equal(szData, g_szMapname)) {
  411.             bFound = true
  412.                    
  413.             new szString[512]
  414.             formatex(szString, 511, "%s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f", g_szMapname, vOrigin[0], vOrigin[1], vOrigin[2],\
  415.                 vfPoint[0][0], vfPoint[0][1], vfPoint[0][2], vlPoint[0][0], vlPoint[0][1], vlPoint[0][2],\
  416.                 vfPoint[1][0], vfPoint[1][1], vfPoint[1][2], vlPoint[1][0], vlPoint[1][1], vlPoint[1][2])
  417.                    
  418.             write_file(g_szFile, szString, iPos - 1)
  419.                    
  420.             break
  421.         }
  422.     }
  423.            
  424.     if(!bFound)
  425.         fprintf(iFile, "%s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f^n", g_szMapname, vOrigin[0], vOrigin[1], vOrigin[2],\
  426.             vfPoint[0][0], vfPoint[0][1], vfPoint[0][2], vlPoint[0][0], vlPoint[0][1], vlPoint[0][2],\
  427.             vfPoint[1][0], vfPoint[1][1], vfPoint[1][2], vlPoint[1][0], vlPoint[1][1], vlPoint[1][2])
  428.     fclose(iFile)
  429.            
  430.     ColorChat(id, "Successfully saved ball & nets!")
  431.    
  432.     return PLUGIN_HANDLED
  433. }
  434.  
  435. public HandleMainMenu(id, key)
  436. {
  437.     if((key == 2 || key == 3 || key == 4) && !( get_user_flags(id) & ADMIN_RCON)) {
  438.         ShowMainMenu(id)
  439.         return PLUGIN_HANDLED
  440.     }
  441.    
  442.     switch(key)
  443.     {
  444.         case 0:
  445.         {
  446.             ShowBallMenu(id)
  447.             return PLUGIN_HANDLED
  448.  
  449.         }
  450.         case 1:
  451.         {
  452.             ShowNetMenu(id)
  453.             return PLUGIN_HANDLED
  454.         }
  455.         case 2:
  456.         {
  457.             if(is_valid_ent(gBall)) {
  458.                 entity_set_vector(gBall, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 })
  459.                 entity_set_origin(gBall, g_vOrigin )
  460.                
  461.                 entity_set_int(gBall, EV_INT_movetype, MOVETYPE_BOUNCE)
  462.                 entity_set_size(gBall, Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 })
  463.                 entity_set_int(gBall, EV_INT_iuser1, 0)
  464.                
  465.                 ColorChat(id, "Successfully loaded entity!")
  466.             }
  467.         }
  468.         case 3:
  469.         {
  470.             new ent
  471.             new ball, net
  472.             while((ent = find_ent_by_class(ent, g_szBallName)) > 0)
  473.             {
  474.                 remove_entity(ent)
  475.                 ball++
  476.             }
  477.                
  478.             while((ent = find_ent_by_class(ent, "JailNet")) > 0)
  479.             {
  480.                 remove_entity(ent)
  481.                 countnets--
  482.                 net++
  483.             }
  484.                
  485.             ColorChat(id, "Successfully removed^x03 %d^x01 ball and^x03 %d^x01 nets", ball, net)
  486.         }
  487.         case 4: SaveAll(id)
  488.         case 9: return PLUGIN_HANDLED
  489.     }
  490.    
  491.     ShowMainMenu(id)
  492.  
  493.     return PLUGIN_HANDLED
  494. }
  495.  
  496. public HandleBallMenu(id, key)
  497. {
  498.     if(key != 9 && !( get_user_flags(id) & ADMIN_RCON)) {
  499.         ShowBallMenu(id)
  500.         return PLUGIN_HANDLED
  501.     }
  502.    
  503.     switch(key)
  504.     {
  505.         case 0:
  506.         {
  507.             if(pev_valid(gBall))
  508.                 return PLUGIN_CONTINUE
  509.                
  510.             new ball
  511.             ball = CreateBall(id)
  512.            
  513.             if(pev_valid(ball))
  514.                 ColorChat(id, "Successfully created ball!")
  515.             else
  516.                 ColorChat(id, "Failled to create ball!")
  517.         }
  518.         case 1:
  519.         {
  520.             if(!g_bHighlight[id][1])
  521.             {
  522.                 set_rendering(gBall, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 255)
  523.                 entity_set_float(gBall, EV_FL_renderamt, 1.0)
  524.                
  525.                 g_bHighlight[id][1] = true
  526.                
  527.                 ColorChat(id, "Ball highlight has been^x04 Enabled^x01.")
  528.             } else {
  529.                 set_rendering(gBall, kRenderFxNone, 0, 0, 255, kRenderNormal, 255)
  530.                 entity_set_float(gBall, EV_FL_renderamt, 1.0)
  531.                
  532.                 g_bHighlight[id][1] = false
  533.                
  534.                 ColorChat(id, "Ball highlight has been^x03 Disabled^x01.")
  535.             }
  536.         }
  537.         case 2:
  538.         {
  539.             new ent
  540.             new bool:bFound
  541.             while((ent = find_ent_by_class(ent, g_szBallName)) > 0)
  542.             {
  543.                 remove_entity(ent)
  544.                 bFound = true
  545.             }
  546.             if(bFound)
  547.                 ColorChat(id, "Successfully removed ball!")
  548.             else
  549.                 ColorChat(id, "No ball was found to remove")
  550.         }
  551.         case 9:
  552.         {
  553.             ShowMainMenu(id)
  554.             return PLUGIN_HANDLED
  555.         }
  556.     }
  557.    
  558.     ShowBallMenu(id)
  559.     return PLUGIN_HANDLED
  560. }
  561.  
  562. public HandleNetMenu(id, key)
  563. {
  564.     if(key != 9 && !( get_user_flags(id) & ADMIN_RCON)) {
  565.         ShowNetMenu(id)
  566.         return PLUGIN_HANDLED
  567.     }
  568.    
  569.     switch(key)
  570.     {
  571.         case 0:
  572.         {
  573.             if(g_buildingNet[id])
  574.             {
  575.                 ColorChat(id, "Already in building net mod.")
  576.                 ShowNetMenu(id)
  577.                
  578.                 return PLUGIN_HANDLED
  579.             }
  580.             if(countnets >= MAX_NETS)
  581.             {
  582.                 ColorChat(id, "Sorry, limit of nets reached (%d).", countnets)
  583.                 ShowNetMenu(id)
  584.                
  585.                 return PLUGIN_HANDLED
  586.             }
  587.            
  588.             g_buildingNet[id] = true
  589.            
  590.             ColorChat(id, "Set the origin for the top right corner of the box.")
  591.         }
  592.         case 1:
  593.         {
  594.             if(!g_bHighlight[id][0])
  595.             {
  596.                 set_task(1.0, "taskShowNet", 1000 + id, "", 0, "b", 0)
  597.                 g_bHighlight[id][0] = true
  598.                
  599.                 ColorChat(id, "Net highlight has been^x04 Enabled^x01.")
  600.             } else {
  601.                 remove_task(1000+id)
  602.                 g_bHighlight[id][0] = false
  603.                
  604.                 ColorChat(id, "Net highlight has been^x03 Disabled^x01.")
  605.             }
  606.         }
  607.         case 2:
  608.         {
  609.             new ent, body
  610.             new bool:bFound
  611.             static classname[32]
  612.        
  613.             get_user_aiming(id, ent, body, 9999)
  614.             entity_get_string(ent, EV_SZ_classname, classname, charsmax(classname))
  615.            
  616.             if(is_valid_ent(ent) && equal(classname, "JailNet"))
  617.             {
  618.                 remove_entity(ent)
  619.                 countnets--
  620.                    
  621.                 bFound = true
  622.             } else {
  623.                 new Float:fPlrOrigin[3], Float:fNearestDist = 9999.0, iNearestEnt
  624.                 new Float:fOrigin[3], Float:fCurDist
  625.    
  626.                 pev(id, pev_origin, fPlrOrigin)
  627.    
  628.                 new ent = -1
  629.                 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "JailNet")) != 0)
  630.                 {
  631.                     pev(ent, pev_origin, fOrigin)
  632.        
  633.                     fCurDist = vector_distance(fPlrOrigin, fOrigin)
  634.        
  635.                     if(fCurDist < fNearestDist)
  636.                     {
  637.                         iNearestEnt = ent
  638.                         fNearestDist = fCurDist
  639.                     }
  640.                 }
  641.                 if(iNearestEnt > 0 && is_valid_ent(iNearestEnt))
  642.                 {
  643.                     remove_entity(iNearestEnt)
  644.                     countnets--
  645.                 }
  646.                
  647.                 bFound = true
  648.             }
  649.             if(bFound)
  650.                 ColorChat(id, "Successfully removed net!")
  651.             else
  652.                 ColorChat(id, "No net was found to remove")
  653.         }
  654.         case 9:
  655.         {
  656.             ShowMainMenu(id)
  657.             return PLUGIN_HANDLED
  658.         }
  659.     }
  660.    
  661.     ShowNetMenu(id)
  662.     return PLUGIN_HANDLED
  663. }
  664.        
  665. public EventRoundStart()
  666. {
  667.     if(!g_bNeedBall)
  668.     return
  669.    
  670.     if(!is_valid_ent(gBall))
  671.         CreateBall(0, g_vOrigin)
  672.     else {
  673.         entity_set_vector(gBall, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 })
  674.         entity_set_origin(gBall, g_vOrigin)
  675.        
  676.         entity_set_int(gBall, EV_INT_solid, SOLID_BBOX)
  677.         entity_set_int(gBall, EV_INT_movetype, MOVETYPE_BOUNCE)
  678.         entity_set_size(gBall, Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 })
  679.         entity_set_int(gBall, EV_INT_iuser1, 0)
  680.     }
  681. }
  682.  
  683. public FwdHamObjectCaps(id)
  684. {
  685.     if(pev_valid(gBall) && is_user_alive(id)) {
  686.         static iOwner
  687.        
  688.         iOwner = pev(gBall, pev_iuser1)
  689.        
  690.         if(iOwner == id)
  691.         {
  692.             KickBall(id)
  693.             g_Owner = iOwner
  694.        
  695.             get_user_origin(id, g_OwnerOrigin)
  696.         }
  697.     }
  698. }
  699.  
  700. public FwdThinkBall(ent,sprite,life,size,R,G,B,F) {
  701.     if(!is_valid_ent(gBall))
  702.         return PLUGIN_HANDLED
  703.    
  704.     static Float:vOrigin[3], Float:vBallVelocity[3]
  705.    
  706.     entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.05)
  707.     entity_get_vector(ent, EV_VEC_origin, vOrigin)
  708.     entity_get_vector(ent, EV_VEC_velocity, vBallVelocity)
  709.    
  710.     static iOwner
  711.     static iSolid
  712.    
  713.     iSolid = pev(ent, pev_solid)
  714.     iOwner = pev(ent, pev_iuser1)
  715.    
  716.     static Float:flGametime, Float:flLastThink
  717.     flGametime = get_gametime()
  718.    
  719.     if(flLastThink < flGametime) {
  720.         if(floatround(vector_length(vBallVelocity)) > 10)
  721.         {
  722.         Trail(ent,g_Trail,12,8,255,155,55,255)
  723.  
  724.         }
  725.        
  726.         flLastThink = flGametime + 3.0
  727.     }
  728.    
  729.     if(iOwner > 0)
  730.     {
  731.         static Float:vOwnerOrigin[3]
  732.         static const Float:vVelocity[3] = { 1.0, 1.0, 0.0 }
  733.         entity_get_vector( iOwner, EV_VEC_origin, vOwnerOrigin )
  734.        
  735.         if(!is_user_alive(iOwner))
  736.         {
  737.             vOwnerOrigin[ 2 ] += 5.0
  738.            
  739.             entity_set_int(ent, EV_INT_iuser1, 0)
  740.             entity_set_origin(ent, vOwnerOrigin)
  741.             entity_set_vector(ent, EV_VEC_velocity, vVelocity)
  742.            
  743.             return PLUGIN_CONTINUE
  744.         }
  745.        
  746.         if(iSolid != SOLID_NOT)
  747.         {
  748.             set_pev(ent, pev_solid, SOLID_NOT)
  749.             set_hudmessage(255, 20, 20, -1.0, 0.4, 1, 1.0, 1.5, 0.1, 0.1, 2)
  750.             show_hudmessage(iOwner, "** YOU HAVE THE BALL! **")
  751.         }
  752.        
  753.         static Float:vAngles[3], Float:vReturn[3]
  754.         entity_get_vector( iOwner, EV_VEC_v_angle, vAngles )
  755.        
  756.         vReturn[0] = (floatcos(vAngles[1], degrees) * 55.0) + vOwnerOrigin[0]
  757.         vReturn[1] = (floatsin(vAngles[1], degrees) * 55.0) + vOwnerOrigin[1]
  758.         vReturn[2] = vOwnerOrigin[2]
  759.         vReturn[2] -= (entity_get_int(iOwner, EV_INT_flags) & FL_DUCKING) ? 10 : 30
  760.        
  761.         entity_set_vector(ent, EV_VEC_velocity, vVelocity)
  762.         entity_set_origin(ent, vReturn)
  763.     } else {
  764.         if(iSolid != SOLID_BBOX )
  765.             set_pev(ent, pev_solid, SOLID_BBOX)
  766.        
  767.         static Float:flLastVerticalOrigin
  768.        
  769.         if(vBallVelocity[2] == 0.0)
  770.         {
  771.             static iCounts
  772.            
  773.             if(flLastVerticalOrigin > vOrigin[2])
  774.             {
  775.                 iCounts++
  776.                
  777.                 if( iCounts > 10 && !g_bScored)
  778.                 {
  779.                     iCounts = 0
  780.                     UpdateBall(0)
  781.                 }
  782.             } else {
  783.                 iCounts = 0
  784.                
  785.                 if(PointContents(vOrigin) != CONTENTS_EMPTY && !g_bScored)
  786.                     UpdateBall(0)
  787.             }
  788.            
  789.             flLastVerticalOrigin = vOrigin[2]
  790.         }
  791.     }
  792.    
  793.     return PLUGIN_CONTINUE
  794. }
  795.  
  796. KickBall(id)
  797. {
  798.     ResetMaxspeed(id)
  799.     static Float:vOrigin[3]
  800.     entity_get_vector(gBall, EV_VEC_origin, vOrigin)
  801.    
  802.     if(PointContents(vOrigin) != CONTENTS_EMPTY)
  803.         return PLUGIN_HANDLED
  804.  
  805.     new Float:vVelocity[3]
  806.     velocity_by_aim( id, get_pcvar_num(ball_distance), vVelocity)
  807.        
  808.     set_pev(gBall, pev_solid, SOLID_BBOX)
  809.     entity_set_size(gBall, Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 })
  810.     entity_set_int(gBall, EV_INT_iuser1, 0)
  811.     entity_set_vector(gBall, EV_VEC_velocity, vVelocity)
  812.        
  813.     return PLUGIN_CONTINUE
  814. }
  815.  
  816. public Goal()
  817. {
  818.     new name[32], fdistance
  819.     new Float:fOrigin[3]
  820.     entity_get_vector(gBall, EV_VEC_origin,fOrigin)
  821.     new Origin[3]
  822.    
  823.     FVecIVec(fOrigin, Origin)
  824.    
  825.     get_user_name(g_Owner, name,31)
  826.     fdistance = get_distance(Origin, g_OwnerOrigin)
  827.     set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), -1.0, -1.0, 0, 6.0, 6.0)
  828.    
  829.     if(g_Owner != 0)
  830.         show_hudmessage(0, "%s^nScored A Goal^n[%i Units]", name, fdistance)
  831.     client_cmd( 0, "spk ^"sound/Top/JB/goal.wav^"" );  
  832.    
  833.     flameWave(Origin, 0, 0, 255, 4)
  834.    
  835.     g_bScored = true
  836.    
  837.     MoveBall(0)
  838.    
  839.     set_task(5.0, "MoveBall", 1)
  840. }
  841.    
  842. public FwdTouchPlayer(Ball, id, ent)
  843. {
  844.     if(is_user_bot(id))
  845.         return PLUGIN_CONTINUE
  846.    
  847.     static iOwner
  848.    
  849.     iOwner = pev(Ball, pev_iuser1)
  850.    
  851.     if( iOwner == 0 )
  852.     {
  853.         entity_set_int(Ball, EV_INT_iuser1, id)
  854.         entity_set_float(id, EV_FL_maxspeed, get_pcvar_float(ball_speed))
  855.    
  856.     }
  857.    
  858.     return PLUGIN_CONTINUE
  859. }
  860.  
  861. public FwdTouchWorld(Ball, World, ent)
  862. {
  863.     static Float:vVelocity[3]
  864.     entity_get_vector(Ball, EV_VEC_velocity, vVelocity)
  865.    
  866.     if(floatround(vector_length(vVelocity)) > 10)
  867.     {
  868.         vVelocity[0] *= 0.85
  869.         vVelocity[1] *= 0.85
  870.         vVelocity[2] *= 0.85
  871.        
  872.         entity_set_vector(Ball, EV_VEC_velocity, vVelocity)
  873.         emit_sound(Ball, CHAN_ITEM, g_szBallBounce, 1.0, ATTN_NORM, 0, PITCH_NORM)
  874.     }
  875.  
  876.     return PLUGIN_CONTINUE
  877. }
  878.  
  879. public FwdTouch(ent, id)
  880. {
  881.     static szNameEnt[32], szNameId[32]
  882.     pev(ent, pev_classname, szNameEnt, sizeof szNameEnt - 1)
  883.     pev(id, pev_classname, szNameId, sizeof szNameId - 1)
  884.  
  885.    
  886.     static Float:fGameTime
  887.     fGameTime = get_gametime()
  888.    
  889.     if(equal(szNameEnt, "JailNet") && equal(szNameId, g_szBallName) && (fGameTime - g_fLastTouch) > 0.1)
  890.     {
  891.         Goal()
  892.         g_fLastTouch = fGameTime
  893.     }
  894. }
  895.  
  896.  
  897. CreateBall(id, Float:vOrigin[ 3 ] = { 0.0, 0.0, 0.0 })
  898. {  
  899.     if(!id && vOrigin[0] == 0.0 && vOrigin[1] == 0.0 && vOrigin[2] == 0.0)
  900.         return 0
  901.    
  902.     g_bNeedBall = true
  903.    
  904.     gBall = create_entity("info_target")
  905.    
  906.     if(is_valid_ent(gBall))
  907.     {          
  908.         entity_set_string(gBall, EV_SZ_classname, g_szBallName)
  909.    
  910.         entity_set_int(gBall, EV_INT_solid, SOLID_BBOX)
  911.         entity_set_int(gBall, EV_INT_movetype, MOVETYPE_BOUNCE)
  912.         entity_set_model(gBall, g_szBallModel)
  913.  
  914.         entity_set_size(gBall, Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 })
  915.        
  916.         entity_set_float(gBall, EV_FL_framerate, 0.0)
  917.         entity_set_int(gBall, EV_INT_sequence, 0)
  918.        
  919.         entity_set_float(gBall, EV_FL_nextthink, get_gametime() + 0.05)
  920.    
  921.    
  922.        
  923.         if(id > 0) {
  924.             new iOrigin[3]
  925.             get_user_origin(id, iOrigin, 3)
  926.             IVecFVec(iOrigin, vOrigin)
  927.        
  928.             vOrigin[2] += 5.0
  929.            
  930.             entity_set_origin(gBall, vOrigin)
  931.         } else
  932.             entity_set_origin(gBall, vOrigin)
  933.        
  934.         g_vOrigin = vOrigin
  935.        
  936.         return gBall
  937.     }
  938.    
  939.     return -1
  940. }
  941.  
  942. CreateNet(Float:firstPoint[3], Float:lastPoint[3])
  943. {
  944.     new ent
  945.     new Float:fCenter[3], Float:fSize[3]
  946.     new Float:fMins[3], Float:fMaxs[3]
  947.        
  948.     for ( new i = 0; i < 3; i++ )
  949.     {
  950.         fCenter[i] = (firstPoint[i] + lastPoint[i]) / 2.0
  951.                
  952.         fSize[i] = get_float_difference(firstPoint[i], lastPoint[i])
  953.                
  954.         fMins[i] = fSize[i] / -2.0
  955.         fMaxs[i] = fSize[i] / 2.0
  956.     }
  957.    
  958.     ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  959.    
  960.     if (ent) {
  961.         engfunc(EngFunc_SetOrigin, ent, fCenter)
  962.        
  963.         set_pev(ent, pev_classname, "JailNet")
  964.    
  965.         dllfunc(DLLFunc_Spawn, ent)
  966.    
  967.         set_pev(ent, pev_movetype, MOVETYPE_FLY)
  968.         set_pev(ent, pev_solid, SOLID_TRIGGER)
  969.    
  970.         engfunc(EngFunc_SetSize, ent, fMins, fMaxs)
  971.     }
  972. }
  973.  
  974. ResetMaxspeed(id)
  975. {
  976.     static Float:max_speed
  977.     switch ( get_user_weapon(id) )
  978.     {
  979.         case CSW_SG550, CSW_AWP, CSW_G3SG1:        max_speed = 210.0
  980.         case CSW_M249:                    max_speed = 220.0
  981.         case CSW_AK47:                    max_speed = 221.0
  982.         case CSW_M3, CSW_M4A1:                max_speed = 230.0
  983.         case CSW_SG552:                    max_speed = 235.0
  984.         case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS:    max_speed = 240.0
  985.         case CSW_P90:                    max_speed = 245.0
  986.         case CSW_SCOUT:                    max_speed = 260.0
  987.         default:                    max_speed = 250.0
  988.     }
  989.    
  990.     entity_set_float(id, EV_FL_maxspeed, max_speed)
  991. }
  992.  
  993. public sqrt(num)
  994. {        
  995.     new div = num
  996.     new result = 1
  997.    
  998.     while (div > result)
  999.     {
  1000.         div = (div + result) / 2
  1001.         result = num / div
  1002.     }
  1003.    
  1004.     return div
  1005. }
  1006.  
  1007. stock Float:get_float_difference(Float:num1, Float:num2)
  1008. {
  1009.     if(num1 > num2)
  1010.         return (num1-num2)
  1011.     else if(num2 > num1)
  1012.         return (num2-num1)
  1013.    
  1014.     return 0.0
  1015. }
  1016.  
  1017. stock Trail(ent,sprite,life,size,R,G,B,F)
  1018. {
  1019.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1020.         write_byte(TE_BEAMFOLLOW)
  1021.         write_short(ent)
  1022.         write_short(sprite)
  1023.         write_byte(life)
  1024.         write_byte(size)
  1025.         write_byte(R)
  1026.         write_byte(G)
  1027.         write_byte(B)
  1028.         write_byte(F)
  1029.         message_end()
  1030. }
  1031.  
  1032. public taskShowNet(id)
  1033. {
  1034.     id -= 1000
  1035.    
  1036.     if(!is_user_connected(id))
  1037.     {
  1038.         remove_task(1000 + id)
  1039.         return
  1040.     }
  1041.    
  1042.     new ent
  1043.     new Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3]
  1044.     new vMaxs[3], vMins[3]
  1045.     new iColor[3] = { 255, 0, 0 }
  1046.    
  1047.     while((ent = find_ent_by_class(ent, "JailNet")) > 0)
  1048.     {
  1049.         pev(ent, pev_mins, fMins)
  1050.         pev(ent, pev_maxs, fMaxs)
  1051.         pev(ent, pev_origin, fOrigin)
  1052.    
  1053.         fMins[0] += fOrigin[0]
  1054.         fMins[1] += fOrigin[1]
  1055.         fMins[2] += fOrigin[2]
  1056.         fMaxs[0] += fOrigin[0]
  1057.         fMaxs[1] += fOrigin[1]
  1058.         fMaxs[2] += fOrigin[2]
  1059.        
  1060.         FVecIVec(fMins, vMins)
  1061.         FVecIVec(fMaxs, vMaxs)
  1062.  
  1063.         fm_draw_line(id, vMaxs[0], vMaxs[1], vMaxs[2], vMins[0], vMaxs[1], vMaxs[2], iColor)
  1064.         fm_draw_line(id, vMaxs[0], vMaxs[1], vMaxs[2], vMaxs[0], vMins[1], vMaxs[2], iColor)
  1065.         fm_draw_line(id, vMaxs[0], vMaxs[1], vMaxs[2], vMaxs[0], vMaxs[1], vMins[2], iColor)
  1066.         fm_draw_line(id, vMins[0], vMins[1], vMins[2], vMaxs[0], vMins[1], vMins[2], iColor)
  1067.         fm_draw_line(id, vMins[0], vMins[1], vMins[2], vMins[0], vMaxs[1], vMins[2], iColor)
  1068.         fm_draw_line(id, vMins[0], vMins[1], vMins[2], vMins[0], vMins[1], vMaxs[2], iColor)
  1069.         fm_draw_line(id, vMins[0], vMaxs[1], vMaxs[2], vMins[0], vMaxs[1], vMins[2], iColor)
  1070.         fm_draw_line(id, vMins[0], vMaxs[1], vMins[2], vMaxs[0], vMaxs[1], vMins[2], iColor)
  1071.         fm_draw_line(id, vMaxs[0], vMaxs[1], vMins[2], vMaxs[0], vMins[1], vMins[2], iColor)
  1072.         fm_draw_line(id, vMaxs[0], vMins[1], vMins[2], vMaxs[0], vMins[1], vMaxs[2], iColor)
  1073.         fm_draw_line(id, vMaxs[0], vMins[1], vMaxs[2], vMins[0], vMins[1], vMaxs[2], iColor)
  1074.         fm_draw_line(id, vMins[0], vMins[1], vMaxs[2], vMins[0], vMaxs[1], vMaxs[2], iColor)
  1075.     }
  1076. }
  1077.  
  1078. public flameWave(Origin[3], r, g, b, speed)
  1079. {
  1080.  
  1081. }
  1082. stock fm_draw_line(id, x1, y1, z1, x2, y2, z2, g_iColor[3])
  1083. {
  1084.     message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, SVC_TEMPENTITY, _, id ? id : 0)
  1085.    
  1086.     write_byte(TE_BEAMPOINTS)
  1087.    
  1088.     write_coord(x1)
  1089.     write_coord(y1)
  1090.     write_coord(z1)
  1091.    
  1092.     write_coord(x2)
  1093.     write_coord(y2)
  1094.     write_coord(z2)
  1095.    
  1096.     write_short(g_iTrailSprite)
  1097.     write_byte(1)
  1098.     write_byte(1)
  1099.     write_byte(10)
  1100.     write_byte(5)
  1101.     write_byte(0)
  1102.    
  1103.     write_byte(g_iColor[0])
  1104.     write_byte(g_iColor[1])
  1105.     write_byte(g_iColor[2])
  1106.    
  1107.     write_byte(200)
  1108.     write_byte(0)
  1109.    
  1110.     message_end()
  1111. }
  1112.  
  1113. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
  1114.     new msg[191], players[32], count = 1
  1115.    
  1116.     static len
  1117.     len = formatex(msg, charsmax(msg), "^x04[^x03 %s^x04 ]^x01 ", PLUGIN_PREFIX)
  1118.     vformat(msg[len], charsmax(msg) - len, string, 3)
  1119.  
  1120.     if(id)
  1121.         players[0] = id
  1122.     else
  1123.         get_players(players,count,"ch")
  1124.  
  1125.     for (new i = 0; i < count; i++)
  1126.     {
  1127.         if(is_user_connected(players[i]))
  1128.         {
  1129.             message_begin(MSG_ONE_UNRELIABLE, g_SayText,_, players[i])
  1130.             write_byte(players[i])
  1131.             write_string(msg)
  1132.             message_end()
  1133.         }
  1134.     }
  1135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement