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

new bomb script help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SAMURAI16
BANNED
Join Date: Sep 2006
Old 03-04-2007 , 19:27   new bomb script help
Reply With Quote #1

Hi guys,
I need some help on this code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <cstrike>
#include <fakemeta_util>
#include <fun>

#define PLUGIN "Molotov Cocktail"
#define VERSION "1.0"
#define AUTHOR "SAMURAI"

new pnumpluginppricepMldamagepMlradius
new g_hasMolotov[33];
new 
g_active[33];

new 
g_restarted
new firespr;
new 
g_MaxPlayers

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
    
register_clcmd("say /molotov","buy_molotov",0)
    
register_clcmd("say molotov","buy_molotov",0)
    
    
pnumplugin register_cvar("molotov_cocktail","1")
    
pprice register_cvar("molotov_price","1200")
    
pMldamage register_cvar("molotov_damage","520.0");
    
pMlradius register_cvar("molotov_radius","240.0");
    
    
    
// EVENTS
    
register_event("CurWeapon""Event_CurWeapon","be""1=1")
    
register_event("HLTV","event_new_round""a","1=0""2=0")
    
register_event("TextMsg","Event_GameRestart","a","2=#Game_Commencing","2=#Game_will_restart_in")
    
    
register_forward(FM_SetModel,"fw_setmodel");
    
g_MaxPlayers get_maxplayers()

    
}

public 
buy_molotov(id)
{
    if(!
get_pcvar_num(pnumplugin))
    return 
PLUGIN_CONTINUE;
    
    if(!
is_user_alive(id))
    {
        
client_print(id,print_center,"You can't buy Molotov Cocktail because you are dead !");
        return 
PLUGIN_HANDLED;
    }
    
    if(!
cs_get_user_buyzone(id))
    {
        
client_print(id,print_center,"You are not in the BuyZone target !");
        return 
PLUGIN_HANDLED;
    }
    
    
    new 
money cs_get_user_money(id)
    
    if(
money get_pcvar_num(pprice))
    {
        
client_print(id,print_center,"Your don't have enough $ to buy a Molotov Cocktail");
        return 
PLUGIN_HANDLED;
    }
    
    
    
    if(
g_hasMolotov[id])
    {
        
client_print(id,print_center,"You alearly have a Molotov Cocktail");
        return 
PLUGIN_HANDLED;
    }
    
        
    new 
temp[2], weaponID get_user_weapon(idtemp[0], temp[1])
    if(
weaponID == CSW_HEGRENADE
    {
        
g_active[id] = true
        set_molotov_model
(id)
    }
    
    
    
    
g_hasMolotov[id] = 1
    
    cs_set_user_money
(id,money get_pcvar_num(pprice))
    
give_item(id,"weapon_hegrenade")
    
client_print(id,print_chat,"You got a Molotov Cocktail !");
    
    return 
PLUGIN_HANDLED;
}

public 
set_molotov_model(id)
{
    
entity_set_string(idEV_SZ_viewmodel"models/v_molotov.mdl")
    
entity_set_string(idEV_SZ_weaponmodel"models/p_molotov.mdl")
    
entity_set_model(id,"models/w_molotov.mdl")
}
    
public 
set_hegren_model(id)
{
    
entity_set_string(idEV_SZ_viewmodel"models/v_hegrenade.mdl")
    
entity_set_string(idEV_SZ_weaponmodel"models/p_hegrenade.mdl")    
    
entity_set_model(id,"models/w_hegrenade.mdl")
}
    
public 
plugin_precache()
{
    
precache_model("models/v_molotov.mdl")
    
precache_model("models/p_molotov.mdl")
    
precache_model("models/w_molotov.mdl")
    
firespr precache_model("sprites/fire.spr");
}
    
public 
Event_CurWeapon(id)
{
    if(!
is_user_alive(id) || !g_hasMolotov[id]) 
    return 
PLUGIN_CONTINUE
    
    
new WeaponID read_data(2)
    switch(
WeaponID
    {
        case 
CSW_HEGRENADE:
        {
            
set_task(0.3"task_activemolotov"id)
            
set_molotov_model(id)
            
entity_set_int(idEV_INT_weaponanim9)
        }
        default: 
g_active[id] = 0
    
}
    return 
PLUGIN_CONTINUE
}

public 
task_activemolotov(id
{
    if(!
is_user_connected(id) || !is_user_alive(id))
    return 
PLUGIN_CONTINUE
    
    
new temp[2], weaponID get_user_weapon(idtemp[0], temp[1])
    if(
weaponID == CSW_HEGRENADEg_active[id] = 1
        
    
return PLUGIN_CONTINUE;
}
    
public 
Event_GameRestart() 
{
    
g_restarted 1
}    

public 
event_new_round() 
{
    if(
g_restarted)
    {
        new 
Players[32], iNum 0
        get_players
(PlayersiNum)
        for(new 
0iNumi++) 
        {
            new 
id Players[i]
    
            
g_active[id] = 0
            g_hasMolotov
[id] = 0
    
            
new temp[2], weaponID get_user_weapon(idtemp[0], temp[1])
            if(
weaponID == CSW_HEGRENADEset_hegren_model(id)
            
            
g_restarted 0
        
}
    }
    
    new 
molotovs = -1
    
while((molotovs find_ent_by_class(molotovs"molotov")))
        
remove_entity(molotovs)
    
    
}


public 
fw_setmodel(entmodel[])
{
    if(
get_pcvar_num(pnumplugin) == || !is_valid_ent(ent))
    return 
FMRES_IGNORED;
    
    if(!
equali(model,"models/w_molotov.mdl"))
    return 
FMRES_IGNORED;
    
    new 
owner entity_get_edict(ent,EV_ENT_owner);
    
    if(!
g_hasMolotov[owner])
    return 
FMRES_IGNORED;
    
    
set_task(1.5,"grenade_explode",ent);
    
    return 
FMRES_IGNORED;
}

public 
grenade_explode(ent)
{
    if(
get_pcvar_num(pnumplugin) == || !is_valid_ent(ent))
    return 
PLUGIN_CONTINUE;
    
    new 
Float:origin[3];
    
pev(ent,pev_origin,origin);
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(17);
    
write_coord(floatround(origin[0])); // coord, coord, coord (position)
    
write_coord(floatround(origin[1]));
    
write_coord(floatround(origin[2]));
    
write_short(firespr); // short (sprite index)
    
write_byte(20); // byte (scale in 0.1's)
    
write_byte(200); // byte (brightness)
    
message_end();
    
    
molotov_damage(origin"hegrenade"get_pcvar_float(pMldamage), get_pcvar_float(pMlradius)) 
    
    return 
PLUGIN_CONTINUE;
}

public 
molotov_damage(Float:origin[3], const classname[], Float:damageFloat:range
{
      
    new 
Float:pOrigin[3]
    new 
Float:dist
    
new Float:tmpdmg
    
    
for(new 1<= g_MaxPlayersi++) {
        if(
is_user_alive(i) ) {
            
pev(i,pev_origin,pOrigin)
            
dist get_distance_f(origin,pOrigin)
            
            if(
dist <= range) {
                
tmpdmg damage-(damage/range)*dist
                fm_fakedamage
(iclassnametmpdmgDMG_BLAST)
            }
        }
    }


What doesen't works:
1) If i use "say /molotov" the hegren will became molotov, but i want if i don't use "molotov" again to don't be molotov
2) Use used a condition to check if alearly have molotov, but i want to check if have alealy bought. So if have bought one and drop one, to can buy another
3) Molotov doesen't make fire effects on impact. It's like a HeGrenade.

Please fix that bugs. Thanks
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
Ryu2877
Member
Join Date: Sep 2006
Location: China
Old 03-04-2007 , 22:34   Re: new bomb script help
Reply With Quote #2

Quote:
entity_set_model(id,"models/w_molotov.mdl")
in this case, id must be the grenade entity index, not a player index.
Ryu2877 is offline
Ryu2877
Member
Join Date: Sep 2006
Location: China
Old 03-04-2007 , 22:45   Re: new bomb script help
Reply With Quote #3

Quote:
if(!equali(model,"models/w_molotov.mdl"))
when player throw a hegrenade, engine generally use default model, so you must use "models/w_hegrenade.mdl" to hook it. And then check the owner status & something other etc.
Ryu2877 is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 03-04-2007 , 23:44   Re: new bomb script help
Reply With Quote #4

I tryed to change from !equali(mode,"models/w_molotov.mdl") with w_hegrenade.mdl but dosen't works
Also for this bugs have an ideia ?
Quote:
1) If i use "say /molotov" the hegren will became molotov, but i want if i don't use "molotov" again to don't be molotov
2) Use used a condition to check if alearly have molotov, but i want to check if have alealy bought. So if have bought one and drop one, to can buy another
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
Oskar
BANNED
Join Date: Jan 2007
Location: Slöinge, Falkenberg, Hal
Old 03-05-2007 , 05:53   Re: new bomb script help
Reply With Quote #5

Shouldn't it be "equal"?
Oskar is offline
Send a message via MSN to Oskar
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-05-2007 , 17:49   Re: new bomb script help
Reply With Quote #6

Quote:
Originally Posted by Oskar View Post
Shouldn't it be "equal"?
It would make almost no difference.
[ --<-@ ] Black Rose is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 03-06-2007 , 06:08   Re: new bomb script help
Reply With Quote #7

i solved anyway
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
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 18:07.


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