Quote:
Originally Posted by Hawk552
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(iEnt, m_iId, XTRA_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 current, clip, ammo, i
current = get_user_weapon(id, clip, ammo) // get id and ammo of current weapon
new arg[21]
read_argv(1, arg, 20) // 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 (i = 0; i < NADE_TYPES; ++i) {
if (current == NADE_WEAPON_ID[i]) // if current weapon is nade
break
}
}
else {
// check if weapon to drop is nade
for (i = 0; i < NADE_TYPES; ++i) {
if (equal(arg, NADE_WEAPON_NAME[i])) // if weapon to drop is nade
break
}
}
if (i == NADE_TYPES) // if weapon to drop isn't nade
return PLUGIN_CONTINUE
new weapon = NADE_WEAPON_ID[i]
ammo = get_pdata_int(id, NADE_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(id, print_center, MSG_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(id, print_center, MSG_BUY)
return PLUGIN_HANDLED
}
#else
new seconds = floatround(wait, floatround_floor)
client_print(id, print_center, MSG_BUY, seconds ? seconds : 1)
return PLUGIN_HANDLED
#endif
}
}
new nade = engfunc(EngFunc_CreateNamedEntity, g_ipsz_armoury_entity) // create nade entity
if (!nade) { // if nade entity not created
client_print(id, print_center, MSG_ERROR) // client error center text message
log_amx(MSG_ERROR) // log error
return PLUGIN_HANDLED
}
g_nades_number++
set_pdata_int(id, NADE_OFFSET_AMMO[i], --ammo, OFFSET_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 j = 0; j < WEAPONS; ++j) {
if (user_has_weapon(id, WEAPON_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], wname, 19) // get name of player main weapon
engclient_cmd(id, wname) // switch player to his main weapon
break
}
}
}
else {
// this is necessary to strip nade properly
engclient_cmd(id, NADE_WEAPON_NAME[i]) // switch to nade
engclient_cmd(id, g_lastinv) // switch to previous weapon
}
}
set_nade_kvd(nade, g_item, NADE_ITEM_ID[i]) // set nade item type
set_pev(nade, pev_classname, NADE_NAME) // set nade unique classname
// setup nade start origin
new Float:origin[3]
pev(id, pev_origin, origin)
engfunc(EngFunc_SetOrigin, nade, origin)
// setup nade angles
new Float:angles[3]
pev(id, pev_angles, angles)
angles[0] = 0.0 // we don't need specific vertical angle
angles[1] += NADE_PLR_DIFF_ANGLE_HOR
set_pev(nade, pev_angles, angles)
// setup nade velocity
new Float:anglevec[3], Float:velocity[3]
pev(id, pev_v_angle, anglevec)
engfunc(EngFunc_MakeVectors, anglevec)
global_get(glb_v_forward, anglevec)
velocity[0] = anglevec[0] * NADE_VELOCITY
velocity[1] = anglevec[1] * NADE_VELOCITY
velocity[2] = anglevec[2] * NADE_VELOCITY
set_pev(nade, pev_velocity, velocity)
dllfunc(DLLFunc_Spawn, nade) // spawn nade
return PLUGIN_HANDLED
}
Quote:
Originally Posted by Hawk552
if it was anyone else who posted it, I would approve it
|
You meant
unapprove ?
Quote:
Originally Posted by Hawk552
This plugin is well done.
|
Thanks
Quote:
Originally Posted by Hawk552
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.
__________________