Resolved [ Turtorial ] Native

Unpaid Requests, Public Plugins
Post Reply
VicKy
Member
Member
Pakistan
Posts: 31
Joined: 4 Months Ago
Has thanked: 6 times
Been thanked: 1 time
Contact:

[ Turtorial ] Native

#1

Post by VicKy » 1 Week Ago

How To Make Native Of Gun
Give Turtorial Please
Image

ngamerz
Member
Member
Philippines
Posts: 21
Joined: 4 Months Ago
Location: Philippines From South Korea
Has thanked: 1 time
Been thanked: 3 times
Contact:

#2

Post by ngamerz » 1 Week Ago

First of all, to make natives you need to follow this steps:

Add this:

Code: Select all

public plugin_natives()
{
}
After that, inside of those 2 brackets you'll need to add this

Code: Select all

register_native("ze_test_gun", "native_ze_test_gun", 1)
then this:

Code: Select all

public native_ze_test_gun(id)
{
	Do something //
}
These users thanked the author ngamerz for the post (total 2):
Raheem (5 Days Ago) • VicKy (1 Day Ago)
My Steam:
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2160
Joined: 4 Years Ago
Has thanked: 49 times
Been thanked: 145 times
Age: 23
Contact:

#3

Post by Raheem » 5 Days Ago

And here is an example:
    1. #include <zombie_escape>
    2. #include <fun>
    3. #include <cstrike>
    4.  
    5. #define is_valid_player(%1) (1 <= %1 <= 32)
    6.  
    7. new M4_V_MODEL[64] = "models/zombie_escape/v_golden_m4a1.mdl"
    8. new M4_P_MODEL[64] = "models/zombie_escape/p_golden_m4a1.mdl"
    9. new M4_W_MODEL[64] = "models/zombie_escape/w_golden_m4a1.mdl"
    10.  
    11. /* Pcvars */
    12. new cvar_dmgmultiplier, cvar_goldbullets,  cvar_custommodel, cvar_uclip
    13.  
    14. new bool:g_HasM4[33]
    15.  
    16. new bullets[ 33 ]
    17.  
    18. // Sprite
    19. new m_spriteTexture
    20.  
    21. const Wep_m4a1 = ((1<<CSW_M4A1))
    22.  
    23. public plugin_init()
    24. {
    25.    
    26.     /* CVARS */
    27.     cvar_dmgmultiplier = register_cvar("zp_goldenm4_dmg_multiplier", "4")
    28.     cvar_custommodel = register_cvar("zp_goldenm4_custom_model", "1")
    29.     cvar_goldbullets = register_cvar("zp_goldenm4_gold_bullets", "1")
    30.     cvar_uclip = register_cvar("zp_goldenm4_unlimited_clip", "0")
    31.    
    32.     // Register The Plugin
    33.     register_plugin("Golden M4A1", "1.1", "SPIR0X")
    34.  
    35.     // Death Msg
    36.     register_event("DeathMsg", "Death", "a")
    37.     // Weapon Pick Up
    38.     register_event("WeapPickup","checkModel","b","1=19")
    39.     // Current Weapon Event
    40.     register_event("CurWeapon","checkWeapon","be","1=1")
    41.     register_event("CurWeapon", "make_tracer", "be", "1=1", "3>0")
    42.     // Ham TakeDamage
    43.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    44.     RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
    45.    
    46. }
    47.  
    48. public plugin_natives()
    49. {
    50.     register_native("give_golden_m4a1", "native_give_golden_m4a1", 1)
    51. }
    52.  
    53. public client_connect(id)
    54. {
    55.     g_HasM4[id] = false
    56. }
    57.  
    58. public client_disconnected(id)
    59. {
    60.     g_HasM4[id] = false
    61. }
    62.  
    63. public Death()
    64. {
    65.     g_HasM4[read_data(2)] = false
    66. }
    67.  
    68. public fwHamPlayerSpawnPost(id)
    69. {
    70.     g_HasM4[id] = false
    71. }
    72.  
    73. public plugin_precache()
    74. {
    75.     precache_model(M4_V_MODEL)
    76.     precache_model(M4_P_MODEL)
    77.     precache_model(M4_W_MODEL)
    78.     m_spriteTexture = precache_model("sprites/dot.spr")
    79.     precache_sound("weapons/zoom.wav")
    80. }
    81.  
    82. public ze_user_infected(id, iInfector)
    83. {
    84.     if (ze_is_user_zombie(id))
    85.     {
    86.         g_HasM4[id] = false
    87.     }
    88. }
    89.  
    90. public checkModel(id)
    91. {
    92.     if (ze_is_user_zombie(id))
    93.         return PLUGIN_HANDLED
    94.    
    95.     new szWeapID = read_data(2)
    96.    
    97.     if ( szWeapID == CSW_M4A1 && g_HasM4[id] == true && get_pcvar_num(cvar_custommodel) )
    98.     {
    99.         set_pev(id, pev_viewmodel2, M4_V_MODEL)
    100.         set_pev(id, pev_weaponmodel2, M4_P_MODEL)
    101.         set_pev(id, pev_weaponmodel2, M4_W_MODEL)
    102.     }
    103.     return PLUGIN_HANDLED
    104. }
    105.  
    106. public checkWeapon(id)
    107. {
    108.     new plrClip, plrAmmo, plrWeap[32]
    109.     new plrWeapId
    110.    
    111.     plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
    112.    
    113.     if (plrWeapId == CSW_M4A1 && g_HasM4[id])
    114.     {
    115.         checkModel(id)
    116.     }
    117.     else
    118.     {
    119.         return PLUGIN_CONTINUE
    120.     }
    121.    
    122.     if (plrClip == 0 && get_pcvar_num(cvar_uclip))
    123.     {
    124.         // If the user is out of ammo..
    125.         get_weaponname(plrWeapId, plrWeap, 31)
    126.         // Get the name of their weapon
    127.         rg_give_item(id, plrWeap)
    128.         engclient_cmd(id, plrWeap)
    129.         engclient_cmd(id, plrWeap)
    130.         engclient_cmd(id, plrWeap)
    131.     }
    132.     return PLUGIN_HANDLED
    133. }
    134.  
    135.  
    136.  
    137. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
    138. {
    139.     if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_M4A1 && g_HasM4[attacker] )
    140.     {
    141.         SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) )
    142.     }
    143. }
    144.  
    145. public make_tracer(id)
    146. {
    147.     if (get_pcvar_num(cvar_goldbullets))
    148.     {
    149.         new clip,ammo
    150.         new wpnid = get_user_weapon(id,clip,ammo)
    151.         new pteam[16]
    152.        
    153.         get_user_team(id, pteam, 15)
    154.        
    155.         if ((bullets[id] > clip) && (wpnid == CSW_M4A1) && g_HasM4[id])
    156.         {
    157.             new vec1[3], vec2[3]
    158.             get_user_origin(id, vec1, 1) // origin; your camera point.
    159.             get_user_origin(id, vec2, 4) // termina; where your bullet goes (4 is cs-only)
    160.            
    161.            
    162.             //BEAMENTPOINTS
    163.             message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
    164.             write_byte (0)     //TE_BEAMENTPOINTS 0
    165.             write_coord(vec1[0])
    166.             write_coord(vec1[1])
    167.             write_coord(vec1[2])
    168.             write_coord(vec2[0])
    169.             write_coord(vec2[1])
    170.             write_coord(vec2[2])
    171.             write_short( m_spriteTexture )
    172.             write_byte(1) // framestart
    173.             write_byte(5) // framerate
    174.             write_byte(2) // life
    175.             write_byte(10) // width
    176.             write_byte(0) // noise
    177.             write_byte( 255 )     // r, g, b
    178.             write_byte( 215 )       // r, g, b
    179.             write_byte( 0 )       // r, g, b
    180.             write_byte(200) // brightness
    181.             write_byte(150) // speed
    182.             message_end()
    183.         }
    184.    
    185.         bullets[id] = clip
    186.     }
    187.    
    188. }
    189.  
    190. public native_give_golden_m4a1(player)
    191. {
    192.     if (user_has_weapon(player, CSW_M4A1))
    193.     {
    194.         drop_prim(player)
    195.     }
    196.        
    197.     give_item(player, "weapon_m4a1")
    198.     cs_set_user_bpammo(player, CSW_M4A1, 90)
    199.    
    200.     g_HasM4[player] = true;
    201. }
    202.  
    203. stock drop_prim(id)
    204. {
    205.     new weapons[32], num
    206.     get_user_weapons(id, weapons, num)
    207.     for (new i = 0; i < num; i++) {
    208.         if (Wep_m4a1 & (1<<weapons[i]))
    209.         {
    210.             static wname[32]
    211.             get_weaponname(weapons[i], wname, sizeof wname - 1)
    212.             engclient_cmd(id, "drop", wname)
    213.         }
    214.     }
    215. }
These users thanked the author Raheem for the post:
VicKy (1 Day Ago)
He who fails to plan is planning to fail

VicKy
Member
Member
Pakistan
Posts: 31
Joined: 4 Months Ago
Has thanked: 6 times
Been thanked: 1 time
Contact:

#4

Post by VicKy » 1 Day Ago

Thanks To Help Me @Raheem And @ngamerz
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests