AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawn some NPC after X seconds. (https://forums.alliedmods.net/showthread.php?t=147683)

dFF 01-12-2011 11:48

Respawn some NPC after X seconds.
 
I tried http://forums.alliedmods.net/showthread.php?t=21819 but doesn't work very well. Error is: [FAKEMETA] Invalid entity

Origins is Ok, but the entity id is wrong.

Arkshine 01-12-2011 11:50

Re: Respawn some NPC after X seconds.
 
Tried what exactly. Show the code here.

dFF 01-12-2011 11:56

Re: Respawn some NPC after X seconds.
 
Here is the partial code I used:
PHP Code:

public fw_touch(toucherent)
{
    
//check valid...

    
new Float:curOrigin[3]
    
pev(entpev_origincurOrigin)
    
    new 
data[3]
    
FVecIVec(curOrigindata)

    
set_task(5.0"RecreateEnt"entdata3)

    
engfuncEngFunc_RemoveEntityent )
}

public 
RecreateEntiEntitydata[3])
{
    
client_print03"%d | %d %d %d"iEntitydata[0],data[1],data[2])
    
    new 
Float:origin[3]
    
IVecFVec(dataorigin)
    
    
engfuncEngFunc_SetOriginiEntityorigin // here is the fault, server freeze X seconds.
    
    //some stuff


Debug Test

Code:

Entity ID | Entity Origin
10632 | 552 560 56


hleV 01-12-2011 12:07

Re: Respawn some NPC after X seconds.
 
Code:
public RecreateEnt( iEntity, data[3])
change to
Code:
public RecreateEnt( data[3], iEntity)

dFF 01-12-2011 12:24

Re: Respawn some NPC after X seconds.
 
Yep, working if change this
PHP Code:

set_task(5.0"RecreateEnt"entdata3


to
set_task(5.0, "RecreateEnt", 0, data, 3)

But have another problem, game freeze during the re-create ent / or players is blocked.

hleV 01-12-2011 12:52

Re: Respawn some NPC after X seconds.
 
It seems that you're setting origin to an entity which doesn't exist (as you remove it). If you provide 0 as entity, it will set origin to the 0th entity, which is not the entity you want to set origin to.

dFF 01-12-2011 13:00

Re: Respawn some NPC after X seconds.
 
Yes, You're right. But I don't have a idea how to restore my entity (NPC).
For example I spawn some NPCs, and when player touch any NPC, the NPC is removed and after 5 seconds she restored in the same origin after spawn first time. How to make this ?

Edit.

dFF 01-14-2011 05:33

Re: Respawn some NPC after X seconds.
 
Any ideas ? Or How to check if an entity is already spawned in some origin ?

Elusive138 01-14-2011 06:42

Re: Respawn some NPC after X seconds.
 
PointContents(vOrigin)

// engfunc(EngFunc_PointContents, Float:origin) return values
#define CONTENTS_EMPTY -1
#define CONTENTS_SOLID -2
#define CONTENTS_WATER -3
#define CONTENTS_SLIME -4
#define CONTENTS_LAVA -5
#define CONTENTS_SKY -6
#define CONTENTS_ORIGIN -7 // Removed at csg time
#define CONTENTS_CLIP -8 // Changed to contents_solid
#define CONTENTS_CURRENT_0 -9
#define CONTENTS_CURRENT_90 -10
#define CONTENTS_CURRENT_180 -11
#define CONTENTS_CURRENT_270 -12
#define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14
#define CONTENTS_TRANSLUCENT -15
#define CONTENTS_LADDER -16
#define CONTENT_FLYFIELD -17
#define CONTENT_GRAVITY_FLYFIELD -18
#define CONTENT_FOG -19

dFF 01-14-2011 07:36

Re: Respawn some NPC after X seconds.
 
Tried and doesn't work.


All times are GMT -4. The time now is 01:59.

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