Raised This Month: $ Target: $400
 0% 

Pickup multiple weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XAT
Member
Join Date: Jul 2011
Old 01-21-2012 , 14:49   Pickup multiple weapons
Reply With Quote #1

Since none answeared my last question, i've made some progress by myselfe and i got another question.

How does set_task works with a 0.0 time, as i understand it should immediately call the function behind it but somehow it makes difference when i use it. Ex. Ham_Item_AddToPlayer hook, when i change player offsets in this hook (pre or post, dosen't make a difference) it is overwited (by game function ? cs_i386 ?), but when i use this immediately task in the same hook, it isn't overwrited anymore.

So how does this thing work ? Does task have extra seconds or something ? Or does anyone know in what function after this hook can i safety set this (weapon / item) offsets without this laggy timer ?

Last edited by Arkshine; 01-22-2012 at 15:18.
XAT is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-21-2012 , 15:01   Re: Set_Task question
Reply With Quote #2

set_task with 0.0 doesn't make sense to start. The minimal time is 0.1, if you put 0.0, it will be considered to 0.1.
Instead of focusing on set_task, you should try to understand what you're doing about the offsets you want to set. What offsets are you talking about ? If offsets are overwritten whatever pre/post and it works after 0.1s, it would mean AddToPlayer is inappropriate.
__________________

Last edited by Arkshine; 01-21-2012 at 15:03.
Arkshine is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-21-2012 , 15:01  
Reply With Quote #3

You should be able to set any offset in pre from what i understand it just depends on your return after you set it.
Doc-Holiday is offline
XAT
Member
Join Date: Jul 2011
Old 01-21-2012 , 15:05   Re: Set_Task question
Reply With Quote #4

What am i trying to do is change offset 42 (m_pNext) when Ham_Item_AddToPlayer (or player gets a new weapon) is called

It works with a task but i found it laggy as Arkshine said its 0.1 and sometimes its annoying.

Last edited by XAT; 01-21-2012 at 15:11.
XAT is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-21-2012 , 15:25   Re: Set_Task question
Reply With Quote #5

You should try to learn working with HLSDK.

PHP Code:
BOOL CBasePlayer::AddPlayerItemCBasePlayerItem *pItem )
{
    
CBasePlayerItem *pInsert;

    
pInsert m_rgpPlayerItemspItem->iItemSlot() ];

    while( 
pInsert )
    {
        if( 
FClassnameIspInsert->pevSTRINGpItem->pev->classname ) ) )
        {
            if( 
pItem->AddDuplicatepInsert ) )
            {
                
g_pGameRules->PlayerGotWeaponthispItem );
                
pItem->CheckRespawn();

                
// ugly hack to update clip w/o an update clip message
                
pInsert->UpdateItemInfo( );

                if( 
m_pActiveItem )
                    
m_pActiveItem->UpdateItemInfo();

                
pItem->Kill( );
            }
            else if( 
gEvilImpulse101 )
            {
                
// FIXME: remove anyway for deathmatch testing
                
pItem->Kill();
            }
            return 
FALSE;
        }

        
pInsert pInsert->m_pNext;
    }


    if( 
pItem->AddToPlayerthis ) )
    {
        
g_pGameRules->PlayerGotWeaponthispItem );

        if( 
pItem->iItemSlot() == ItemSlot_Primary )
        {
            
m_fHasPrimaryWeapon TRUE;
        }

        
pItem->CheckRespawn();

        
pItem->m_pNext m_rgpPlayerItemspItem->iItemSlot() ];
        
m_rgpPlayerItems [pItem->iItemSlot() ] = pItem;

        if( 
HasShield() )
        {
            
pev->gamestate 0;
        }

        
// should we switch to this item?
        
if( g_pGameRules->FShouldSwitchWeaponthispItem ) && !IsProtectedByShield() )
        {
            
SwitchWeaponpItem );
        }

        return 
TRUE;
    }
    else if( 
gEvilImpulse101 )
    {
        
// FIXME: remove anyway for deathmatch testing
        
pItem->Kill();
    }
    return 
FALSE;

AddToPlayer is called inside AddPlayerItem and you see m_pNext is set after AddToPlayer, so of course whatever pre/post, that's not going to work. Here, you should hook AddPlayerItem as post, check return is 1, then setting the offset.
__________________
Arkshine is offline
XAT
Member
Join Date: Jul 2011
Old 01-21-2012 , 16:45   Re: Set_Task question
Reply With Quote #6

Well, i've done what you've said but i get strange error after i set the offset. It seems to be set (message shows after set_pdata_cbase) but i get crash.

PHP Code:
0xb5655f5e in CWeaponBox::Touch(CBaseEntity *) () 
Any ideas what am i doing wrong ?

Last edited by XAT; 01-21-2012 at 16:46.
XAT is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-21-2012 , 16:53   Re: Set_Task question
Reply With Quote #7

Nobody can help you if you don't explain exactly what you want really to do, and what you have done exactly if there is a problem.
__________________
Arkshine is offline
XAT
Member
Join Date: Jul 2011
Old 01-22-2012 , 05:09   Re: Set_Task question
Reply With Quote #8

Quote:
Originally Posted by Arkshine View Post
Nobody can help you if you don't explain exactly what you want really to do, and what you have done exactly if there is a problem.
I'm trying to extend player primary and secondary weapon slots.
I want to make them holding multiple primary/secondary weapons.
i've got it working ExecuteHam(Ham_AddPlayerItem, ...) in touch forward, but when i drop weapons fast and pick up them in same time i get random crashes.

PHP Code:
Program received signal SIGINTInterrupt.
0xb5655f60 in CWeaponBox::Touch(CBaseEntity *) ()
   
from /home/hlds/cstrike/dlls/cs_i386.so
(gdbbt
#0  0xb5655f60 in CWeaponBox::Touch(CBaseEntity *) ()
   
from /home/hlds/cstrike/dlls/cs_i386.so
#1  0xb50bfb8c in Hook_Void_Cbase (hook=0x8f07da8, pthis=0x8fd3cb0,
    
other=0x8fcf4c8at hook_callbacks.cpp:256
#2  0x08f08016 in ?? ()
#3  0xb55d5f21 in DispatchTouch(edict_s *, edict_s *) ()
   
from /home/hlds/cstrike/dlls/cs_i386.so
#4  0xb58198fb in mm_DispatchTouch(edict_s *, edict_s *) ()
   
from ./cstrike/addons/metamod/dlls/metamod_i386.so
#5  0xb5bc1c48 in ?? ()
Backtrace stoppedprevious frame inner to this frame (corrupt stack?)
(
gdbcmd_args
$0x0 
It seems to be invalid entity or not assigned yet, is this a reason of the crash ? Too fast weapon drop and pick ?

Last edited by XAT; 01-22-2012 at 05:10.
XAT is offline
XAT
Member
Join Date: Jul 2011
Old 01-22-2012 , 08:30   Re: Set_Task question
Reply With Quote #9

I've found the problem, i used ExecuteHam in touch forward pre so too many calls caused crash...

Solved, thanks Arkshine.

Last edited by XAT; 01-22-2012 at 08:30.
XAT is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-22-2012 , 08:41   Re: Set_Task question
Reply With Quote #10

So you have done what exactly ?

I've fastly looked, to allow to get multiple weapons by touching a weaponbox entity, one solution would be to hook Touch as pre, saving entity from m_rgpPlayerItems (player offset) of the touched item's slot, replacing by 0 so it will allow to add a new weapon. Then, hooking AddPlayerItem as pre and restoring the entity.
__________________

Last edited by Arkshine; 01-22-2012 at 08:41.
Arkshine 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 17:42.


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