Converted Paint Ball Gun

Zombies/Humans Extra-Items
Post Reply
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 276
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

Paint Ball Gun

#1

Post by Mark » 9 Months Ago

Paint Ball Gun



Note:

OMG I LOVE THIS GUN!!!


Description:
  • A new extra-item for Humans, PaintBall Gun! (1 round)

Cvars:
  1.     paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
  2.     paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
  3.     paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
  4.     paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")

Code:
    1. #include <zombie_escape>
    2. #include <engine>
    3.  
    4. #define ITEM_NAME "Paintball Gun"
    5. #define ITEM_COST 50
    6.  
    7. new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl"
    8. new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl"
    9. new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl"
    10.  
    11. new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
    12. new lastammo[33], g_paintball_gun[33], g_ballsnum = 0
    13.  
    14. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_AK47)|(1<<CSW_M4A1)|(1<<CSW_FAMAS)|(1<<CSW_GALIL)|(1<<CSW_SCOUT)|(1<<CSW_AWP)|(1<<CSW_M249)|(1<<CSW_MP5NAVY)|(1<<CSW_P90)|(1<<CSW_MAC10)|(1<<CSW_TMP)|(1<<CSW_XM1014)|(1<<CSW_M3)|(1<<CSW_G3SG1)|(1<<CSW_SG550)|(1<<CSW_SG552)|(1<<CSW_AUG)|(1<<CSW_UMP45);
    15.  
    16.  
    17. // Cvars //
    18. new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID
    19.  
    20. public plugin_init()
    21. {
    22.     register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark")
    23.     register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED);
    24.    
    25.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    26.     RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer")
    27.     register_forward(FM_SetModel, "fw_SetModel")
    28.     register_event("CurWeapon", "make_paint", "be", "3>0")
    29.     register_event("WeapPickup","checkModel","b","1=19")
    30.     register_event("CurWeapon","checkWeapon","be","1=1")
    31.     register_event("HLTV", "new_round", "a", "1=0", "2=0")
    32.    
    33.     paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
    34.     paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
    35.     paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
    36.     paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")
    37.    
    38.     g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0)
    39. }
    40.  
    41. public plugin_precache()
    42. {
    43.     precache_model("sprites/bhit.spr")
    44.     precache_model("sprites/richo1.spr")
    45.     precache_model(PAINTBALL_V_MODEL)
    46.     precache_model(PAINTBALL_P_MODEL)
    47.     precache_model(PAINTBALL_W_MODEL)
    48. }
    49.  
    50. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
    51. {
    52.     if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker))
    53.     {
    54.         SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi ))
    55.        
    56.         set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16);
    57.         set_task(5.0, "remove_glow", victim)
    58.     }
    59. }
    60.  
    61. public ze_user_humanized(id)
    62. {
    63.     g_paintball_gun[id] = false
    64.     remove_glow(id)
    65. }
    66.  
    67. public ze_user_infected(iVictim)
    68. {
    69.     g_paintball_gun[iVictim] = false
    70.     remove_glow(iVictim)   
    71. }
    72.  
    73. public ze_select_item_pre(id, itemid)
    74. {
    75.     if (itemid != g_iItemID)
    76.         return ZE_ITEM_AVAILABLE
    77.    
    78.     if (ze_is_user_zombie(id))
    79.         return ZE_ITEM_DONT_SHOW
    80.        
    81.     return ZE_ITEM_AVAILABLE
    82. }
    83.  
    84.  
    85. public ze_select_item_post(id, itemid)
    86. {
    87.     if (itemid != g_iItemID)
    88.         return
    89.        
    90.     ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D")
    91.    
    92.     Get_MyWeapon(id)
    93. }
    94.  
    95. public Get_MyWeapon(id)
    96. {
    97.     drop_weapons(id, 1);
    98.     g_paintball_gun[id] = true
    99.     give_item(id, "weapon_mp5navy")
    100. }
    101.  
    102. public remove_glow(id)
    103. {
    104.     set_rendering(id);
    105. }
    106.  
    107. public checkWeapon(id)
    108. {
    109.     new plrClip, plrAmmo, plrWeap[32], plrWeapId
    110.    
    111.     plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
    112.    
    113.     if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id])
    114.         checkModel(id)
    115.  
    116.     else return PLUGIN_CONTINUE;
    117.    
    118.     if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip))
    119.     {
    120.         // If the user is out of ammo..
    121.         get_weaponname(plrWeapId, plrWeap, 31)
    122.         // Get the name of their weapon
    123.         give_item(id, plrWeap)
    124.         engclient_cmd(id, plrWeap)
    125.         engclient_cmd(id, plrWeap)
    126.         engclient_cmd(id, plrWeap)
    127.     }
    128.     return PLUGIN_HANDLED
    129. }
    130.  
    131. public checkModel(id)
    132. {
    133.     if (ze_is_user_zombie(id)) return PLUGIN_HANDLED;
    134.    
    135.     new szWeapID = read_data(2)
    136.    
    137.     if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id])
    138.     {
    139.         entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL)
    140.         entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL)
    141.     }
    142.     return PLUGIN_HANDLED
    143. }
    144.  
    145. public make_paint(id)
    146. {
    147.     new ammo = read_data(3)
    148.    
    149.     if(get_user_weapon(id) == CSW_MP5NAVY  && lastammo[id] > ammo && g_paintball_gun[id])
    150.     {
    151.         new iOrigin[3]
    152.         get_user_origin(id, iOrigin, 4)
    153.         new Float:fOrigin[3]
    154.         IVecFVec(iOrigin, fOrigin)
    155.        
    156.         if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin))
    157.         {
    158.             new ent = create_entity("info_target")
    159.             if(ent > 0)
    160.             {
    161.                 entity_set_string(ent, EV_SZ_classname, "paint_ent")
    162.                 entity_set_int(ent, EV_INT_movetype, 0)
    163.                 entity_set_int(ent, EV_INT_solid, 0)
    164.                 entity_set_model(ent, g_paintSprite[random_num(0,1)])
    165.                 new r, g, b
    166.  
    167.                 r = random_num(64,255)
    168.                 g = random_num(64,255)
    169.                 b = random_num(64,255)
    170.                
    171.                 set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
    172.                 entity_set_origin(ent, fOrigin)
    173.                 entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
    174.                 entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
    175.                 ++g_ballsnum
    176.             }
    177.         }
    178.     }
    179.     lastammo[id] = ammo
    180. }
    181.  
    182. public pfn_think(entity)
    183. {
    184.     if(!is_valid_ent(entity))
    185.         return
    186.    
    187.     new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31)
    188.     if(entity > 0 && equal(class, "paint_ent"))
    189.     {
    190.         remove_entity(entity)
    191.         --g_ballsnum
    192.     }
    193. }
    194.  
    195. public new_round()
    196. {
    197.     for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false
    198.    
    199.     remove_entity_name("paint_ent")
    200.     g_ballsnum = 0
    201. }
    202.  
    203. stock worldInVicinity(Float:origin[3])
    204. {
    205.     new ent = find_ent_in_sphere(-1, origin, 4.0)
    206.     while(ent > 0)
    207.     {
    208.         if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0;
    209.         ent = find_ent_in_sphere(ent, origin, 4.0)
    210.     }
    211.    
    212.     new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
    213.    
    214.     traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0
    215.     traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0
    216.     traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0
    217.     traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0
    218.     traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0
    219.     traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0
    220.     traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0
    221.     traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0
    222.    
    223.     for (new i = 0; i < 8; i++)
    224.     {
    225.         if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1;
    226.    
    227.         hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
    228.         if (hitEnt != -1) return 1;
    229.        
    230.         for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1;
    231.     }
    232.     return 0
    233. }
    234.  
    235. public fw_SetModel(entity, model[])
    236. {
    237.     if(!is_valid_ent(entity))
    238.         return FMRES_IGNORED;
    239.  
    240.     if(!equal(model, "models/w_mp5.mdl"))
    241.         return FMRES_IGNORED;
    242.  
    243.     static szClassName[33]
    244.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
    245.     if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED
    246.  
    247.     static iOwner, iStoredMp5ID
    248.     iOwner = entity_get_edict(entity, EV_ENT_owner)
    249.     iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity)
    250.  
    251.     if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID))
    252.     {
    253.         g_paintball_gun[iOwner] = false
    254.         entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581)
    255.         entity_set_model(entity, PAINTBALL_W_MODEL)
    256.  
    257.         return FMRES_SUPERCEDE
    258.     }
    259.     return FMRES_IGNORED
    260. }
    261.  
    262. public fw_AddToPlayer(wpn, id)
    263. {
    264.     if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581)
    265.     {
    266.         g_paintball_gun[id] = true
    267.         entity_set_int(wpn, EV_INT_impulse, 0)
    268.  
    269.         return HAM_HANDLED
    270.     }
    271.     return HAM_IGNORED
    272. }
    273.  
    274. stock give_item(index, const item[]) {
    275.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
    276.         return 0;
    277.  
    278.     new ent = create_entity(item);
    279.     if (!pev_valid(ent))
    280.         return 0;
    281.  
    282.     new Float:origin[3];
    283.     pev(index, pev_origin, origin);
    284.     set_pev(ent, pev_origin, origin);
    285.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
    286.     dllfunc(DLLFunc_Spawn, ent);
    287.  
    288.     new save = pev(ent, pev_solid);
    289.     dllfunc(DLLFunc_Touch, ent, index);
    290.     if (pev(ent, pev_solid) != save)
    291.         return ent;
    292.  
    293.     engfunc(EngFunc_RemoveEntity, ent);
    294.  
    295.     return -1;
    296. }
    297.  
    298. stock drop_weapons(id, dropwhat)
    299. {
    300.     static weapons[32], num, i, weaponid
    301.     num = 0
    302.     get_user_weapons(id, weapons, num)
    303.    
    304.     for (i = 0; i < num; i++)
    305.     {
    306.         weaponid = weapons[i]
    307.        
    308.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
    309.         {
    310.             static wname[32]
    311.             get_weaponname(weaponid, wname, sizeof wname - 1)
    312.            
    313.             engclient_cmd(id, "drop", wname)
    314.         }
    315.     }
    316.    
    317. }
    318.  
    319. stock client_printcolor(const id,const input[], any:...)
    320. {
    321.     new msg[191], players[32], count = 1
    322.     vformat(msg,190,input,3);
    323.     replace_all(msg,190,"!g","^4");    // green
    324.     replace_all(msg,190,"!y","^1");    // normal
    325.     replace_all(msg,190,"!t","^3");    // team
    326.        
    327.     if (id) players[0] = id; else get_players(players,count,"ch");
    328.        
    329.     for (new i=0;i<count;i++)
    330.     {
    331.         if (is_user_connected(players[i]))
    332.         {
    333.             message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
    334.             write_byte(players[i]);
    335.             write_string(msg);
    336.             message_end();
    337.         }
    338.     }
    339. }

Images:
20180915193325_1.jpg



Download:
These users thanked the author Mark for the post (total 3):
Raheem (9 Months Ago) • Luxurious (9 Months Ago) • Jack GamePlay (9 Months Ago)

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1793
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 89 times
Age: 21
Contact:

#2

Post by Raheem » 9 Months Ago

Nice thanks, but where Humans in photo (Score message)? :lol:
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 276
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#3

Post by Mark » 9 Months Ago

Raheem wrote:
9 Months Ago
Nice thanks, but where Humans in photo (Score message)? :lol:
Has todo with dhud and displaying only 6 dhuds at a time.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1793
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 89 times
Age: 21
Contact:

#4

Post by Raheem » 9 Months Ago

Yeah circle dhud bullet damage cause this.
You don't know? Learn and you will know.

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 597
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 6 times
Age: 19
Contact:

#5

Post by Spir0x » 8 Months Ago

He is running ze mod on zp maps it must zp mod on ze maps bro !
I trynna make money, not friends.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 276
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#6

Post by Mark » 8 Months Ago

Spir0x wrote:
8 Months Ago
He is running ze mod on zp maps it must zp mod on ze maps bro !
What are you talking about lol

I’m running ze on a de map since when was de_dust2 a zp map. Btw map has nothing todo with the dhud problem lol.

[ Post made via iPhone ]
These users thanked the author Mark for the post:
shady101852 (8 Months Ago)

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 597
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 6 times
Age: 19
Contact:

#7

Post by Spir0x » 8 Months Ago

nice ze on de map :lol:
I trynna make money, not friends.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 276
Joined: 9 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#8

Post by Mark » 8 Months Ago

Spir0x wrote:
8 Months Ago
nice ze on de map :lol:
:D

[ Post made via iPhone ]

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest