Raised This Month: $ Target: $400
 0% 

Set players view


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
bibu
Veteran Member
Join Date: Sep 2010
Old 01-05-2013 , 07:56   Re: Set players view
Reply With Quote #6

Alright I tried todo something. It will for sure give you the idea what I have done or make it better since I just used natives from all modules. Not that it is bad, just use the right natives and it is fine.

In that code I basically removed the c4 drop from a player and c4 drop by dieing. It creates an entity with the c4 model and hooks the touch and gives the c4 to that player.

Keep in mind, that I have added a code that the owner of the last thrower of the c4 can't pickup it anymore, since he would pick it right up if he drops it.

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

#define PLUGIN "C4 Drop"
#define VERSION "1.0"
#define AUTHOR "AMXX Community"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Killed"player""Ham_CBasePlayer_Killed_Pre"0)
    
    
register_touch("weapon_c4_custom""player""TouchBomb")
    
    
register_clcmd("drop""DropBomb")
}

public 
Ham_CBasePlayer_Killed_Pre(iVictim)
{
    if(
user_has_weapon(iVictimCSW_C4))
    {
        new 
Float:origin[3]
        
pev(iVictim,pev_origin,origin)
        
        
ham_strip_c4(iVictim"weapon_c4")
        
create_c4(iVictimorigin)
    }
}

public 
DropBomb(id)
{
    if(
is_user_alive(id) && get_user_weapon(id) == CSW_C4)
    {
        new 
Float:iOrigin[3]
        
pev(idpev_originiOrigin)
        
        
ham_strip_c4(id"weapon_c4")
        
create_c4(idiOrigin)
        
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

create_c4(idFloat:iOrigin[3])
{
    new 
C4 create_entity("func_wall")
    
    
entity_set_string(C4EV_SZ_classname"weapon_c4_custom")
    
entity_set_model(C4"models/w_backpack.mdl")
    
entity_set_int(C4EV_INT_solidSOLID_TRIGGER)
    
entity_set_size(C4Float:{-2.0,-2.0,-2.0}, Float:{2.0,2.0,2.0})
    
entity_set_edict(C4EV_ENT_ownerid)
    
    
entity_set_origin(C4iOrigin)
    
    
drop_to_floor(C4)
}

public 
TouchBomb(C4id)
{
    new 
owner entity_get_edict(C4EV_ENT_owner)
    
    if(
owner == id)
        return
   
    
give_item(id"weapon_c4")
    
remove_entity(C4)
}

ham_strip_c4(id,weapon[])
{
    new 
wId get_weaponid(weapon);
    if(!
wId) return 0;

    new 
wEnt;
    while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!
wEnt) return 0;

    if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);

    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    
ExecuteHamB(Ham_Item_Kill,wEnt);

    
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));

    
cs_set_user_plant(id,0,0);
    
cs_set_user_bpammo(id,CSW_C4,0);
    
    return 
1;

__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu 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 13:40.


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