Raised This Month: $32 Target: $400
 8% 

Solved Only 1 C4 [Strip if Multiple C4's]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 01-16-2021 , 17:27   Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #1

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 !!

Last edited by Alber9091; 01-20-2021 at 18:15.
Alber9091 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-16-2021 , 23:59   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #2

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

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 01-17-2021 , 02:57   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #3

Quote:
Originally Posted by iceeedr View Post
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.
Alber9091 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-17-2021 , 12:46   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #4

Quote:
Originally Posted by Alber9091 View Post
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.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 01-17-2021 , 16:07   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #5

Quote:
Originally Posted by iceeedr View Post
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 View Post
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?

Last edited by Alber9091; 01-17-2021 at 17:50.
Alber9091 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-17-2021 , 23:14   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #6

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

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 01-17-2021 at 23:14.
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-18-2021 , 04:49   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #7

Quote:
Originally Posted by iceeedr View Post
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

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-18-2021 at 04:56.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 01-18-2021 , 11:01   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #8

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
Alber9091 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-18-2021 , 11:08   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #9

yup you did mis-understood it, it clearly strips if someone has an extra c4.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-18-2021 , 11:39   Re: Only 1 C4 [Strip if Multiple C4's]
Reply With Quote #10

Quote:
Originally Posted by Natsheh View Post
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.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
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 17:21.


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