AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Brekaeable ent. (https://forums.alliedmods.net/showthread.php?t=86416)

xbatista 02-25-2009 09:05

Brekaeable ent.
 
This is just an example from tutorial, 1.how to do breakeble ent and have for example 200health???2.And you can create only 1 ent per round.3.And delete it on round end???.I need an example.
PHP Code:

// fakemeta
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_Classname[] = "func_car"
new g_Model[] = "models/car.mdl"

public plugin_init()
{
    
register_plugin("OMFG","HAX","LOL")
   
    
register_clcmd("say car","CmdSayCar")
   
    
register_forward(FM_Touch,"ForwardTouch")
}

public 
plugin_precache()
    
precache_model(g_Model)

public 
CmdSayCar(id)
{
    new 
Ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    
set_pev(Ent,pev_classname,g_Classname)
    
engfunc(EngFunc_SetModel,Ent,g_Model)
    
set_pev(Ent,pev_solid,SOLID_TRIGGER)
    
engfunc(EngFunc_SetSize,Ent,Float:{-50.0,-50.0,-50.0},Float:{50.0,50.0,50.0})
    
set_pev(Ent,pev_owner,id)
}

public 
ForwardTouch(Ptd,Ptr)
{
    new 
Classname[33],Ent Ptd,id Ptr
    pev
(Ptd,pev_classname,Classname,32)
   
    if(!
equal(Classname,g_Classname))
    {
        
Ent Ptr
        id 
Ptd
       
        pev
(Ptr,pev_classname,Classname,32)
       
        if(!
equal(Classname,g_Classname))
            return
    }
   
    new 
Owner pev(Ent,pev_owner)
    if(
Owner != id)
        return
   
    
client_print(id,print_chat,"You have used this car. Due to time purposes, I'm not going to add code beyond this.")



xPaw 02-25-2009 09:14

Re: Brekaeable ent.
 
set him pev_health to 200.0 and you will get breakable, about one per round, you can use global variable for that

xbatista 02-25-2009 09:24

Re: Brekaeable ent.
 
Set_pev health for ent?
Quote:

about one per round, you can use global variable for that
How to do this? :mrgreen:
Example please ;)

Dr.G 02-25-2009 11:03

Re: Brekaeable ent.
 
set_pev(Ent, pev_health, 200)... and your classname should be func_breakable

xPaw 02-25-2009 11:10

Re: Brekaeable ent.
 
Dr.G it doesnt effect afaik

ConnorMcLeod 02-25-2009 11:16

Re: Brekaeable ent.
 
You should also set pev_takedamage

Quote:

Originally Posted by hlsdk_const.inc
// new Float:takedamage, pev(entity, pev_takedamage, takedamage) values
#define DAMAGE_NO 0.0
#define DAMAGE_YES 1.0
#define DAMAGE_AIM 2.0


xbatista 02-25-2009 11:18

Re: Brekaeable ent.
 
So I must do this?
set_pev(entity, pev_health, 200)
set_pev(entity, pev_takedamage, 1.0) ??
Quote:

2.And you can create only 1 ent per round.3.And delete/remove it on round end???
And how about this?

ConnorMcLeod 02-25-2009 11:23

Re: Brekaeable ent.
 
set_pev(entity, pev_takedamage, DAMAGE_YES) would be better (for clarity).

You may have to spawn the entity, dunno.

xbatista 02-25-2009 11:27

Re: Brekaeable ent.
 
Thx to all.

xbatista 02-25-2009 15:00

Re: Brekaeable ent.
 
And the last question ;) How to create a sprite effect of killed wall? :mrgreen:
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "XxX"
#define AUTHOR "xbatista"
#define VERSION "0.1"
 
new g_Classname1[] = "wall_brekeable"
new WallModel[] = "models/wall.mdl"

public plugin_precache()
{
    
precache_model(WallModel)
}
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("+wall""wall"
    
    
register_forward(FM_Touch,"ForwardTouch")
}
public 
wall(id

    new 
went engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall")) 
    new 
Float:flOrigin[3]
    new 
aVector[3]
    
get_user_origin(idaVector3)
    
IVecFVec(aVectorflOrigin)
    
set_pev(wentpev_originflOrigin)
    
    
set_pev(went,pev_classname,g_Classname1
    
engfunc(EngFunc_SetModelwentWallModel
    
set_pev(went,pev_solid,SOLID_BBOX
    
set_pev(wentpev_health200.0)
    
set_pev(wentpev_takedamageDAMAGE_YES)
    
engfunc(EngFunc_SetSizewentFloat:{-5.0, -90.0, -150.0}, Float:{5.090.0150.0}) 


public 
ForwardTouch(Ptd,Ptr

    if(!
pev_valid(Ptd))
            return 
FMRES_IGNORED;
    
    new 
Classname[33]
    
pev(Ptd,pev_classname,Classname,32
    
    if(!
equal(Classname,g_Classname1)) 
            return 
FMRES_IGNORED;

    return 
FMRES_IGNORED;




All times are GMT -4. The time now is 16:55.

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