Raised This Month: $51 Target: $400
 12% 

Help to add knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
akdteam
Member
Join Date: Jan 2009
Old 06-02-2011 , 08:41   Help to add knife
Reply With Quote #1

Hi, what is the correct form to add a knife model in a heroe ?

Im view the beginner's Superhero Tutorial But explaining how add a weapon model, thanks.



pd: Im view the chuky code but really dont know If this is the right way.


Other question, how add Explosions and Rays ?

Thanks also.
akdteam is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 06-02-2011 , 08:47   Re: Help to add knife
Reply With Quote #2

A model is a model, has nothing to do at all if its a knife model or a gun model........
__________________
The Art of War is offline
akdteam
Member
Join Date: Jan 2009
Old 06-02-2011 , 10:06   Re: Help to add knife
Reply With Quote #3

But a part of this code no is necessary if change is with knife

Quote:
public sh_hero_init(id, heroID, mode)
{
//you should now know what should be going here

//again we are using the hero init to set the weapon model if the hero is picked
switch (mode)
{
//You know what this is
case SH_HERO_ADD:
{
gHasSuperPower[id] = true
//this is what is new
//this tells that we are going to super_weapons to give out a free weapon
super_weapon(id)
//here when the hero is picked we also go to set the weapon model or he will first get it when he spawn next time
switch_model(id)
}
//You know what this is
case SH_HERO_DROP:
{
gHasSuperPower[id] = false
//now we check if the user is alive if user drops this hero while alive he should not be able to use the gun
if (is_user_alive(id))
{
//this drops the weapon
sh_drop_weapon(id, CSW_M4A1, true)
//the true value I set means that when the weapon is dropped it disappears so user cannot just pick it up again
}

}
And this how is the correct form to edit that for use a knife


public sh_client_spawn(id)
{
//check if they have the power
if (gHasSuperPower[id])
{
//go and give free gun if it is true that the user has the hero
super_weapon(id)
}
}

//yes now we actually give the free gun
super_weapon(id)
{
//before we just handle the gun out to this crazy maniac we have to check if sh is actually running and that the user is alive and he has the hero
if (sh_is_active() && is_user_alive(id) && gHasSuperPower[id] )
{
//if all this is true we can safely give him his gun
sh_give_weapon(id, CSW_M4A1)
}
}

//now we use the registered event
public weapon_change(id)
{
//do nothing if client does not have hero or sh is off
if ( !sh_is_active() || !gHasSuperPower[id] ) return

//the read data is reading the weapon the client has out
new weaponID = read_data(2)
//and if the client does not have the m4a1 out just do nothing
if (weaponID !=CSW_M4A1) return

//now we checked if the user does not have the m4a1 out. If he does not the code stops here
//if he does have m4a1 out then we continue so now we set the weapon model for the m4a1 since he is having that gun out
//yes we are going to do it in switch_models since that makes most sense
switch_model(id)

//now, we do not want the guy to run out of ammo so we just give him an unlimited amout of it
//this is reading how many bullets there are left in the gun
if (read_data(3) == 0)
{
//so if he is out of ammo just reload it
sh_reload_ammo(id, 1)
/*after the id I made a 1 number
look at the superheromod.inc and you will see this
0 - follow server sh_reloadmode CVAR
1 - continuous shooting, no reload
2 - fill the backpack (must reload)
3 - drop the gun and get a new one with full clip
That should explain it*/
}
}
akdteam is offline
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 06-02-2011 , 10:29   Re: Help to add knife
Reply With Quote #4

Everywhere you see the text "Super" you have to edit to your hero name.

ALLWAYS START A HERO WITH THIS!

PHP Code:
//Yeah, we include superheromod for this one
#include <superheromod>

new gHeroID
new gHeroName[] = "super" //creates a string varr to hold the hero name
new bool:gHasSuperPower[SH_MAXSLOTS+1//creates a varr with an aray, with 1 slot per player

public plugin_init()
{
    
//This registers the plugin with amx mod x. This is what is shown when you type amx_plugins in console
    
register_plugin("SUPERHERO Super""ShVersionHere""AuthorNameHere")
    
    
//now we register the cvars
    //you can make the "pcvarLevel" to what ever you want, but make sure it matches this each time you use it
    
new pcvarLevel register_cvar("super_level""0"//this is what level the hero should be avalible at
    
    //This is what creates the hero remember the pcvarLevel is pointing at the level for the hero
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
//This is setting the hero info. It pretty much explains itself
    
sh_set_hero_info(gHeroID"short decription""long decription")
    
    
//if you were used to the old method you will notice that there is no need to register the init anymore therefor nothing more is required
}

public 
sh_hero_init(idheroIDmode)
{
    
//if no power return
    
if (gHeroID != heroID) return
    
    
//This is what runs when someone drops or picks the hero
    
switch(mode)
    {
        
//if the hero is added
        
case SH_HERO_ADD:
        {
            
//it is true that client has the hero
            
gHasSuperPower[id] = true
        
}
        
//if the hero is dropped
        
case SH_HERO_DROP:
        {
            
//it is false that the client has the hero
            
gHasSuperPower[id] = false
        
}
    }

The full hero code is here:

PHP Code:
#include <superheromod>

new gHeroID
new gHasSuper[SH_MAXSLOTS+1]
new const 
gSuperWeapon[] = "models/shmod/v_super_m4a1.mdl"

public plugin_init()
{
    
register_plugin("SUPERHERO Super""ShVersionHere""AuthorNameHere")
    
    new 
pcvarLevel register_cvar("Super_level""10")
    new 
pcvarMult register_cvar("Super_knifemult""5")
    
    
gHeroID sh_create_hero("Super"pcvarLevel)
    
sh_set_hero_info(gHeroID"Short Description""Long Description")
    
    
sh_set_hero_dmgmult(gHeroIDpcvarMultCSW_KNIFE)
    
    
register_event("CurWeapon""weapon_change""be""1=1")    
}

public 
sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return
    
    switch(
mode)
    {
        case 
SH_HERO_ADD:
        {
            
gHasSuper[id] = true
            super_weapon
(id)
            
switch_model(id)
        }
        
        case 
SH_HERO_DROP:
        {
            
gHasSuper[id] = false
            
if (is_user_alive(id))
            {
            
sh_drop_weapon(idCSW_KNIFEtrue)
            }
        }
    }
}

public 
sh_client_spawn(id)
{
    if (
gHasSuper[id])
    {
        
super_weapon(id)
    }
}

public 
plugin_precache() 

    
precache_model(gSuperWeapon);


super_weapon(id)
{
    if (
sh_is_active() && is_user_alive(id) && gHasSuper[id] )
    {
        
sh_give_weapon(idCSW_KNIFE)
    }
}

public 
weapon_change(id)
{
    if ( !
sh_is_active() || !gHasSuper[id] ) return
    
    new 
weaponID read_data(2)
    if (
weaponID !=CSW_KNIFE) return
    
    
switch_model(id)
    
    if (
read_data(3) == 0)
    {
        
sh_reload_ammo(id1)
    }
}

switch_model(id)
{
    if (!
sh_is_active() || !is_user_alive(id) || !gHasSuper[id] ) return
    
    if (
get_user_weapon(id) == CSW_M4A1)
    {
        
set_pev(idpev_viewmodel2gSuperWeapon)
    }

Now for the explainings!

Weapon Model:

PHP Code:
//now we make a new global variable to hold the path of the weapon model
new const gSuperWeapon[] = "models/shmod/v_super_m4a1.mdl"

public plugin_init()
{
    
//all the plugin_init stuff should be here. All the cvars you made so far and the hero creating etc goes here
    
    //and now we can register the CurWeapon event. This runs each time the user changes his weapon
    
register_event("CurWeapon""weapon_change""be""1=1")
}
public 
sh_hero_init(idheroIDmode)
{
    
//you should now know what should be going here
    
    //again we are using the hero init to set the weapon model if the hero is picked
    
switch (mode)
    {
        
//You know what this is
        
case SH_HERO_ADD:
        {
            
gHasSuperPower[id] = true
            
//this is what is new
            //this tells that we are going to super_weapons to give out a free weapon
            
super_weapon(id)
            
//here when the hero is picked we also go to set the weapon model or he will first get it when he spawn next time
            
switch_model(id)
        }
        
//You know what this is
        
case SH_HERO_DROP:
        {
            
gHasSuperPower[id] = false
            
//now we check if the user is alive if user drops this hero while alive he should not be able to use the gun
            
if (is_user_alive(id))
            {
                
//this drops the weapon
                
sh_drop_weapon(idCSW_M4A1true)
                
//the true value I set means that when the weapon is dropped it disappears so user cannot just pick it up again
            
}
        }
    }
}

public 
sh_client_spawn(id)
{
    
//check if they have the power
    
if (gHasSuperPower[id])
    {
        
//go and give free gun if it is true that the user has the hero
        
super_weapon(id)
    }
}

//yes now we actually give the free gun
super_weapon(id)
{
    
//before we just handle the gun out to this crazy maniac we have to check if sh is actually running and that the user is alive and he has the hero
    
if (sh_is_active() && is_user_alive(id) && gHasSuperPower[id] )
    {
        
//if all this is true we can safely give him his gun
        
sh_give_weapon(idCSW_M4A1)
    }
}

//now we use the registered event
public weapon_change(id)
{
    
//do nothing if client does not have hero or sh is off
    
if ( !sh_is_active() || !gHasSuperPower[id] ) return
    
    
//the read data is reading the weapon the client has out
    
new weaponID read_data(2)
    
//and if the client does not have the m4a1 out just do nothing
    
if (weaponID !=CSW_M4A1) return
    
    
//now we checked if the user does not have the m4a1 out. If he does not the code stops here
    //if he does have m4a1 out then we continue so now we set the weapon model for the m4a1 since he is having that gun out
    //yes we are going to do it in switch_models since that makes most sense
    
switch_model(id)
    
    
//now, we do not want the guy to run out of ammo so we just give him an unlimited amout of it
    //this is reading how many bullets there are left in the gun
    
if (read_data(3) == 0)
    {
        
//so if he is out of ammo just reload it
        
sh_reload_ammo(id1)
        
/*after the id I made a 1 number
        look at the superheromod.inc and you will see this
        0 - follow server sh_reloadmode CVAR
        1 - continuous shooting, no reload
        2 - fill the backpack (must reload)
        3 - drop the gun and get a new one with full clip
        That should explain it*/
    
}
}

switch_model(id)
{
    
//if the sh mod is off the client is dead or he does not have the hero we do not want to let him have the weapon model!
    
if (!sh_is_active() || !is_user_alive(id) || !gHasSuperPower[id] ) return
    
    
//and now we check again if he still has the m4a1 out
    
if (get_user_weapon(id) == CSW_M4A1)
    {
        
//now he has all the requirements to have the weapon model so we also need to give it to him
        
set_pev(idpev_viewmodel2gSuperWeapon)
    }

Damage Multiplier:

PHP Code:
public plugin_init()
{
    
//the code you already made should be here
    //Be sure to set the cvars as the first thing in your plugin
    //you now add a cvar for multiplier:
    
new pcvarMult register_cvar("super_mult""5")
    
    
//and now you set the hero power. Remember this should be after you create the hero with sh_create_hero!
    //with this native I set the hero multiplier accordingly to the multiplier cvar
    
sh_set_hero_dmgmult(gHeroIDpcvarMultCSW_KNIFE)

Weapon P Model:

PHP Code:
//now we make a new global variable to hold the path of the gun model
new const gSuperWeapon2[] = "models/shmod/p_super_m4a1.mdl"

switch_model(id)
{
    
//if the sh mod is off the client is dead or he does not have the hero we do not want to let him have the weapon model!
    
if (!sh_is_active() || !is_user_alive(id) || !gHasSuper[id] ) return
    
    
//and now we check again if he still has the m4a1 out
    
if (get_user_weapon(id) == CSW_KNIFE)
    {
        
//now he has all the requirements to have the weapon model so we also need to give it to him
        
set_pev(idpev_weaponmodel2gSuperWeapon2)
    }

Weapon Precache:

PHP Code:
public plugin_precache() 

    
precache_model(gSuperWeapon); //V-model
    
precache_model(gSuperWeapon2); //P-model


Need futher help look here: [Tutorial]Learn The New Ways
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
akdteam
Member
Join Date: Jan 2009
Old 06-02-2011 , 10:52   Re: Help to add knife
Reply With Quote #5

ok thanks now understand, i saw this tutorial but i not understood how add a knife. (IS DIFFERENT).

how i add the rays and explosions in hero?
akdteam is offline
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 06-02-2011 , 11:48   Re: Help to add knife
Reply With Quote #6

adding knife model is fucking same!!! and rays and explosions can you find if you search in other heroes... read jelle's ripping tutorial...
RollerBlades is offline
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 06-02-2011 , 12:41   Re: Help to add knife
Reply With Quote #7

Quote:
Originally Posted by akdteam View Post
ok thanks now understand, i saw this tutorial but i not understood how add a knife. (IS DIFFERENT).

how i add the rays and explosions in hero?
Quote:
Originally Posted by RollerBlades View Post
adding knife model is fucking same!!! and rays and explosions can you find if you search in other heroes... read jelle's ripping tutorial...
Akdteam as RB says.. Its not different, gun and knife is the same..
They are both weapons.

[Tutorial] Reading/ripping hero codes
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 06-02-2011 , 13:12   Re: Help to add knife
Reply With Quote #8

Thank you...

All models (.mdl files) are the same, all CSW_XXXXXXXXX are defined by the name of the CSW weapon namely CSW_KNIFE for knife, so no, its not different.
__________________
The Art of War is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode