AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   respawn players where is the entity (https://forums.alliedmods.net/showthread.php?t=102601)

apocalips 09-04-2009 10:56

respawn players where is the entity
 
How can I make an entity where to revive players ,please give examples .

apocalips 09-04-2009 10:57

Re: respawn players where is the entity
 
Code:

public revive(id)
{

new reviveEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
 

 set_pev(reviveEnt, pev_classname, "revive");
 get_user_origin(id, aimVector, 3)
 
 
 IVecFVec(aimVector, fOrigin);
 
 set_pev(reviveEnt, pev_origin, fOrigin);

 engfunc(EngFunc_SetModel, reviveEnt, reviveModel);

set_pev(reviveEnt,pev_solid,SOLID_BBOX);

set_pev(reviveEnt,pev_health,500.0);
set_pev(reviveEnt,pev_max_health,500.0);
   
set_pev(reviveEnt,pev_takedamage,DAMAGE_AIM)

engfunc(EngFunc_SetSize, reviveEnt, Float:{-30.0, -30.0, -10.0}, Float:{30.0, 30.0, 10.0} )



return FMRES_IGNORED
}

 
public respawn_player(id,reviveEnt)
{
   
   
    if(!pev_valid(reviveEnt))
    return FMRES_IGNORED;

    new classname[32]
    pev(reviveEnt,pev_classname,classname,31)

    if(!equal(classname, "revive")) 
        return FMRES_IGNORED;
   
   
   
    entity_get_vector(reviveEnt,EV_VEC_origin,g_origin)
   
    if (!is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    return;

   
   
    set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
    dllfunc(DLLFunc_Think, id)
       
    dllfunc(DLLFunc_Spawn, id)
   
   
   

   
    g_origin[2] += 60
    entity_set_origin(id, g_origin);

}

I tried but not work ,and sorry for double post

Exolent[jNr] 09-04-2009 14:06

Re: respawn players where is the entity
 
Use [CODE], [PHP], or [PAWN] tags next time.

Jon 09-05-2009 07:12

Re: respawn players where is the entity
 
  1. Create the entity in plugin_init and set it's origin, store its index in a global variable.
  2. When reviving players, respawn them and set their origin to the entity's.

apocalips 09-05-2009 16:20

Re: respawn players where is the entity
 
please give examples :|

Jon 09-06-2009 05:02

Re: respawn players where is the entity
 
If you want us to give you the full code you posted in the wrong section.

apocalips 09-06-2009 05:12

Re: respawn players where is the entity
 
one example does not mean all code

Jon 09-06-2009 06:01

Re: respawn players where is the entity
 
PHP Code:

#include <amxmodx>
#include <engine>

new g_iEnt;
new 
g_fEntOrigin] = {  ......... }

public 
plugin_init()
{
    
register_plugin"""""" );
    
    
register_event"DeathMsg""EventDeathMsg""a" );
    
    
g_iEnt create_entity"info_target" );
    
entity_set_modeliEnt, .....
    
entity_set_intiEntEV_INT_solidSOLID_BBOX );
    
entity_set_sizeiEnt, .....
    
entity_set_vectoriEntEV_VEC_origin, ....
    
    
// More stuff....
    
    
}

public 
EventDeathMsg()
{
    new 
iVictim read_data);
    
    
// Respawn victim 
    
    // Maybe add an offset to the Z axis of the entity origin to make the player spawn on it
    // g_fEntOrigin[ 2 ] += something
    
    
entity_set_originiVictimg_fEntOrigin );



apocalips 09-06-2009 11:42

Re: respawn players where is the entity
 
Thank you for your example, but i want to make the entity during the game, not in the beginning of it, the problem is after i make the entity i don't seem to determine if it exists and its location :cry:

hleV 09-06-2009 13:07

Re: respawn players where is the entity
 
Here's an example.
Code:
#include <engine>   new Float:g_vecLocation[3];   public fnSaveLocation(iClient) {         // Let's save Client's location to g_vecLocation         entity_get_vector(iClient, EV_VEC_origin, g_vecLocation);         // g_vecLocation now holds the origin of Client }   public fnSpawnAndTeleport() {         // Let's create and spawn the Entity         new iEntity = create_entity("whatever_classname");           DispatchSpawn(iEntity);           // We can also check if created Entity is valid         if (!is_valid_ent(iEntity))                 return;           // Now we can teleport the Entity to the location         // that is saved in g_vecLocation         entity_set_origin(iEntity, g_vecLocation);         // Done }


All times are GMT -4. The time now is 15:14.

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