AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   drop dead body (https://forums.alliedmods.net/showthread.php?t=127397)

drekes 05-20-2010 15:07

drop dead body
 
Is it possible, when a player dies, to make his body go up in the air for about 100 units, and then drop down until it touches the ground, and then remove it?

Exolent[jNr] 05-20-2010 19:36

Re: drop dead body
 
1. Block the ClCorpse messages.
2. Hook when player dies.
3. When player dies, create an entity with the player's model and set it to the death sequence.
4. You can then play with the entity how you want.

drekes 05-20-2010 19:49

Re: drop dead body
 
sounds like a lot of new things for me.
but new things == new challenge
and new challenge == lots of fun.

Thanks exolent.

drekes 05-20-2010 20:48

Re: drop dead body
 
I make this, but it give runtime error 4: index out of bounds.

normally i would check if he is alive and if he is a player to fix this, but this is none of those, and idea how i can fix this. And if this sucks, tell it and i'll do something else instead.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <cstrike>

new Floatheight[33]

new 
boolFirstThink[33] = false
new boolStopThink[33] = false

public plugin_init()
{    
    
register_plugin("Mario Bros Death""1.0""Drekes")
    
    
register_event("ClCorpse""Event_ClCorpse""b")
    
register_event("DeathMsg""Event_DeathMsg""b")
    
    
register_forward(FM_Think"Fw_Think")
}

public 
Event_ClCorpse(id)
    return 
PLUGIN_HANDLED
    
public Event_DeathMsg(id)
{
    
// Get info from real corpse
    
new model[12]
    
cs_get_user_model(idmodel11)

    new 
Floatorigin[3]
    
pev(idpev_originorigin)
    
    
make_new_corpse(idmodelFloatorigin)
}

public 
make_new_corpse(idmodel[12], Floatorigin[3])
{
    
// Start making new corpse
    
new corpse engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));

    
set_pev(corpsepev_classname"fake_corpse")

    
engfunc(EngFunc_SetModelcorpsemodel)
    
set_pev(corpsepev_solid2)
    
set_pev(corpsepev_originorigin)

    
set_pev(corpsepev_animtime2.0)
    
set_pev(corpsepev_framerate1.0)
    
set_pev(corpsepev_sequence54)

    
FirstThink[corpse] = true
    StopThink
[corpse] = false
}

public 
Fw_Think(corpse)
{
    if(
StopThink[corpse])
        return

    if(
FirstThink[corpse])
    {    
        
height[corpse] = 0.0
        FirstThink
[corpse] = false
    
}

    new 
classname[32]
    new 
FloatDeadOrigin[3]

    
pev(corpsepev_classnameclassname31)
    
pev(corpsepev_originDeadOrigin)


    if (!
equal(classname"fake_corpse"))
        return

    
set_pev(corpsepev_nextthinkget_gametime() + 0.1)
    
dllfunc(DLLFunc_Thinkcorpse)

    
height[corpse] += 0.5

    
if(height[corpse] >= 100.0)
    {
        
drop_corpse(corpse)
        
StopThink[corpse] = true
    
}
}

public 
drop_corpse(corpse)
{
    if(
FirstThink[corpse])
    {    
        
height[corpse] = 0.0
        FirstThink
[corpse] = false
    
}

    new 
classname[32]
    new 
FloatDeadOrigin[3]

    
pev(corpsepev_classnameclassname31)
    
pev(corpsepev_originDeadOrigin)


    if (!
equal(classname"fake_corpse"))
        return

    
height[corpse] -= 0.5

    
if(height[corpse] <= -100.0)
    {
        
drop_corpse(corpse)
    }



Exolent[jNr] 05-20-2010 20:56

Re: drop dead body
 
http://forums.alliedmods.net/showthread.php?t=127156

drekes 05-20-2010 21:07

Re: drop dead body
 
i looked at it, but i don't understand it. I have almost no experience with engine.

And i also say this:
Quote:


It would be better to use special entity values, like pev_[i|f|v|e]user[1|2|3|4].
but i don't understand that to. Could you explain your example code a bit?

EDIT: I just saw i made a big mistake in Event_DeathMsg to.

Exolent[jNr] 05-20-2010 21:13

Re: drop dead body
 
For your code:
Code:
#define SetFirstThink(%1,%2) entity_set_int( %1, EV_INT_iuser1, %2 ) #define CheckFirstThink(%1) entity_get_int( %1, EV_INT_iuser1 ) #define SetStopThink(%1,%2) entity_set_int( %1, EV_INT_iuser2, %2 ) #define CheckStopThink(%1) entity_get_int( %1, EV_INT_iuser2 ) #define SetHeight(%1,%2) entity_set_float( %1, EV_FL_fuser1, %2 ) #define GetHeight(%1) entity_get_float( %1, EV_FL_fuser1 )

Example:
Code:
public FwdThink( iEntity ) {     if( CheckStopThink( iEntity ) )     {         return;     }         if( CheckFirstThink( iEntity ) )     {         SetFirstThink( iEntity, 0 );     }         new Float:flHeight = GetHeight( iEntity );         flHeight += 0.5;         SetHeight( iEntity, flHeight ); }

drekes 05-20-2010 21:19

Re: drop dead body
 
I don't understand how i should use these.
I think i'll beter stop with this, it's looks to complicated.

EDIT: I think i understand it now, i'm gonna try some stuff and let you know how it goes

Kreation 05-20-2010 21:27

Re: drop dead body
 
Quote:

Originally Posted by drekes (Post 1186462)
I think i'll beter stop with this, it's looks to complicated.

Follow the leadership of Exolent, thou will prevail.

drekes 05-20-2010 22:01

Re: drop dead body
 
i now got this code and it crashes my game as soon as i spawn.

i don't know what i did wrong.
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <cstrike>

#define SetFirstThink(%1,%2) entity_set_int( %1, EV_INT_iuser1, %2 ) 
#define CheckFirstThink(%1) entity_get_int( %1, EV_INT_iuser1 ) 

#define SetStopThink(%1,%2) entity_set_int( %1, EV_INT_iuser2, %2 ) 
#define CheckStopThink(%1) entity_get_int( %1, EV_INT_iuser2 ) 

#define SetHeight(%1,%2) entity_set_float( %1, EV_FL_fuser1, %2 ) 
#define GetHeight(%1) entity_get_float( %1, EV_FL_fuser1 ) 

// new Float: height[33]

new boolcorpse_up
new boolcorpse_down

public plugin_init()
{    
    
register_plugin("Mario Bros Death""1.0""Drekes")
    
    
register_event("ClCorpse""Event_ClCorpse""b")
    
register_event("DeathMsg""Event_DeathMsg""b")
    
    
register_forward(FM_Think"Fw_Think")
}

public 
Event_ClCorpse(id)
    return 
PLUGIN_HANDLED
    
public Event_DeathMsg(id)
{
    
// Get info from real corpse
    
new model[12]
    
cs_get_user_model(idmodel11)

    new 
Floatorigin[3]
    
pev(idpev_originorigin)
    
    
make_new_corpse(idmodelFloatorigin)
    
}

public 
make_new_corpse(idmodel[12], Floatorigin[3])
{
    
// Start making new corpse
    
new corpse engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));

    
set_pev(corpsepev_classname"fake_corpse")

    
engfunc(EngFunc_SetModelcorpsemodel)
    
set_pev(corpsepev_solid2)
    
set_pev(corpsepev_originorigin)

    
set_pev(corpsepev_animtime2.0)
    
set_pev(corpsepev_framerate1.0)
    
set_pev(corpsepev_sequence54)

    
corpse_up true
}

public 
Fw_Think(corpse)
{
    if(!
is_valid_ent(corpse))
        return 
        
    if(
CheckStopThink(corpse))
        return

    if(
CheckFirstThink(corpse))
        
SetFirstThink(corpse0)

    new 
FloatflHeight GetHeight(corpse)

    if(
corpse_up)
    {
        if(
GetHeight(corpse) >= 100.0)
        {
            
corpse_up false
            corpse_down 
true
        
}
        
flHeight += 0.5
    
}

    if(
corpse_down)
    {
        if(
GetHeight(corpse) <= -100.0)
        {
            
corpse_down false
        
}
        
flHeight -= 0.5
    
}
    
SetHeight(corpseflHeight)

    if(!
corpse_up && !corpse_down)
        
remove_entity(corpse)




All times are GMT -4. The time now is 03:34.

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