Raised This Month: $51 Target: $400
 12% 

Weapon Plugin and Removal at the Beginning of the Round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vaflyan
Junior Member
Join Date: Mar 2024
Old 03-17-2024 , 11:37   Weapon Plugin and Removal at the Beginning of the Round
Reply With Quote #1

Does anyone know how this code can implement the removal of this weapon from the player at the start of a new round? I don't want this weapon to remain with the player when they were a survivor.

I've tried many options, but not one has fulfilled this function. Thank you in advance
Attached Files
File Type: sma Get Plugin or Get Source (Weapon_ZhuBajieMinigun.sma - 44 views - 26.1 KB)
Vaflyan is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 03-17-2024 , 12:05   Re: Weapon Plugin and Removal at the Beginning of the Round
Reply With Quote #2

are you talking about not allowing him to use this weapon?

Code:
public zp_user_humanized_post(id, survivor) {     if(zp_get_user_survivor(id))     {
        //Weapon_Give(id);
    } }
__________________
mlibre is offline
Vaflyan
Junior Member
Join Date: Mar 2024
Old 03-17-2024 , 12:15   Re: Weapon Plugin and Removal at the Beginning of the Round
Reply With Quote #3

Quote:
Originally Posted by mlibre View Post
are you talking about not allowing him to use this weapon?

Code:
public zp_user_humanized_post(id, survivor) {     if(zp_get_user_survivor(id))     {
        //Weapon_Give(id);
    } }
No. Look: I'm starting a survivor round. He is given this minigun. If he remains alive, in the next round, as a simple player, this minigun should disappear.

In short: the minigun is only for the survivor
Vaflyan is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 03-19-2024 , 15:28   Re: Weapon Plugin and Removal at the Beginning of the Round
Reply With Quote #4

add this in plugin_init

PHP Code:
RegisterHam(Ham_Spawn"player""Ham_SpawnPlayer_Post"true
and try...

PHP Code:
public Ham_SpawnPlayer_Post(iPlayer)
{
    if(
zp_get_user_survivor(iPlayer) || !is_user_alive(iPlayer))
        return 
HAM_IGNORED
    
    engclient_cmd
(iPlayerWEAPON_REFERANCE)
    
    new 
iActiveItem get_pdata_cbase(iPlayerm_pActiveItemextra_offset_player)

    if(
IsValidPev(iActiveItem) && IsCustomItem(iActiveItem))
    {
        
ExecuteHamB(Ham_RemovePlayerItemiPlayeriActiveItem)
        
        
engclient_cmd(iPlayer"lastinv")
        
        
client_print(iPlayer3"Sorry, the %s is only for the survivor"ZP_ITEM_NAME)
    }
    
    return 
HAM_IGNORED

__________________
mlibre is offline
Vaflyan
Junior Member
Join Date: Mar 2024
Old 03-20-2024 , 03:09   Re: Weapon Plugin and Removal at the Beginning of the Round
Reply With Quote #5

Quote:
Originally Posted by mlibre View Post
add this in plugin_init

PHP Code:
RegisterHam(Ham_Spawn"player""Ham_SpawnPlayer_Post"true
and try...

PHP Code:
public Ham_SpawnPlayer_Post(iPlayer)
{
    if(
zp_get_user_survivor(iPlayer) || !is_user_alive(iPlayer))
        return 
HAM_IGNORED
    
    engclient_cmd
(iPlayerWEAPON_REFERANCE)
    
    new 
iActiveItem get_pdata_cbase(iPlayerm_pActiveItemextra_offset_player)

    if(
IsValidPev(iActiveItem) && IsCustomItem(iActiveItem))
    {
        
ExecuteHamB(Ham_RemovePlayerItemiPlayeriActiveItem)
        
        
engclient_cmd(iPlayer"lastinv")
        
        
client_print(iPlayer3"Sorry, the %s is only for the survivor"ZP_ITEM_NAME)
    }
    
    return 
HAM_IGNORED

God, thank you so much. I've tried a lot of methods, but yours worked. Best
Vaflyan is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 03-20-2024 , 10:11   Re: Weapon Plugin and Removal at the Beginning of the Round
Reply With Quote #6

Quote:
Originally Posted by Vaflyan View Post
God, thank you so much. I've tried a lot of methods, but yours worked. Best
great, this seems to be enough, it could be optimized even more, that would involve involving other functions where bool would play an important role, but of course it is more tedious. something I omitted to not complicate things so much.
__________________
mlibre 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 06:24.


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