Raised This Month: $ Target: $400
 0% 

Weapon Model Setting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NexusReaper69
Member
Join Date: Mar 2008
Old 03-05-2008 , 00:06   Weapon Model Setting
Reply With Quote #1

I am looking for a working method of setting weapon models for heroes since the way I am using (Rolnaaba's Tutorial) does absolutely nothing.

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <superheromod>
#include <fakemeta>

#define PLUGIN "Hero Test"
#define VERSION "1.0"
#define AUTHOR "Vendetter"

new gHeroName[] = "Hero Test"
new bool:gHasTestPower[SH_MAXSLOTS+1]

new g_v_model;

public plugin_init()
{
    register_plugin("Hero Test", "1.0", "Vendetter")
    register_srvcmd("test_init", "test_init");

    shCreateHero(gHeroName, "Hero Test", "Weapon Model Test", false, "test_level");
    shRegHeroInit(gHeroName, "test_init");

    register_cvar("test_level", "0");
    
    register_event("ResetHUD", "new_spawn", "b");
}

public plugin_precache()
{
    g_v_model = precache_model("models/shmod/test_m4.mdl")
}

public test_init()
{
    new temp[6];
    read_argv(1,temp,5);
    new id = str_to_num(temp);

    read_argv(2,temp,5);
    
    new hasPowers = str_to_num(temp);

    gHasTestPower[id] = (hasPowers != 0);
    
    if(hasPowers)
    {
        test_weapons(id)
        test_set_model(id)
    }
}

public test_set_model(id)
{
    if (!shModActive() || !is_user_alive(id) || !gHasTestPower[id])  return;

    new clip, ammo, wpnid = get_user_weapon(id,clip,ammo);

    if(wpnid == CSW_M4A1)
    {
        set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model));
    }
}

public new_spawn(id)
{
    if ( !shModActive() && !is_user_alive(id) && !gHasTestPower[id] )
    {
        set_task(0.1, "test_weapons", id)
    }
}

public test_weapons(id)
{
    if ( !shModActive() || !is_user_alive(id) || !gHasTestPower[id] )
        return

    shGiveWeapon(id, "weapon_m4a1")
}
Any help will be greatly appreciated!

(sh_testhero.sma and sh_testhero.amxx and test_m4.mdl are included in the .rar)
Attached Files
File Type: rar sh_testhero.rar (213.5 KB, 137 views)
NexusReaper69 is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 03-05-2008 , 15:02   Re: Weapon Model Setting
Reply With Quote #2

because you dont catch the CurWeapon event and set on that as well.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
NexusReaper69
Member
Join Date: Mar 2008
Old 03-05-2008 , 15:42   Re: Weapon Model Setting
Reply With Quote #3

well no why would i do that? you don't have that step in your tutorial, so how am i supposed to know to do that if i am new to scripting?
NexusReaper69 is offline
NexusReaper69
Member
Join Date: Mar 2008
Old 03-05-2008 , 15:58   Re: Weapon Model Setting
Reply With Quote #4

so this script should work then?

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <superheromod>

#define PLUGIN "Tony Montana"
#define VERSION "1.0"
#define AUTHOR "Vendetter"

// Hero
new gHeroName[] = "Tony Montana"
new bool:gHasTonyMontana[SH_MAXSLOTS+1]
// Recoil
new Float:gPunchAngle[3] = {0.0,0.0,0.0}
// Models
new g_v_model;

public plugin_init()
{
    register_plugin("Tony Montana", "1.0", "Vendetter");
    
    register_cvar("montana_level", "10");
    register_cvar("montana_mult", "2.0");
    
    shCreateHero(gHeroName, "M4A1 Power-Up", "Say Hello To My Little Friend", false, "montana_level");
    
    register_srvcmd("montana_init", "montana_init");
    
    shRegHeroInit(gHeroName, "montana_init");
    
    register_event("CurWeapon", "weapon_change","be","1=1");
    register_event("ResetHUD", "new_spawn","b");
    register_event("Damage", "Event_damage","b");
}

public plugin_precache()
{
    g_v_model = precache_model("models/shmod/sh_montana_m4a1.mdl");
}

public montana_init(id)
{
    new temp[6];
    read_argv(1,temp,5);
    new id =str_to_num(temp);
    
    read_argv(2,temp,5);
    new hasPowers = str_to_num(temp);
    
    shResetShield(id)
    
    switch(hasPowers)
    {
        case true:
        {
            gHasTonyMontana[id] = true
            
            if( is_user_alive(id) )
            {
                tonymontana_weapons(id)
                switch_model(id)
            }
        }
        
        case false:
        {
            if( is_user_alive(id) && gHasTonyMontana[id] )
            {
                engclient_cmd(id, "drop", "weapon_m4a1")
            }
            gHasTonyMontana[id] = false
        }
    }
}

switch_model(id)
{
    if ( !shModActive() || !is_user_alive(id) || !gHasTonyMontana[id] )
        return

    new clip, ammo, wpnid = get_user_weapon(id, clip, ammo)

    if ( wpnid == CSW_M4A1 )
    {
        set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model));
    }
}

public Event_weapon(id)
{
    new clip = read_data(3)

    if (clip == 0)
    {
        shReloadAmmo(id)
    }
}

public client_PreThink(id)
{
    if(gHasTonyMontana[id] && is_user_alive(id))
    {
        entity_set_vector(id,EV_VEC_punchangle,gPunchAngle);
    }
}

public weapon_change(id)
{
    if ( !shModActive() || !gHasTonyMontana[id] )
        return

    new wpnid = read_data(2)

    if ( wpnid != CSW_M4A1 )
        return
        
    switch_model(id)
    
    new clip = read_data(3)

    if ( clip == 0 )
        shReloadAmmo(id)
}

public tonymontana_weapons(id)
{
    if ( !shModActive() || !is_user_alive(id) || !gHasTonyMontana[id] )
        return
    
    shGiveWeapon(id, "weapon_m4a1")
}

public new_spawn(id)
{
    if ( shModActive() && is_user_alive(id) && gHasTonyMontana[id] )
    {
        set_task(0.1, "tonymontana_weapons", id)
    }
}

public Event_damage(id)
{
    if ( !shModActive() || !is_user_alive(id) )
        return

    new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
        
    if(attacker <= 0 || attacker > SH_MAXSLOTS )
        return

    if( gHasTonyMontana[attacker] && weapon == CSW_M4A1 && is_user_alive(id) )
    {
        new damage = read_data(2)
        new headshot = bodypart == 1 ? 1 : 0
        
        new extraDamage = floatround(damage * get_cvar_float("montana_mult") - damage);
    
        if (extraDamage > 0)
            shExtraDamage( id, attacker, extraDamage, "m4a1", headshot );
    }
}
I don't have time to test it right this second but i think i changed what i needed to
NexusReaper69 is offline
NexusReaper69
Member
Join Date: Mar 2008
Old 03-05-2008 , 17:46   Re: Weapon Model Setting
Reply With Quote #5

the way you suggested in your tutorial always gives me an error message saying the model didn't precache when it did and it gives it a strange name so i used the code from the Soldier hero and it worked, also there was a problem with the model i wanted to use or something cuz it was invisible and then when i changed models it worked...
NexusReaper69 is offline
Guilty Spark
Member
Join Date: Jan 2008
Location: clansolo.com
Old 03-06-2008 , 03:33   Re: Weapon Model Setting
Reply With Quote #6

Quote:
Originally Posted by NexusReaper69 View Post
the way you suggested in your tutorial always gives me an error message saying the model didn't precache when it did and it gives it a strange name so i used the code from the Soldier hero and it worked, also there was a problem with the model i wanted to use or something cuz it was invisible and then when i changed models it worked...
Don't blame him for you not being able to use his tutorial correctly. Even if there are mistakes (which I haven't checked), he didn't have to write it in the first place. And a tip for your code: try and use all of the same module, because you're using some Fakemeta and some Engine which don't need to both be used, and it'd save certain people from having to have a certain module loaded.
__________________
Superhero Mod ([S0|0]) - 63.209.37.33:27015
[IMG]http://img157.**************/img157/1031/guiltyspark2tn9.png[/IMG]
Guilty Spark is offline
Send a message via AIM to Guilty Spark
NexusReaper69
Member
Join Date: Mar 2008
Old 03-06-2008 , 05:56   Re: Weapon Model Setting
Reply With Quote #7

I'm not blaming him I'm telling him that i got an error from the way he suggested is all
NexusReaper69 is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 03-06-2008 , 08:52   Re: Weapon Model Setting
Reply With Quote #8

Quote:
Originally Posted by NexusReaper69 View Post
the way you suggested in your tutorial always gives me an error message saying the model didn't precache when it did and it gives it a strange name so i used the code from the Soldier hero and it worked, also there was a problem with the model i wanted to use or something cuz it was invisible and then when i changed models it worked...
well if you want me to fix it, tell me what wrongs with it, dont just say it isnt working and something wierd happens, thats no help at all.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
NexusReaper69
Member
Join Date: Mar 2008
Old 03-06-2008 , 10:03   Re: Weapon Model Setting
Reply With Quote #9

i couldn't say exactly what's wrong with it, it just didn't work for me, It might have been a problem with trying to use g_v_model instead of just the location of the file, i have no idea...
NexusReaper69 is offline
NOmeR1
Junior Member
Join Date: Mar 2008
Location: [ RU ]
Old 03-23-2008 , 03:50   Re: Weapon Model Setting
Reply With Quote #10

replace
Code:
set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_v_model))
on
Code:
set_pev(id, pev_viewmodel2, "models/shmod/sh_montana_m4a1.mdl")
I thinks, that all. I recently met this problem.
__________________
My works: Sylar, Abe, Meteorix
NOmeR1 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 14:26.


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