Advertisement
MegastoRM

Bonus Box v2

Sep 11th, 2012
1,570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.87 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4. #include < engine >
  5. #include < fakemeta_util >
  6. #include < cstrike >
  7. #include < colorchat>
  8.  
  9. #define PLUGIN "Bonus Box v2"
  10. #define VERSION "1.0"
  11. #define AUTHOR "MegastorM"
  12.  
  13. #define TASK_BONUS 1234
  14.  
  15. new modell[] = { "models/box/w_bonus.mdl" }
  16. new const szPrefix[15] = "[Bonus Box v2]"
  17. new g_sprite
  18. new Float:OriginZrtve[3], Float:Uglovi[3]
  19.  
  20. public plugin_init() {
  21.     register_plugin(PLUGIN, VERSION, AUTHOR)
  22.     register_event("DeathMsg", "event_death", "ade");
  23.     register_touch("BonusBox", "player",  "touchbox");
  24.     // Add your code here...
  25. }
  26.  
  27. public plugin_precache()
  28. {
  29.     precache_model(modell)
  30.     g_sprite = precache_model("sprites/box/box_sprite.spr")
  31.     precache_sound("box/supplybox.wav")
  32.     precache_sound("box/touched.wav")
  33. }
  34.  
  35. public event_death()
  36. {
  37.     new victim = read_data(2)
  38.     if(is_user_connected(victim))
  39.     {
  40.         get_origin(victim)
  41.        
  42.         set_task(0.1,"create_bonusbox",TASK_BONUS)
  43.     }
  44. }
  45.  
  46. public get_origin(id)
  47. {
  48.     pev(id, pev_origin, OriginZrtve)
  49.     pev(id, pev_angles, Uglovi)
  50.     Uglovi[0] = 0.0
  51. }
  52.  
  53. public create_bonusbox()
  54. {
  55.     new ent = create_entity("info_target")
  56.    
  57.     entity_set_origin(ent, OriginZrtve)
  58.     entity_set_string(ent, EV_SZ_classname, "BonusBox")
  59.     entity_set_model(ent, modell)
  60.     set_rendering ( ent, kRenderFxGlowShell, random_num(128,255),random_num(128,255),random_num(128,255), kRenderFxNone, 255 )
  61.     emit_sound(ent, CHAN_ITEM, "box/supplybox.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
  62.     entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
  63.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_PUSHSTEP)
  64.    
  65.     entity_set_size(ent,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  66.    
  67.     drop_to_floor(ent)
  68.    
  69.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, OriginZrtve, 0)
  70.     write_byte(TE_BEAMCYLINDER) // TE id
  71.     engfunc(EngFunc_WriteCoord, OriginZrtve[0]) // x
  72.     engfunc(EngFunc_WriteCoord, OriginZrtve[1]) // y
  73.     engfunc(EngFunc_WriteCoord, OriginZrtve[2]) // z
  74.     engfunc(EngFunc_WriteCoord, OriginZrtve[0]) // x axis
  75.     engfunc(EngFunc_WriteCoord, OriginZrtve[1]) // y axis
  76.     engfunc(EngFunc_WriteCoord, OriginZrtve[2]+385.0) // z axis
  77.     write_short(g_sprite) // sprite
  78.     write_byte(0) // startframe
  79.     write_byte(0) // framerate
  80.     write_byte(4) // life
  81.     write_byte(30) // width
  82.     write_byte(0) // noise
  83.     write_byte(250) // red
  84.     write_byte(0) // green
  85.     write_byte(0) // blue
  86.     write_byte(200) // brightness
  87.     write_byte(0) // speed
  88.     message_end()
  89. }
  90.  
  91. public touchbox(ent, toucher)
  92. {
  93.     if (!is_user_alive(toucher) || !pev_valid(ent))
  94.         return FMRES_IGNORED
  95.    
  96.     new classname[32]  
  97.     pev(ent, pev_classname, classname, 31)
  98.     if (!equal(classname, "BonusBox"))
  99.         return FMRES_IGNORED
  100.    
  101.     meni_za_potvrdu(toucher)
  102.    
  103.     emit_sound(toucher, CHAN_ITEM, "box/touched.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
  104.    
  105.     set_pev(ent, pev_effects, EF_NODRAW)
  106.     set_pev(ent, pev_solid, SOLID_NOT)
  107.     remove_ent(ent)
  108.     return FMRES_IGNORED
  109.    
  110. }
  111.  
  112. public meni_za_potvrdu(id)
  113. {
  114.     new szItem[32]
  115.     new menu = menu_create("Da li zelis random item iz kutije?","Box_H");
  116.    
  117.     formatex(szItem,charsmax(szItem),"\yDa")
  118.     menu_additem(menu, szItem)
  119.    
  120.     formatex(szItem,charsmax(szItem),"\dNe")
  121.     menu_additem(menu,szItem)
  122.     menu_display(id,menu);
  123. }
  124.  
  125. public Box_H(id, menu, item)
  126. {  
  127.     switch(item)
  128.     {
  129.         case 0:
  130.         {
  131.             switch(random_num(1, 13))
  132.             {
  133.                 case 1:
  134.                 {
  135.                     set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  136.                     fm_give_item(id, "weapon_deagle")
  137.                     cs_set_user_bpammo(id, CSW_DEAGLE,35)
  138.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 Desert Eagle+Aura",szPrefix)
  139.                 }
  140.                 case 2:
  141.                 {
  142.                     fm_give_item(id, "weapon_ak47")
  143.                     cs_set_user_bpammo(id, CSW_AK47,90)
  144.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 AK47",szPrefix)
  145.                 }
  146.                 case 3:
  147.                 {
  148.                     fm_give_item(id, "weapon_m4a1")
  149.                     cs_set_user_bpammo(id, CSW_M4A1,90)
  150.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 M4A1",szPrefix)
  151.                 }
  152.                 case 4:
  153.                 {
  154.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Nazalost,nisi dobio nista,vise srece sledeci put",szPrefix)
  155.                 }
  156.                 case 5:
  157.                 {
  158.                     fm_give_item(id, "weapon_sg550")
  159.                     cs_set_user_bpammo(id, CSW_SG550,90)
  160.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 SG550",szPrefix)
  161.                 }
  162.                 case 6:
  163.                 {
  164.                     fm_give_item(id, "weapon_g3sg1")
  165.                     cs_set_user_bpammo(id, CSW_G3SG1,90)
  166.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 G3SG1",szPrefix)
  167.                 }
  168.                 case 7:
  169.                 {
  170.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Nazalost,nisi dobio nista,vise srece sledeci put",szPrefix)
  171.                 }
  172.                 case 8:
  173.                 {
  174.                     fm_set_user_health(id, get_user_health(id)+250)
  175.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 +250HP",szPrefix)
  176.                 }
  177.                 case 9:
  178.                 {
  179.                     fm_set_user_health(id, get_user_health(id)+500)
  180.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 +500HP",szPrefix)
  181.                 }
  182.                 case 10:
  183.                 {
  184.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Nazalost,nisi dobio nista,vise srece sledeci put",szPrefix)
  185.                 }
  186.                 case 11:
  187.                 {
  188.                     cs_set_user_money(id, cs_get_user_money(id)+1000)
  189.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 +1000$",szPrefix)
  190.                 }
  191.                 case 12:
  192.                 {
  193.                     cs_set_user_money(id, cs_get_user_money(id)+5000)
  194.                     ColorChat(id, TEAM_COLOR, "^4%s^1 dobio si^3 +5000$",szPrefix)
  195.                 }
  196.                 case 13:
  197.                 {
  198.                     cs_set_user_money(id, 0)
  199.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Nazalost,izgubio si^3 sve pare",szPrefix)
  200.                 }
  201.             }
  202.         }
  203.         case 1:
  204.         {
  205.             switch(random_num(1,3))
  206.             {
  207.                 case 1:
  208.                 {
  209.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Sledeci put prihvati bonus iz kutije!",szPrefix)
  210.                 }
  211.                 case 2:
  212.                 {
  213.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Ne boj se,neces umreti ako prihvatis bonus!",szPrefix)
  214.                 }
  215.                 case 3:
  216.                 {
  217.                     ColorChat(id, TEAM_COLOR, "^4%s^1 Nisi prihvatio bonus tako da nisi ni nagradjen!",szPrefix)
  218.                 }
  219.                
  220.             }
  221.         }
  222.        
  223.     }
  224.     return PLUGIN_CONTINUE;
  225. }
  226.  
  227. public remove_ent(ent)
  228. {
  229.     if (pev_valid(ent))
  230.         engfunc(EngFunc_RemoveEntity, ent)
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement