Raised This Month: $ Target: $400
 0% 

Ballistic knife new*


Post New Thread Reply   
 
Thread Tools Display Modes
Linkin Hisoka
Senior Member
Join Date: Sep 2014
Location: Morocco, Marrakesh
Old 01-24-2015 , 10:21   Re: [Plugin] Ballistic knife new*
Reply With Quote #11

that code is nicely ^^ i love it
__________________
Moroccan and proud
Linkin Hisoka is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-25-2015 , 06:39   Re: [Plugin] Ballistic knife new*
Reply With Quote #12

CmdStart is not as good as Jhob said.
  • Sometimes static, sometimes new. In such forward static is better.
  • Returning PLUGIN_HANDLED is dumb, use FMRES_ return types.
  • Striping all user weapons seems an unwanted bug.
  • Same story for PLUGIN_CONTINUE as for PLUGIN_HANDLED.
  • This check
    PHP Code:
      else if(is_user_alive (id) && !g_Block[id]) 
    make no sens, why you need to check again if it's alive when you already do that some lines above ?

The other parts:
  • const Hex_Value = 0x21 just to make it to "look better" in your opinion or why ? You kill the ability of beginners to fully understanding your code.
  • Stick to just one coding style. If you capitalize some of your vars, do that with all of them.
  • Storing cvars into an array doesn't give any advantages, it's good only if you are going to loop and cache them. Now it's not wrong, but not in any way better.
  • Again, strip only the knife, not all of his weapons.
  • g_Remplace: isn't Remplace a french word ? Just curious.
  • In Ballistic_knife check if the user is alive.
  • PHP Code:
     (get_pcvar_float(Cvar_stock[0]) > 1) ? ExecuteHam(Ham_TakeDamageVictimididDamageDMG_NERVEGAS) : death_message(idVictim1"weapon_knife"
    coding in just one line. Readability is gone.....
  • Cache get_user_msgid("ScoreInfo").
  • Use Ham_Item_Deploy for setting models, not CurWeapon event.
  • Instead of checking to times if he has knife in his hands, check just one time.
__________________

Last edited by HamletEagle; 01-25-2015 at 06:40.
HamletEagle is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-25-2015 , 08:09   Re: [Plugin] Ballistic knife new*
Reply With Quote #13

Quote:
Originally Posted by HamletEagle View Post
CmdStart is not as good as Jhob said.
  • Sometimes static, sometimes new. In such forward static is better.
  • Returning PLUGIN_HANDLED is dumb, use FMRES_ return types.
  • Striping all user weapons seems an unwanted bug.
  • Same story for PLUGIN_CONTINUE as for PLUGIN_HANDLED.
  • This check
    PHP Code:
      else if(is_user_alive (id) && !g_Block[id]) 
    make no sens, why you need to check again if it's alive when you already do that some lines above ?

The other parts:
  • const Hex_Value = 0x21 just to make it to "look better" in your opinion or why ? You kill the ability of beginners to fully understanding your code.
  • Stick to just one coding style. If you capitalize some of your vars, do that with all of them.
  • Storing cvars into an array doesn't give any advantages, it's good only if you are going to loop and cache them. Now it's not wrong, but not in any way better.
  • Again, strip only the knife, not all of his weapons.
  • g_Remplace: isn't Remplace a french word ? Just curious.
  • In Ballistic_knife check if the user is alive.
  • PHP Code:
     (get_pcvar_float(Cvar_stock[0]) > 1) ? ExecuteHam(Ham_TakeDamageVictimididDamageDMG_NERVEGAS) : death_message(idVictim1"weapon_knife"
    coding in just one line. Readability is gone.....
  • Cache get_user_msgid("ScoreInfo").
  • Use Ham_Item_Deploy for setting models, not CurWeapon event.
  • Instead of checking to times if he has knife in his hands, check just one time.
I didnt said it was good, i said it wasnt as bad as curweapon method to change model. My point was to show that he hasn't done it by himself.
__________________
Jhob94 is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-26-2015 , 09:20   Re: [Plugin] Ballistic knife new*
Reply With Quote #14

Didn't test it

PHP Code:
#include <amxmodx> 
#include <cstrike> 
#include <engine> 
#include <fun> 
#include <colorchat> 
#include <hamsandwich> 
#include <fakemeta_util> 

#define MAXPLAYERS 32
#define OFFSET_PRIMARYWEAPON 116


new const Model_Ballistic[] = "models/v_Ballistic_knife.mdl" 
new const Model_Replace[] = "models/v_knife_Replace.mdl" 

new bool:g_Ballistic[MAXPLAYERS 1], bool:has_rest[MAXPLAYERS 1], bool:g_Replace[MAXPLAYERS 1
new 
Ammo[MAXPLAYERS 1], g_Block[MAXPLAYERS 1


new 
Cvar_stock[3// damage = 0 | ammo = 1 | rest = 2 
new beamSpr 
new g_ScoreInfo


public plugin_precache() {
    
precache_model(Model_Ballistic)     
    
precache_model(Model_Replace
    
beamSpr precache_model("sprites/dot.spr"


public 
plugin_init() 

    
register_plugin("Ballistic knife (fixed)","1.0.3","Medox* / Spawner"
    
    
register_clcmd("say /Ballistic","Ballistic_knife"
    
    
Cvar_stock[0] = register_cvar("ballistic_damage""100"
    
Cvar_stock[1] = register_cvar("ballistic_ammo""5"
    
Cvar_stock[2] = register_cvar("ballistic_rest""0.1"
    
    
g_ScoreInfo get_user_msgid("ScoreInfo")
    
    
register_forward(FM_CmdStart"CmdStart"
    
    
    
RegisterHam(Ham_Item_Deploy"weapon_knife""knife_ham"1
    
RegisterHam(Ham_Spawn"player""fw_spawn"1
    
    


public 
client_connect(id)      
    
Bool_off(id

public 
fw_spawn(id

    
Bool_off(id)     
    
strip_player_weap(id)


public 
Ballistic_knife(id

    
g_Replace[id] = false 
    g_Ballistic
[id] = true 
    g_Block
[id] = true 
    Ammo
[id] = get_pcvar_num(Cvar_stock[1]) 
    
    
ColorChat(idGREEN"^4[Knife] ^1You are get Ballistic knife^4 5 ^1Ammo for shoter ^4!")     


public 
CmdStart(iduc_handleseed
{     
    if(
is_user_alive(id)) 
    { 
        static 
CurButton 
        CurButton 
get_uc(uc_handleUC_Buttons
        new 
Float:flNextAttack get_pdata_float(id835
        
        if(
CurButton IN_ATTACK2)  
        {  
            if(
g_Block[id] && !has_rest[id])  
            {                 
                
cmd_shote(id
                
set_task(get_pcvar_float(Cvar_stock[2]), "reset_cmd"id
                
has_rest[id] = true                     
                
                
if(Ammo[id] > 0  && flNextAttack <= 0.0
                {             
                    
set_hudmessage(01272550.010.8506.01.0
                    
show_hudmessage(id"Remaining Ammo: %d "Ammo[id]) 
                }         
                else 
                {     
                    
strip_player_weap(id)
                    
g_Ballistic[id] = false 
                    g_Block
[id] = false 
                    g_Replace
[id] = true 
                    ColorChat
(idGREEN"^4[Knife] ^1You are not Ammo. you get Replace Ballistic knife ^4!"
                }     
                
Ammo[id] -= 
                
                CurButton 
&= ~IN_ATTACK2 
                set_uc
(uc_handleUC_ButtonsCurButton)                 
            }                     
        }      
    } 
    return 
FMRES_IGNORED
}


// Cmd Shote ---- > 
public cmd_shote(id)  

    static 
VictimBodyEndOrigin[3], BeamOrigin[3
    
get_user_origin(idBeamOrigin3
    
get_user_origin(idEndOrigin3
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY
    
write_byte(TE_BEAMENTPOINT
    
write_short(id 0x1000
    
write_coord(BeamOrigin[0])    // Start X 
    
write_coord(BeamOrigin[1])    // Start Y 
    
write_coord(BeamOrigin[2])    // Start Z 
    
write_short(beamSpr)             // Sprite 
    
write_byte(1)              // Start frame                 
    
write_byte(1)             // Frame rate                     
    
write_byte(1)            // Life 
    
write_byte(25)           // Line width         
    
write_byte(0)            // Noise 
    
write_byte(190)         // Red 
    
write_byte(190)                 // Green 
    
write_byte(190)                 // Blue 
    
write_byte(150)            // Brightness                     
    
write_byte(25)              // Scroll speed                     
    
message_end()         
    
    
get_user_aiming(idVictimBody999999
    if(
is_user_connected(Victim))  
    { 
        new 
Float:Damage floatget_damage_body(Bodyget_pcvar_float(Cvar_stock[0])) ) 
        
        new 
Float:VictimOrigin[3]; 
        
VictimOrigin[0] = float(EndOrigin[0]) 
        
VictimOrigin[1] = float(EndOrigin[1]) 
        
VictimOrigin[2] = float(EndOrigin[2]) 
        

        if(
get_pcvar_float(Cvar_stock[0]) >= 1)
            
ExecuteHam(Ham_TakeDamageVictimididDamageDMG_NERVEGAS)
        else if(
get_pcvar_float(Cvar_stock[0]) < 1)
            
death_message(idVictim1"weapon_knife")     
            
    } 
    else  
    { 
        static 
ClassName[32
        
pev(Victimpev_classnameClassNamecharsmax(ClassName)) 
        if(
equal(ClassName"func_breakable"))  
        {         
            if(
entity_get_float(VictimEV_FL_health) <= get_pcvar_num(Cvar_stock[0]))  
            { 
                
force_use(idVictim
            } 
        } 
    } 


public 
strip_player_weap(id){
    
    
strip_user_weapons(id)
    
set_pdata_int(idOFFSET_PRIMARYWEAPON0)
    
give_item(id"weapon_knife")
    
}
public 
reset_cmd(id
    
has_rest[id] = false 
// Cmd Shote ---- < 

// Stock ---- > 
stock death_message(KillerVictimScoreBoard, const Weapon[])  

    
// Block death msg 
    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET
    
ExecuteHamB(Ham_KilledVictimKiller2
    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT
    
    
// Death 
    
make_deathmsg(KillerVictim0Weapon
    
cs_set_user_money(Killercs_get_user_money(Killer) + 3000
    
    
// Update score board 
    
if(ScoreBoard)  
    { 
        
        
message_begin(MSG_BROADCASTg_ScoreInfo
        
write_byte(Killer// id 
        
write_short(pev(Killerpev_frags)) // frags 
        
write_short(cs_get_user_deaths(Killer)) // deaths 
        
write_short(0// class? 
        
write_short(get_user_team(Killer)) // team 
        
message_end() 
        
        
message_begin(MSG_BROADCASTg_ScoreInfo
        
write_byte(Victim// id 
        
write_short(pev(Victimpev_frags)) // frags 
        
write_short(cs_get_user_deaths(Victim)) // deaths 
        
write_short(0// class? 
        
write_short(get_user_team(Victim)) // team 
        
message_end() 
    } 


stock get_damage_body(bodyFloat:damage)  

    switch(
body)  
    { 
        case 
HIT_HEADdamage *= 4.0 
            
case HIT_STOMACHdamage *= 1.1 
            
case HIT_CHESTdamage *= 1.5 
            
case HIT_LEFTARMdamage *= 0.77 
            
case HIT_RIGHTARMdamage *= 0.77 
            
case HIT_LEFTLEGdamage *= 0.75 
            
case HIT_RIGHTLEGdamage *= 0.75 
            
default: damage *= 1.0 
    

    return 
floatround(damage


stock Bool_off(index

    
g_Ballistic[index] = false 
    Ammo
[index] = false 
    g_Block
[index] = false 
    g_Replace
[index] = false 

// Stock ---- < 

// Ham ---- > 
public knife_ham(id

    if(
g_Ballistic[id]) 
        
set_pev(idpev_viewmodel2Model_Ballistic)     
    else if(
g_Replace[id]) 
        
set_pev(idpev_viewmodel2Model_Replace)        

Freezo Begin is offline
Skuduriukas
Junior Member
Join Date: Jan 2015
Old 01-26-2015 , 12:40   Re: [Plugin] Ballistic knife new*
Reply With Quote #15

Quote:
Plugin failed to compile! Please try contacting the author.
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/home/forums/content/files/2/5/3/5/7/4/141737.attach(7) : fatal error 100: cannot read from file: "Colorchat"

Compilation aborted.
1 Error.
Skuduriukas is offline
joshknifer
Veteran Member
Join Date: Jun 2011
Location: Denver, CO
Old 01-26-2015 , 17:10   Re: [Plugin] Ballistic knife new*
Reply With Quote #16

You have to have the colorchat.inc and compile locally.
__________________
joshknifer is offline
Send a message via Skype™ to joshknifer
Skuduriukas
Junior Member
Join Date: Jan 2015
Old 01-27-2015 , 01:08   Re: [Plugin] Ballistic knife new*
Reply With Quote #17

i mean i get this error when trying to download files

Last edited by Skuduriukas; 01-27-2015 at 01:41.
Skuduriukas is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-27-2015 , 04:12   Re: [Plugin] Ballistic knife new*
Reply With Quote #18

You must compile it in your computer
__________________
Jhob94 is offline
Skuduriukas
Junior Member
Join Date: Jan 2015
Old 01-27-2015 , 04:42   Re: [Plugin] Ballistic knife new*
Reply With Quote #19

Quote:
Originally Posted by Jhob94 View Post
You must compile it in your computer
how to do that?
Skuduriukas is offline
joshknifer
Veteran Member
Join Date: Jun 2011
Location: Denver, CO
Old 01-27-2015 , 12:15   Re: [Plugin] Ballistic knife new*
Reply With Quote #20

https://forums.alliedmods.net/showthread.php?t=130511
__________________
joshknifer is offline
Send a message via Skype™ to joshknifer
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 20:40.


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