AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Only 1 C4 [Strip if Multiple C4's] (https://forums.alliedmods.net/showthread.php?t=330010)

Alber9091 01-16-2021 17:27

Only 1 C4 [Strip if Multiple C4's]
 
Hi,

A friend's server has little bug, sometimes, more than 1 player gets C4, usually 2 and 2 C4's are planted & the bug is so rare, it happens like once in 300 rounds, hence what is causing it is difficult to catch, checking plugin by plugin.

Hence, I need some plugin, which:

1. Randomly Strips C4 from all except 1, if plugin detects more than 1 C4's with message "Due to multiple C4's, C4 is stripped from you and x player will keep the C4". (Message seen by T's & Specs only).
C4 Check/Detection, 3 seconds after the start of every round.
OR
2. If plugin detects more than 1 C4's, strips C4 from everyone and then give 1 to any random T's after 3 seconds with message "C4 stripped from everyone because of multiple C4's" & then after 3 seconds "C4 given to x player randomly" (Message seen by T's & Specs only).
C4 Check/Detection, 3 seconds after the start of every round.
OR
3. Just allow only single plant with message, "C4 is already planted, you can't plant another." (Yet, would be controversial CT's guarding one and other gets planted).

Or any other idea? Or any of given ideas you feel easy and best?

AMXX 1.90 [5271]
ReApi (instead of Orpheu)

Thanks !!

iceeedr 01-16-2021 23:59

Re: Only 1 C4 [Strip if Multiple C4's]
 
Not tested

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <reapi>
#include <hamsandwich>
#include <csx>

#define VERSION "0.0.1"
#define PLUGIN ""

new bool:g_bCanPlantC4

public plugin_init()
{
        
register_plugin(PLUGINVERSION"ConnorMcLeod & iceeedR")
        
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_c4""CC4_PrimaryAttack")
        
register_event("HLTV","EventNewRnd""a""1=0""2=0")
}

public 
EventNewRnd()
{
        
g_bCanPlantC4 true
}

public 
bomb_planted(planter)
{
        
g_bCanPlantC4 false
}

public 
CC4_PrimaryAttackiC4 )
{
        if( !
g_bCanPlantC4 )
        {
                new 
id get_member(idm_pPlayer)
                
client_print(idprint_chat"C4 is actually disabled !!")
                
set_member(iC4m_flNextAttack1.0)
                return 
HAM_SUPERCEDE
        
}
        return 
HAM_IGNORED



Alber9091 01-17-2021 02:57

Re: Only 1 C4 [Strip if Multiple C4's]
 
Quote:

Originally Posted by iceeedr (Post 2732906)
Not tested

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <reapi>
#include <hamsandwich>
#include <csx>

#define VERSION "0.0.1"
#define PLUGIN ""

new bool:g_bCanPlantC4

public plugin_init()
{
        
register_plugin(PLUGINVERSION"ConnorMcLeod & iceeedR")
        
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_c4""CC4_PrimaryAttack")
        
register_event("HLTV","EventNewRnd""a""1=0""2=0")
}

public 
EventNewRnd()
{
        
g_bCanPlantC4 true
}

public 
bomb_planted(planter)
{
        
g_bCanPlantC4 false
}

public 
CC4_PrimaryAttackiC4 )
{
        if( !
g_bCanPlantC4 )
        {
                new 
id get_member(idm_pPlayer)
                
client_print(idprint_chat"C4 is actually disabled !!")
                
set_member(iC4m_flNextAttack1.0)
                return 
HAM_SUPERCEDE
        
}
        return 
HAM_IGNORED



Thank You !! Can you please specify which idea you implemented? It will help me to check much more easily, seems like 3rd? but still I can't see through coding eyes.

iceeedr 01-17-2021 12:46

Re: Only 1 C4 [Strip if Multiple C4's]
 
Quote:

Originally Posted by Alber9091 (Post 2732917)
Thank You !! Can you please specify which idea you implemented? It will help me to check much more easily, seems like 3rd? but still I can't see through coding eyes.

Yup 3rd.

Alber9091 01-17-2021 16:07

Re: Only 1 C4 [Strip if Multiple C4's]
 
Quote:

Originally Posted by iceeedr (Post 2732987)
Yup 3rd.

Thanks for the help. They say something is better than nothing but its more than something, I will use it, it will be much appreciated if some how? You or anyone else? Can apply the first method, since 3rd one still leaves a gap, what I mentioned in first post that CT's will guard the one C4, if dropped and the other one will be planted.

- Check at the start of round the number of C4's.
- If more than 1
- Strip C4, randomly from everyone having C4, except 1.

Quote:

Originally Posted by VEN (Post 343295)
Code:
// How to strip the bomb from a player?     engclient_cmd(id, "weapon_c4")     cs_set_user_bpammo(id, CSW_C4, 0)     engclient_cmd(id, "lastinv")     // remove bomb hud icon     message_begin(MSG_ONE, get_user_msgid("StatusIcon"), _, id)     write_byte(0)     write_string("c4")     message_end()


FAQ/Tutorial CS Bomb Scripting


OR Any other way?

iceeedr 01-17-2021 23:14

Re: Only 1 C4 [Strip if Multiple C4's]
 
Not tested and I'm tired, so I can't guarantee it's 100%.

PHP Code:

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

#define VERSION "0.0.1"
#define PLUGIN ""

new GotTheBomb

public plugin_init()
{
        
register_plugin(PLUGINVERSION"iceeedR")
        
register_event("HLTV","EventNewRnd""a""1=0""2=0")
}

public 
EventNewRnd()
{
        
GotTheBomb 0
        
new iPlayers[MAX_PLAYERS],iNumid
        get_players_ex
(iPlayersiNumGetPlayers_ExcludeHLTV GetPlayers_ExcludeBots GetPlayers_MatchTeam"TERRORIST")

        for(new 
iiNum;i++)
        {
                
id iPlayers[i]

                if (!(
user_has_weapon(idCSW_C4)))
                        continue

                
GotTheBomb ++

                if(
GotTheBomb 1)
                {
                        
ham_strip_user_weapon(idCSW_C4)
                        break
                }
        }
}

// stock made by drekes (removed from stripweapons.inc)
stock ham_strip_user_weapon(idiCswIdiSlot 0bool:bSwitchIfActive true)
{
        new 
iWeapon
        
if( !iSlot )
        {
                static const 
iWeaponsSlots[] = {
                        -
1,
                        
2//CSW_P228
                        
-1,
                        
1//CSW_SCOUT
                        
4//CSW_HEGRENADE
                        
1//CSW_XM1014
                        
5//CSW_C4
                        
1//CSW_MAC10
                        
1//CSW_AUG
                        
4//CSW_SMOKEGRENADE
                        
2//CSW_ELITE
                        
2//CSW_FIVESEVEN
                        
1//CSW_UMP45
                        
1//CSW_SG550
                        
1//CSW_GALIL
                        
1//CSW_FAMAS
                        
2//CSW_USP
                        
2//CSW_GLOCK18
                        
1//CSW_AWP
                        
1//CSW_MP5NAVY
                        
1//CSW_M249
                        
1//CSW_M3
                        
1//CSW_M4A1
                        
1//CSW_TMP
                        
1//CSW_G3SG1
                        
4//CSW_FLASHBANG
                        
2//CSW_DEAGLE
                        
1//CSW_SG552
                        
1//CSW_AK47
                        
3//CSW_KNIFE
                        
//CSW_P90
                
}
                
iSlot iWeaponsSlots[iCswId]
        }

        const 
XTRA_OFS_PLAYER 5
        
const m_rgpPlayerItems_Slot0 367

        iWeapon 
get_pdata_cbase(idm_rgpPlayerItems_Slot0 iSlotXTRA_OFS_PLAYER)

        const 
XTRA_OFS_WEAPON 4
        
const m_pNext 42
        
const m_iId 43

        
while( iWeapon )
        {
                if( 
get_pdata_int(iWeaponm_iIdXTRA_OFS_WEAPON) == iCswId )
                {
                        break
                }
                
iWeapon get_pdata_cbase(iWeaponm_pNextXTRA_OFS_WEAPON)
        }

        if( 
iWeapon )
        {
                const 
m_pActiveItem 373
                
if( bSwitchIfActive && get_pdata_cbase(idm_pActiveItemXTRA_OFS_PLAYER) == iWeapon )
                {
                        
ExecuteHamB(Ham_Weapon_RetireWeaponiWeapon)
                }

                if( 
ExecuteHamB(Ham_RemovePlayerItemidiWeapon) )
                {
                        
user_has_weapon(idiCswId0)
                        
ExecuteHamB(Ham_Item_KilliWeapon)
                        return 
1
                
}
        }

        return 
0



Natsheh 01-18-2021 04:49

Re: Only 1 C4 [Strip if Multiple C4's]
 
Quote:

Originally Posted by iceeedr (Post 2733033)
Not tested and I'm tired, so I can't guarantee it's 100%.

you need a 2 or 3 seconds delay for HLTV event since dead players won't be respawned yet.


so it should be like this.
PHP Code:

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

#define VERSION "0.0.1"
#define PLUGIN ""

#define TASK_PLAYERS_SPAWNED 500

public plugin_init()
{
        
register_plugin(PLUGINVERSION"iceeedR")
        
register_event("HLTV","event_hltv""a""1=0""2=0")
}

public 
event_hltv()
{
        
remove_task(TASK_PLAYERS_SPAWNED);
        
set_task(3.0"Players_Spawned"TASK_PLAYERS_SPAWNED)
}

public 
Players_Spawned(taskid)
{
        new 
GotTheBomb 0;
        new 
iPlayers[MAX_PLAYERS],iNumid
        get_players
(iPlayersiNum"ah""TERRORIST")

        for(new 
iiNum;i++)
        {
                
id iPlayers[i]

                if (!(
user_has_weapon(idCSW_C4)))
                        continue

                
GotTheBomb ++

                if(
GotTheBomb  && GotTheBomb != 1)
                {
                        
ham_strip_user_weapon(idCSW_C4)
                        
GotTheBomb --;
                }
        }
}

// stock made by drekes (removed from stripweapons.inc)
stock ham_strip_user_weapon(idiCswIdiSlot 0bool:bSwitchIfActive true)
{
        new 
iWeapon
        
if( !iSlot )
        {
                static const 
iWeaponsSlots[] = {
                        -
1,
                        
2//CSW_P228
                        
-1,
                        
1//CSW_SCOUT
                        
4//CSW_HEGRENADE
                        
1//CSW_XM1014
                        
5//CSW_C4
                        
1//CSW_MAC10
                        
1//CSW_AUG
                        
4//CSW_SMOKEGRENADE
                        
2//CSW_ELITE
                        
2//CSW_FIVESEVEN
                        
1//CSW_UMP45
                        
1//CSW_SG550
                        
1//CSW_GALIL
                        
1//CSW_FAMAS
                        
2//CSW_USP
                        
2//CSW_GLOCK18
                        
1//CSW_AWP
                        
1//CSW_MP5NAVY
                        
1//CSW_M249
                        
1//CSW_M3
                        
1//CSW_M4A1
                        
1//CSW_TMP
                        
1//CSW_G3SG1
                        
4//CSW_FLASHBANG
                        
2//CSW_DEAGLE
                        
1//CSW_SG552
                        
1//CSW_AK47
                        
3//CSW_KNIFE
                        
//CSW_P90
                
}
                
iSlot iWeaponsSlots[iCswId]
        }

        const 
XTRA_OFS_PLAYER 5
        
const m_rgpPlayerItems_Slot0 367

        iWeapon 
get_pdata_cbase(idm_rgpPlayerItems_Slot0 iSlotXTRA_OFS_PLAYER)

        const 
XTRA_OFS_WEAPON 4
        
const m_pNext 42
        
const m_iId 43

        
while( iWeapon )
        {
                if( 
get_pdata_int(iWeaponm_iIdXTRA_OFS_WEAPON) == iCswId )
                {
                        break
                }
                
iWeapon get_pdata_cbase(iWeaponm_pNextXTRA_OFS_WEAPON)
        }

        if( 
iWeapon )
        {
                const 
m_pActiveItem 373
                
if( bSwitchIfActive && get_pdata_cbase(idm_pActiveItemXTRA_OFS_PLAYER) == iWeapon )
                {
                        
ExecuteHamB(Ham_Weapon_RetireWeaponiWeapon)
                }

                if( 
ExecuteHamB(Ham_RemovePlayerItemidiWeapon) )
                {
                        
user_has_weapon(idiCswId0)
                        
ExecuteHamB(Ham_Item_KilliWeapon)
                        return 
1
                
}
        }

        return 
0



Alber9091 01-18-2021 11:01

Re: Only 1 C4 [Strip if Multiple C4's]
 
I can't test it rapidly since bug is rare and as I'm not scripter, so little bit what I did understand from code, if there are multiple C4's, its strips C4 from everyone (not excluding 1 random with C4), which creates another bug, no one having C4, if there are >1 C4's after this plugin, what I understand no one have C4 ... OR I understood it wrong?

TIA

Natsheh 01-18-2021 11:08

Re: Only 1 C4 [Strip if Multiple C4's]
 
yup you did mis-understood it, it clearly strips if someone has an extra c4.

iceeedr 01-18-2021 11:39

Re: Only 1 C4 [Strip if Multiple C4's]
 
Quote:

Originally Posted by Natsheh (Post 2733058)
you need a 2 or 3 seconds delay for HLTV event since dead players won't be respawned yet.


so it should be like this.
PHP Code:

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

#define VERSION "0.0.1"
#define PLUGIN ""

#define TASK_PLAYERS_SPAWNED 500

public plugin_init()
{
        
register_plugin(PLUGINVERSION"iceeedR")
        
register_event("HLTV","event_hltv""a""1=0""2=0")
}

public 
event_hltv()
{
        
remove_task(TASK_PLAYERS_SPAWNED);
        
set_task(3.0"Players_Spawned"TASK_PLAYERS_SPAWNED)
}

public 
Players_Spawned(taskid)
{
        new 
GotTheBomb 0;
        new 
iPlayers[MAX_PLAYERS],iNumid
        get_players
(iPlayersiNum"ah""TERRORIST")

        for(new 
iiNum;i++)
        {
                
id iPlayers[i]

                if (!(
user_has_weapon(idCSW_C4)))
                        continue

                
GotTheBomb ++

                if(
GotTheBomb  && GotTheBomb != 1)
                {
                        
ham_strip_user_weapon(idCSW_C4)
                        
GotTheBomb --;
                }
        }
}

// stock made by drekes (removed from stripweapons.inc)
stock ham_strip_user_weapon(idiCswIdiSlot 0bool:bSwitchIfActive true)
{
        new 
iWeapon
        
if( !iSlot )
        {
                static const 
iWeaponsSlots[] = {
                        -
1,
                        
2//CSW_P228
                        
-1,
                        
1//CSW_SCOUT
                        
4//CSW_HEGRENADE
                        
1//CSW_XM1014
                        
5//CSW_C4
                        
1//CSW_MAC10
                        
1//CSW_AUG
                        
4//CSW_SMOKEGRENADE
                        
2//CSW_ELITE
                        
2//CSW_FIVESEVEN
                        
1//CSW_UMP45
                        
1//CSW_SG550
                        
1//CSW_GALIL
                        
1//CSW_FAMAS
                        
2//CSW_USP
                        
2//CSW_GLOCK18
                        
1//CSW_AWP
                        
1//CSW_MP5NAVY
                        
1//CSW_M249
                        
1//CSW_M3
                        
1//CSW_M4A1
                        
1//CSW_TMP
                        
1//CSW_G3SG1
                        
4//CSW_FLASHBANG
                        
2//CSW_DEAGLE
                        
1//CSW_SG552
                        
1//CSW_AK47
                        
3//CSW_KNIFE
                        
//CSW_P90
                
}
                
iSlot iWeaponsSlots[iCswId]
        }

        const 
XTRA_OFS_PLAYER 5
        
const m_rgpPlayerItems_Slot0 367

        iWeapon 
get_pdata_cbase(idm_rgpPlayerItems_Slot0 iSlotXTRA_OFS_PLAYER)

        const 
XTRA_OFS_WEAPON 4
        
const m_pNext 42
        
const m_iId 43

        
while( iWeapon )
        {
                if( 
get_pdata_int(iWeaponm_iIdXTRA_OFS_WEAPON) == iCswId )
                {
                        break
                }
                
iWeapon get_pdata_cbase(iWeaponm_pNextXTRA_OFS_WEAPON)
        }

        if( 
iWeapon )
        {
                const 
m_pActiveItem 373
                
if( bSwitchIfActive && get_pdata_cbase(idm_pActiveItemXTRA_OFS_PLAYER) == iWeapon )
                {
                        
ExecuteHamB(Ham_Weapon_RetireWeaponiWeapon)
                }

                if( 
ExecuteHamB(Ham_RemovePlayerItemidiWeapon) )
                {
                        
user_has_weapon(idiCswId0)
                        
ExecuteHamB(Ham_Item_KilliWeapon)
                        return 
1
                
}
        }

        return 
0



Yes, I was very tired and I knew something like that would pass me by, thanks.


All times are GMT -4. The time now is 00:50.

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