AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Weapon Plugin and Removal at the Beginning of the Round (https://forums.alliedmods.net/showthread.php?t=346786)

Vaflyan 03-17-2024 11:37

Weapon Plugin and Removal at the Beginning of the Round
 
1 Attachment(s)
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

mlibre 03-17-2024 12:05

Re: Weapon Plugin and Removal at the Beginning of the Round
 
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);     } }

Vaflyan 03-17-2024 12:15

Re: Weapon Plugin and Removal at the Beginning of the Round
 
Quote:

Originally Posted by mlibre (Post 2819666)
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

mlibre 03-19-2024 15:28

Re: Weapon Plugin and Removal at the Beginning of the Round
 
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



Vaflyan 03-20-2024 03:09

Re: Weapon Plugin and Removal at the Beginning of the Round
 
Quote:

Originally Posted by mlibre (Post 2819781)
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

mlibre 03-20-2024 10:11

Re: Weapon Plugin and Removal at the Beginning of the Round
 
Quote:

Originally Posted by Vaflyan (Post 2819797)
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.


All times are GMT -4. The time now is 04:43.

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