Raised This Month: $ Target: $400
 0% 

[REQ] Loot AFK C4 ?


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2015 , 12:20   Re: [REQ] Loot AFK C4 ?
Reply With Quote #11

Ok, check this:
PHP Code:
/*      Copyleft 2015

    SteaC4 is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StealC4; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/ 

#include <amxmodx>  
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>

#define PluginName    "Steal C4"
#define PluginVersion "0.3"
#define PluginAuthor  "HamletEagle"

new const NeededSound[] = "common/wpn_denyselect.wav"

new bool:CarrierIsCamping

new BombOwner
new CvarDistance
new CvarLootTime
new CvarLootAfk
new CvarAutoDropC4
new CvarAutoDropTime
new MaxPlayers
new gmsgBarTime

public plugin_init()
{
    
register_plugin
    
(
        .
plugin_name PluginName,
        .
version     PluginVersion,
        .
author      PluginAuthor
    
)
    
    
register_forward(FM_EmitSound"PfnEmitSound")
    
RegisterHam(Ham_AddPlayerItem"player""CBasePlayer_AddPlayerItem"true)
    
    
CvarLootTime     register_cvar("loot_time""3")
    
CvarLootAfk      register_cvar("loot_afk""10")
    
CvarDistance     register_cvar("loot_distance""20.0")
    
CvarAutoDropC4   register_cvar("loot_autodropc4""0")
    
CvarAutoDropTime register_cvar("loot_autodroptime""20")
    
    
MaxPlayers get_maxplayers()
    
gmsgBarTime get_user_msgid("BarTime")
    
    
set_task(1.0"CheckCarrierAfk", .flags "b")
}   

public 
CheckCarrierAfk()
{
    if(
BombOwner == 0)
    {
        return
    }
    static 
bool:SameOrigini
    
static CampSecondsDropSeconds
    
static Float:PlayerOrigin[3]; pev(BombOwnerpev_originPlayerOrigin)
    static 
Float:PlayerOldOrigin[3]
    
    for(
03i++)
    {
        if(
PlayerOrigin[i] == PlayerOldOrigin[i])
        {
            
SameOrigin true
            
break
        }
        else 
        {
            
SameOrigin false
            
break
        }
    }    
    
    if(
SameOrigin)
    {
        
CampSeconds CampSeconds 1
        
if(CampSeconds >= get_pcvar_num(CvarLootAfk))
        {
            
CarrierIsCamping true
            
if(get_pcvar_num(CvarAutoDropC4) != 0)
            {
                
DropSeconds DropSeconds 1
                
if(DropSeconds >= get_pcvar_num(CvarAutoDropTime))
                {
                    
#if AMXX_VERSION_NUM < 183
                        
engclient_cmd(BombOwner"drop""weapon_c4")    
                    
#else
                        
amxclient_cmd(BombOwner"drop""weapon_c4")
                    
#endif
                
                    
BombOwner 0
                    CarrierIsCamping 
false
                
}
            }
            else if(
DropSeconds)
            {
                
DropSeconds 0
            
}
        }
        else 
        {
            
DropSeconds 0
        
}
    }
    else 
    {
        
CampSeconds 0
        CarrierIsCamping 
false
    
}
    
    
PlayerOldOrigin PlayerOrigin
}

public 
CBasePlayer_AddPlayerItem(idWeaponEntity)
{
    if(
pev_valid(WeaponEntity) && cs_get_weapon_id(WeaponEntity) == CSW_C4)
    {
        if(
<= id <= MaxPlayers)
        {
            
BombOwner id
        
}
    }
}

public 
PfnEmitSound(idChannel, const Sound[], Float:VolumeFloat:AttenuationFlagsPitch)
{
    if(
equal(SoundNeededSound) && (pev(idpev_button) & IN_USE)) //just to make sure, the sound may be reused for another action
    
{
        if(
<= id <= MaxPlayers)
        {
            if(!
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)
            {
                if(
CarrierIsCamping)
                {
                    new 
TargetBody
                    get_user_aiming
(idTargetBody)
                    if(
<= Target <= MaxPlayers && Target == BombOwner)
                    {
                        new 
Float:TargetOrigin[3]; pev(Targetpev_originTargetOrigin)
                        new 
Float:PlayerOrigin[3]; pev(idpev_originPlayerOrigin)
                        
                        if(
get_distance_f(PlayerOriginTargetOrigin) <= get_pcvar_float(CvarDistance))
                        {
                            new 
Time get_pcvar_num(CvarLootTime)
                            
message_begin(MSG_ONEgmsgBarTime_id)
                            {
                                
write_short(Time)
                                
message_end()
                            }   
                            
set_task(float(Time), "TransferC4"id)
                        }
                    }
                }
            }
        }
    }
    
}

public 
TransferC4(id)
{
    
fm_transfer_user_gun(BombOwneridCSW_C4)
                            
    
user_has_weapon(BombOwnerCSW_C40)
    
user_has_weapon(idCSW_C41)
                            
    
BombOwner id
}

stock bool:fm_transfer_user_gun(index1index2wid 0, const wname[] = "")
{
    new 
ent_class[32]
    if(!
wid && wname[0])
    {
        
copy(ent_classcharsmax(ent_class), wname)
    }
    else 
    {
        new 
weapon widclipammo
        
if(!weapon && !(weapon get_user_weapon(index1clipammo)))
        {
            return 
false
        
}
        
        
get_weaponname(weaponent_classcharsmax(ent_class))
    }

    new 
ent_weap find_ent_by_owner(-1ent_classindex1)
    if(!
ent_weap)
    {
        return 
false
    
}

    
engclient_cmd(index1"drop"ent_class)

    new 
ent_box pev(ent_weappev_owner)
    if(!
ent_box || ent_box == index1)
    {
        return 
false
    
}

    
set_pev(ent_boxpev_flagspev(ent_boxpev_flags) | FL_ONGROUND)
    
dllfunc(DLLFunc_Touchent_boxindex2)
    if(
pev(ent_weappev_owner) != index2)
    {
        return 
false
    
}

    return 
true

__________________

Last edited by HamletEagle; 07-29-2015 at 12:22.
HamletEagle is offline
Costin83
Senior Member
Join Date: Jul 2008
Location: Romania
Old 07-29-2015 , 12:39   Re: [REQ] Loot AFK C4 ?
Reply With Quote #12

Yup. I think that's it!

One more Q. Would it be more efficient (or even working... ) like this:

PHP Code:
    if(SameOrigin)
    {
        if(
CampSeconds >= get_pcvar_num(CvarLootAfk))
        {
            
CarrierIsCamping true
            
if(get_pcvar_num(CvarAutoDropC4) != 0)
            {
                if(
DropSeconds >= get_pcvar_num(CvarAutoDropTime))
                {
                    
#if AMXX_VERSION_NUM < 183
                        
engclient_cmd(BombOwner"drop""weapon_c4")    
                    
#else
                        
amxclient_cmd(BombOwner"drop""weapon_c4")
                    
#endif
                
                    
BombOwner 0
                    CarrierIsCamping 
false
                
}
                else
                {
                    
DropSeconds DropSeconds // Only ++seconds if the timer isn't met ?
                
}
            }
            else if(
DropSeconds)
            {
                
DropSeconds 0
            
}
        }
        else 
        {
            
CampSeconds CampSeconds // Only ++seconds if the timer isn't met ?
            
DropSeconds 0
        
}
    } 
?
__________________
Originally Posted by Hawk552
Actually, if your style pisses me off enough, I'll generally go through your code and find some reason to unapprove it or at least hold it back.

Last edited by Costin83; 07-29-2015 at 12:42.
Costin83 is offline
Send a message via Yahoo to Costin83
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2015 , 12:54   Re: [REQ] Loot AFK C4 ?
Reply With Quote #13

Yes, you can change it.
__________________
HamletEagle is offline
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 05:03.


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