AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Strip weapon (https://forums.alliedmods.net/showthread.php?t=92602)

ƒa†es™ 05-17-2009 07:14

Strip weapon
 
Does anyone know how add the strip weapon code / Drop weapon when purchase an item, because i want it to have knife only ?

Here is the code :

PHP Code:

/*================================================================================
 
    -----------------------------------
    -*- [ZP] Extra Item : Spartan -*-
    -----------------------------------
 
    ~~~~~~~~~~~~~~~
    - Description -
    ~~~~~~~~~~~~~~~
 
    A Spartan has Multipy Damage x10000.
 
================================================================================*/
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <hamsandwich>
#define is_valid_player(%1) (1 <= %1 <= 32)
new g_itemidpcvar_dmgmultiplier
new bool:g_Hasspartan[33]
const 
Wep_knife = ((1<<CSW_KNIFE))
public 
plugin_init()
{
        
register_plugin("[ZP] Extra: Spartan ( Multipy Damage x10000 )""1.0""ƒa†es™")
 
g_itemid zp_register_extra_item("Spartan ( Multipy Damage x10000 )"0ZP_TEAM_HUMAN)
 
pcvar_dmgmultiplier register_cvar("zp_awp_dmg_multiplier""10000")
 
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
 
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
 
register_event("HLTV","new_round""a","1=0""2=0")
 
register_forward(FM_ClientConnect"client_connect")
 
register_forward(FM_ClientDisconnect"client_disconnect")
}
public 
new_round()
{
 for(new 
032i++)
 {
  
g_Hasspartan[i] = false
 
}
}
public 
client_connect(id)
{
 
g_Hasspartan[id] = false
}
public 
client_disconnect(id)
{
 
g_Hasspartan[id] = false
}
public 
Death()
{
 
g_Hasspartan[read_data(2)] = false
}
public 
fwHamPlayerSpawnPost(id)
{
 
g_Hasspartan[id] = false
}
public 
zp_user_infected_post(id)
{
 if (
zp_get_user_zombie(id))
 {
  
g_Hasspartan[id] = false
 
}
}
 
public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if ( 
is_valid_playerattacker ) && get_user_weapon(attacker) == CSW_KNIFE && g_Hasspartan[attacker] )
    {
        
SetHamParamFloat(4damage get_pcvar_floatpcvar_dmgmultiplier ) )
    }
}
public 
zp_extra_item_selected(iditemid)
{
 if ( 
itemid == g_itemid )
 {
  if ( 
user_has_weapon(idCSW_KNIFE) )
  {
   
drop_prim(id)
  }
 
  
fm_give_item(id"weapon_knife")
                
set_pev(idpev_armorvaluefloat(pev(idpev_armorvalue)) + 1500.0)
                
set_pev(idpev_healthfloat(pev(idpev_health)) + 1500.0)
                
set_pev(idpev_gravityfloat(pev(idpev_gravity)) + 0.7)
                
fm_user_rendering(idkRenderFxGlowShell22500kRenderNormal16)
  
client_print(idprint_chat"[ZP] You has bought Spartan")
  
g_Hasspartan[id] = true;
 }
}
stock drop_prim(id
{
 new 
weapons[32], num
 get_user_weapons
(idweaponsnum)
 for (new 
0numi++) {
  if (
Wep_knife & (1<<weapons[i])) 
  {
   static 
wname[32]
   
get_weaponname(weapons[i], wnamesizeof wname 1)
   
engclient_cmd(id"drop"wname)
  }
 }
}
stock fm_give_item(id, const item[])
{
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent)) return;
 
    static 
Float:originF[3]
    
pev(idpev_originoriginF)
    
set_pev(entpev_originoriginF)
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
    
dllfunc(DLLFunc_Spawnent)
 
    static 
save
    save 
pev(entpev_solid)
    
dllfunc(DLLFunc_Touchentid)
    if (
pev(entpev_solid) != save)
        return;
 
    
engfunc(EngFunc_RemoveEntityent)
}
stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16) {
 new 
Float:RenderColor[3];
 
RenderColor[0] = float(r);
 
RenderColor[1] = float(g);
 
RenderColor[2] = float(b);
 
set_pev(entitypev_renderfxfx);
 
set_pev(entitypev_rendercolorRenderColor);
 
set_pev(entitypev_rendermoderender);
 
set_pev(entitypev_renderamtfloat(amount));
 return 
1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
*/ 


xbatista 05-17-2009 07:26

Re: Strip weapon
 
http://www.amxmodx.org/funcwiki.php?...pons&go=search
Strip user weapons before giving knife

ƒa†es™ 05-17-2009 22:23

Re: Strip weapon
 
Thanks but is there any stock to prevent using Fun modules ?

Question 2 : I do set that when player strip the weapon and prevent it from taking it back ?

xbatista 05-18-2009 02:08

Re: Strip weapon
 
strip_user_weapons (fun module) is more efficent than (fakemeta) this :
PHP Code:

stock fm_strip_user_weapons(index
{
    static 
entent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
    if(!
pev_valid(ent)) return 0
    
    dllfunc
(DLLFunc_Spawnent)
    
dllfunc(DLLFunc_Useentindex)
    
engfunc(EngFunc_RemoveEntityent)
    
    return 
1


Second question missunderstood :)

ƒa†es™ 05-18-2009 02:42

Re: Strip weapon
 
Quote:

Originally Posted by xbatista (Post 829703)
strip_user_weapons (fun module) is more efficent than (fakemeta) this :
PHP Code:

stock fm_strip_user_weapons(index
{
    static 
entent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
    if(!
pev_valid(ent)) return 0
 
    dllfunc
(DLLFunc_Spawnent)
    
dllfunc(DLLFunc_Useentindex)
    
engfunc(EngFunc_RemoveEntityent)
 
    return 
1


Second question missunderstood :)


Thanks but still need to include Fun but anyway you know how to add question 2 ?

One 05-18-2009 02:54

Re: Strip weapon
 
u wanna ham? ham is much much better.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new g_iFhKeyValue

public plugin_precache()
{
    new 
iEnt

    iEnt 
engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "player_weaponstrip" ) )
    
SetKeyValue(iEnt"origin""9999 9999 9999""player_weaponstrip")
    
SetKeyValue(iEnt"targetname""stripper""player_weaponstrip")
    
dllfunc(DLLFunc_SpawniEnt)

    
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "game_player_equip" ) )
    
SetKeyValue(iEnt"weapon_knife""1""game_player_equip")
    
SetKeyValue(iEnt"targetname""equipment""game_player_equip")
    
dllfunc(DLLFunc_SpawniEnt)

    
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "multi_manager" ) )
    
SetKeyValue(iEnt"stripper""0""multi_manager")
    
SetKeyValue(iEnt"equipment""1""multi_manager")
    
SetKeyValue(iEnt"targetname""game_playerspawn""multi_manager")
    
SetKeyValue(iEnt"spawnflags""1""multi_manager")
    
dllfunc(DLLFunc_SpawniEnt)

    
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "info_map_parameters" ) )
    
SetKeyValue(iEnt"buying""3""info_map_parameters")
    
dllfunc(DLLFunc_SpawniEnt)

    
g_iFhKeyValue register_forward(FM_KeyValue"KeyValue")
}

SetKeyValue(iEnt, const szKey[], const szValue[], const szClassName[])
{
    
set_kvd(0KV_ClassNameszClassName)
    
set_kvd(0KV_KeyNameszKey)
    
set_kvd(0KV_ValueszValue)
    
set_kvd(0KV_fHandled0)
    
dllfunc(DLLFunc_KeyValueiEnt0)
}

public 
KeyValue(iEntkvd_handle)
{
    if( 
pev_valid(iEnt) )
    {
        static 
szClassName[20]
        
get_kvd(kvd_handleKV_ClassNameszClassNamecharsmax(szClassName))
        if(    
equal(szClassName"game_player_equip")
        ||    
equal(szClassName"info_map_parameters")
        ||    
equal(szClassName"player_weaponstrip")    )
        {
            
engfuncEngFunc_RemoveEntityiEnt )
            return 
FMRES_SUPERCEDE
        
}
    }
    return 
FMRES_IGNORED
}

public 
plugin_init()
{
    
unregister_forward(FM_KeyValueg_iFhKeyValue)
    
set_cvar_float("sv_restart"1.0)

    
register_plugin("strips""1""AUTHOR")

    
pause("ad")


for 2. u can remove weapons on ground after x sec.

by this code, player willbe stripped & drops nothing. so player cant buy, cant peak anyweapons. but maybe the weapons on map like aim_ak-colt

ƒa†es™ 05-18-2009 05:21

Re: Strip weapon
 
Quote:

Originally Posted by One (Post 829725)
u wanna ham? ham is much much better.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
new g_iFhKeyValue
 
public plugin_precache()
{
    new 
iEnt
 
    iEnt 
engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "player_weaponstrip" ) )
    
SetKeyValue(iEnt"origin""9999 9999 9999""player_weaponstrip")
    
SetKeyValue(iEnt"targetname""stripper""player_weaponstrip")
    
dllfunc(DLLFunc_SpawniEnt)
 
    
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "game_player_equip" ) )
    
SetKeyValue(iEnt"weapon_knife""1""game_player_equip")
    
SetKeyValue(iEnt"targetname""equipment""game_player_equip")
    
dllfunc(DLLFunc_SpawniEnt)
 
    
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "multi_manager" ) )
    
SetKeyValue(iEnt"stripper""0""multi_manager")
    
SetKeyValue(iEnt"equipment""1""multi_manager")
    
SetKeyValue(iEnt"targetname""game_playerspawn""multi_manager")
    
SetKeyValue(iEnt"spawnflags""1""multi_manager")
    
dllfunc(DLLFunc_SpawniEnt)
 
    
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString "info_map_parameters" ) )
    
SetKeyValue(iEnt"buying""3""info_map_parameters")
    
dllfunc(DLLFunc_SpawniEnt)
 
    
g_iFhKeyValue register_forward(FM_KeyValue"KeyValue")
}
 
SetKeyValue(iEnt, const szKey[], const szValue[], const szClassName[])
{
    
set_kvd(0KV_ClassNameszClassName)
    
set_kvd(0KV_KeyNameszKey)
    
set_kvd(0KV_ValueszValue)
    
set_kvd(0KV_fHandled0)
    
dllfunc(DLLFunc_KeyValueiEnt0)
}
 
public 
KeyValue(iEntkvd_handle)
{
    if( 
pev_valid(iEnt) )
    {
        static 
szClassName[20]
        
get_kvd(kvd_handleKV_ClassNameszClassNamecharsmax(szClassName))
        if(    
equal(szClassName"game_player_equip")
        ||    
equal(szClassName"info_map_parameters")
        ||    
equal(szClassName"player_weaponstrip")    )
        {
            
engfuncEngFunc_RemoveEntityiEnt )
            return 
FMRES_SUPERCEDE
        
}
    }
    return 
FMRES_IGNORED
}
 
public 
plugin_init()
{
    
unregister_forward(FM_KeyValueg_iFhKeyValue)
    
set_cvar_float("sv_restart"1.0)
 
    
register_plugin("strips""1""AUTHOR")
 
    
pause("ad")


for 2. u can remove weapons on ground after x sec.

by this code, player willbe stripped & drops nothing. so player cant buy, cant peak anyweapons. but maybe the weapons on map like aim_ak-colt


I think you have mistaker because i don't want everyone to stirp i just want the person strip when he brought spartan extra item and he cannot take back the weapon or any other weapon too.

One 05-18-2009 05:35

Re: Strip weapon
 
oh oki.

ƒa†es™ 05-19-2009 01:19

Re: Strip weapon
 
I guess nobody knows ?

vato loco [GE-S] 05-19-2009 04:37

Re: Strip weapon
 
hi....i hope this is what you want

PHP Code:

/*================================================================================

-----------------------------------
-*- [ZP] Extra Item : Spartan -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

A Spartan has Multipy Damage x10000.

================================================================================*/
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <hamsandwich>

#define is_valid_player(%1) (1 <= %1 <= 32)

new g_itemidpcvar_dmgmultiplier
new bool:g_Hasspartan[33]

public 
plugin_init()
{
    
register_plugin("[ZP] Extra: Spartan ( Multipy Damage x10000 )""1.0""ƒa†es™")
    
g_itemid zp_register_extra_item("Spartan ( Multipy Damage x10000 )"0ZP_TEAM_HUMAN)
    
pcvar_dmgmultiplier register_cvar("zp_awp_dmg_multiplier""10000")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
    
register_event("HLTV","new_round""a","1=0""2=0")
    
register_forward(FM_ClientConnect"client_connect")
    
register_forward(FM_ClientDisconnect"client_disconnect")
}
public 
new_round()
{
    for(new 
032i++)
    {
        
g_Hasspartan[i] = false
    
}
}
public 
client_connect(id)
{
    
g_Hasspartan[id] = false
}
public 
client_disconnect(id)
{
    
g_Hasspartan[id] = false
}
public 
Death()
{
    
g_Hasspartan[read_data(2)] = false
}
public 
fwHamPlayerSpawnPost(id)
{
    
g_Hasspartan[id] = false
}
public 
zp_user_infected_post(id)
{
    if (
zp_get_user_zombie(id))
    {
        
g_Hasspartan[id] = false
    
}
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if ( 
is_valid_playerattacker ) && get_user_weapon(attacker) == CSW_KNIFE && g_Hasspartan[attacker] )
    {
        
SetHamParamFloat(4damage get_pcvar_floatpcvar_dmgmultiplier ) )
    }
}
public 
zp_extra_item_selected(iditemid)
{
    if ( 
itemid == g_itemid )
    {
        
fm_weaponstrip(id0)
        
set_pev(idpev_armorvaluefloat(pev(idpev_armorvalue)) + 1500.0)
        
set_pev(idpev_healthfloat(pev(idpev_health)) + 1500.0)
        
set_pev(idpev_gravityfloat(pev(idpev_gravity)) + 0.7)
        
fm_user_rendering(idkRenderFxGlowShell22500kRenderNormal16)
        
client_print(idprint_chat"[ZP] You has bought Spartan")
        
g_Hasspartan[id] = true;
    }
}
stock fm_weaponstrip(idnoknife=0)
{
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
    if(!
pev_valid(ent)) return 0
    dllfunc
(DLLFunc_Spawnent)
    
dllfunc(DLLFunc_Useentid)
    if(!
noknife)fm_give_item(id,"weapon_knife")
    
engfunc(EngFunc_RemoveEntityent)
    return 
1
}
stock fm_give_item(id, const item[])
{
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent)) return;
    
    static 
Float:originF[3]
    
pev(idpev_originoriginF)
    
set_pev(entpev_originoriginF)
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
    
dllfunc(DLLFunc_Spawnent)
    
    static 
save
    save 
pev(entpev_solid)
    
dllfunc(DLLFunc_Touchentid)
    if (
pev(entpev_solid) != save)
        return;
    
    
engfunc(EngFunc_RemoveEntityent)
}
stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16) {
    new 
Float:RenderColor[3];
    
RenderColor[0] = float(r);
    
RenderColor[1] = float(g);
    
RenderColor[2] = float(b);
    
set_pev(entitypev_renderfxfx);
    
set_pev(entitypev_rendercolorRenderColor);
    
set_pev(entitypev_rendermoderender);
    
set_pev(entitypev_renderamtfloat(amount));
    return 
1;


strip user weapons without knife
PHP Code:

fm_weaponstrip(id0

strip user all weapons
PHP Code:

fm_weaponstrip(id1



All times are GMT -4. The time now is 01:35.

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