AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [H3LP] Weapon Respawn Time (https://forums.alliedmods.net/showthread.php?t=296422)

DarthMan 04-20-2017 13:08

[H3LP] Weapon Respawn Time
 
Hello everyone. How can I set the time be4 a weapon respawns?
I've been trying everything, but nothing seems to work.
Thanks !

gabuch2 04-20-2017 13:17

Re: [H3LP] Weapon Respawn Time
 
pev_nextthink or Ham_Respawn() seem to be related to Item Respawning, unfortunately I haven't work with them too much, but you can test them.

PartialCloning 04-20-2017 13:31

Re: [H3LP] Weapon Respawn Time
 
By weapon you mean armoury entities? Call ExecuteHam(Ham_CS_Restart, Entity) on the entity. Alternatively you can change its flags to ~EF_NODRAW and the m_iCount to m_iInitialCount or the amount you would want it to have.

DarthMan 04-20-2017 13:32

Re: [H3LP] Weapon Respawn Time
 
Quote:

Originally Posted by PartialCloning (Post 2513883)
By weapon you mean armoury entities? Call ExecuteHam(Ham_CS_Restart, Entity) on the entity. Alternatively you can change its flags to ~EF_NODRAW and the m_iCount to m_iInitialCount or the amount you would want it to have.

Nope, I want for my HL1 server to check on any weapon respawn.

gabuch2 04-20-2017 13:58

Re: [H3LP] Weapon Respawn Time
 
Quote:

Originally Posted by PartialCloning (Post 2513883)
By weapon you mean armoury entities?

Weapon entities mean weapon entities. (weapon_*)

DarthMan 04-20-2017 14:11

Re: [H3LP] Weapon Respawn Time
 
Quote:

Originally Posted by Gabe Iggy (Post 2513892)
Weapon entities mean weapon entities. (weapon_*)

Ik, maybe with an enumeration it will check for all?

Craxor 04-20-2017 14:14

Re: [H3LP] Weapon Respawn Time
 
He mean to call when the weapons from the ground ( example fy_snow weapons ) are being created.

Example, when a new WEAPONBOX entity are maded.

This will be scanned ONLY when you pickup an m4a1, that's when you first create a m4a1 weaponbox:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init( )
{
    
RegisterHamHam_Spawn "weapon_m4a1""Test" );
}

public 
TestEnt )
{
    if( !
pev_validEnt ) )
        return 
PLUGIN_HANDLED;

    new 
szClass15 ];
    
pevEnt pev_classnameszClasscharsmaxszClass ) );

    
server_print"%s "szClass );
    return 
PLUGIN_CONTINUE;



gabuch2 04-20-2017 14:21

Re: [H3LP] Weapon Respawn Time
 
Quote:

Originally Posted by DarthMan (Post 2513895)
Ik, maybe with an enumeration it will check for all?

Just try with the stuff I recommended you, unless the game you want to mod is CS you won't get more help than this.

(Assuming the weapon is grabbed and not respawned)
PHP Code:

set_pev(idpev_nextthinkget_gametime()+n

n being the delay to respawn


Another more reliable way is to hook Ham_Respawn like I told you, then set a timer to execute
PHP Code:

ExecuteHamB(Ham_Respawnid

Like I said I haven't tested them too much, so your best bet is to test them and experiment yourself.

DarthMan 04-21-2017 09:21

Re: [H3LP] Weapon Respawn Time
 
Quote:

Originally Posted by Gabe Iggy (Post 2513898)
Just try with the stuff I recommended you, unless the game you want to mod is CS you won't get more help than this.

(Assuming the weapon is grabbed and not respawned)
PHP Code:

set_pev(idpev_nextthinkget_gametime()+n

n being the delay to respawn


Another more reliable way is to hook Ham_Respawn like I told you, then set a timer to execute
PHP Code:

ExecuteHamB(Ham_Respawnid

Like I said I haven't tested them too much, so your best bet is to test them and experiment yourself.

I have tried ur suggestion, on spawn, respawn and also think, it didn't work on any of these cases sadly.
Maybe u can show me a complete example of how it's done in CS then I can update it to work with HL and GC?

gabuch2 04-21-2017 09:50

Re: [H3LP] Weapon Respawn Time
 
Post the code to see how are you trying.

EDIT: Try this:

PHP Code:

/* Mod Template generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN    "New Plugin"
#define VERSION    "1.0"
#define AUTHOR    "Unknown"

/* Initialization */

#define RESPAWN_TIME 5.0
#define RESPAWN_ID 48575

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
RegisterHam(Ham_Respawn"weapon_shotgun""respawn_hook");
    
RegisterHam(Ham_Touch"weapon_shotgun""touch_hook"1); //post
}

public 
touch_hook(idother)
{
    
//weapon is picked up, assumed it dissapeared from the world
    //we set a task to respawn it
    
set_task(RESPAWN_TIME"respawn_task"RESPAWN_ID+id);
}

public 
respawn_hook(id)
{
    
// prevent natural respawn
    
return HAM_SUPERCEDE;
}

public 
respawn_task(tid)
{
    new 
id tid RESPAWN_ID;
    
ExecuteHam(Ham_Respawnid);


Untested. Done extremely quick.


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

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