Raised This Month: $ Target: $400
 0% 

Weapons Drop Ability


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-03-2010 , 05:26   Re: Weapons Drop Ability
Reply With Quote #17

Quote:
Originally Posted by Hawk552 View Post
This seems useless to me
To me it seems the easiest/most efficient way to enable nades drop for example.

-> my plugin code :
PHP Code:
public CS_Item_CanDrop(iEnt)
{
    const 
XTRA_OFS_WEAPON 4
    
const m_iId 43

    SetHamReturnInteger
( !! (DEFAULT_CANT_DROP_BITSUM & ( 1<<get_pdata_int(iEntm_iIdXTRA_OFS_WEAPON) )) )

    return 
HAM_SUPERCEDE

-> other plugin code :
PHP Code:
public clcmd_drop(id) {
    if (!
MODE_ALIVE || !is_user_alive(id)) // if nade drops not allowed to alive players or player isn't alive
        
return PLUGIN_CONTINUE

    
new currentclipammoi
    current 
get_user_weapon(idclipammo// get id and ammo of current weapon

    
new arg[21]
    
read_argv(1arg20// get name of weapon to drop
    
if (!arg[0]) { // if weapon name isn't specified
        
if (!ammo// if no weapon ammo (usually knife)
            
return PLUGIN_CONTINUE

        
// get nade index
        
for (0NADE_TYPES; ++i) {
            if (
current == NADE_WEAPON_ID[i]) // if current weapon is nade
                
break
        }
    }
    else {
        
// check if weapon to drop is nade
        
for (0NADE_TYPES; ++i) {
            if (
equal(argNADE_WEAPON_NAME[i])) // if weapon to drop is nade
                
break
        }
    }

    if (
== NADE_TYPES// if weapon to drop isn't nade
        
return PLUGIN_CONTINUE

    
new weapon NADE_WEAPON_ID[i]
    
ammo get_pdata_int(idNADE_OFFSET_AMMO[i], OFFSET_AMMO_LINUXDIFF// get nade actual ammo
    
if (ammo 1// if no nade ammo
        
return PLUGIN_CONTINUE

    
if (g_nades_number >= MAX_NADE_ENTITIES) {
        
client_print(idprint_centerMSG_TOMANY)
        return 
PLUGIN_HANDLED
    
}

    if (!
MODE_BUY && !g_freezetime) { // is rnd_buy is 0 and currently not a freezetime
        
new Float:wait get_pcvar_float(g_pcvar_buytime) * 60 - (get_gametime() - g_round_start_time)
        if (
wait 0) { // is currently a buytime
            #if defined OBEY_BUYZONE
                
if (g_buyzone[id]) { // is player in buyzone
                    
client_print(idprint_centerMSG_BUY)
                    return 
PLUGIN_HANDLED
                
}
            
#else
                
new seconds floatround(waitfloatround_floor)
                
client_print(idprint_centerMSG_BUYseconds seconds 1)
                return 
PLUGIN_HANDLED
            
#endif
        
}
    }

    new 
nade engfunc(EngFunc_CreateNamedEntityg_ipsz_armoury_entity// create nade entity
    
if (!nade) { // if nade entity not created
        
client_print(idprint_centerMSG_ERROR// client error center text message
        
log_amx(MSG_ERROR// log error
        
return PLUGIN_HANDLED
    
}

    
g_nades_number++

    
set_pdata_int(idNADE_OFFSET_AMMO[i], --ammoOFFSET_AMMO_LINUXDIFF// reduce nade ammo over one unit
    
if (!ammo) { // no more weapon ammo
        
if (current == weapon) { // if current weapon is weapon to drop
            // CS standard-like weapon switching after drop
            
for (new 0WEAPONS; ++j) {
                if (
user_has_weapon(idWEAPON_PRIORITY[j]) && weapon != WEAPON_PRIORITY[j]) { // search for player main weapon id
                    
new wname[20// longest weapon name is "weapon_smokegrenade" (19 characters long)
                    
get_weaponname(WEAPON_PRIORITY[j], wname19// get name of player main weapon
                    
engclient_cmd(idwname// switch player to his main weapon
                    
break
                }
            }
        }
        else {
            
// this is necessary to strip nade properly
            
engclient_cmd(idNADE_WEAPON_NAME[i]) // switch to nade
            
engclient_cmd(idg_lastinv// switch to previous weapon
        
}
    }

    
set_nade_kvd(nadeg_itemNADE_ITEM_ID[i]) // set nade item type

    
set_pev(nadepev_classnameNADE_NAME// set nade unique classname

    // setup nade start origin
    
new Float:origin[3]
    
pev(idpev_originorigin)
    
engfunc(EngFunc_SetOriginnadeorigin)

    
// setup nade angles
    
new Float:angles[3]
    
pev(idpev_anglesangles)
    
angles[0] = 0.0 // we don't need specific vertical angle
    
angles[1] += NADE_PLR_DIFF_ANGLE_HOR
    set_pev
(nadepev_anglesangles)

    
// setup nade velocity
    
new Float:anglevec[3], Float:velocity[3]
    
pev(idpev_v_angleanglevec)
    
engfunc(EngFunc_MakeVectorsanglevec)
    
global_get(glb_v_forwardanglevec)
    
velocity[0] = anglevec[0] * NADE_VELOCITY
    velocity
[1] = anglevec[1] * NADE_VELOCITY
    velocity
[2] = anglevec[2] * NADE_VELOCITY
    set_pev
(nadepev_velocityvelocity)

    
dllfunc(DLLFunc_Spawnnade// spawn nade

    
return PLUGIN_HANDLED

Quote:
Originally Posted by Hawk552 View Post
if it was anyone else who posted it, I would approve it
You meant unapprove ?

Quote:
Originally Posted by Hawk552 View Post
This plugin is well done.
Thanks

Quote:
Originally Posted by Hawk552 View Post
If you would like any information regarding possible adjustments you could make or things you could do to make this better, please feel free to post here or PM me.
Sure i would like.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-03-2010 at 05:42.
ConnorMcLeod is offline
 



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 19:48.


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