Raised This Month: $12 Target: $400
 3% 

Object collision


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IEcliPsEI95
Junior Member
Join Date: Jul 2011
Location: Romania
Old 01-08-2016 , 11:43   Object collision
Reply With Quote #1

Hello!

I had made a plugin that makes some places on the map as special zones where you can do some things. The problem is that when you create such an zone, you have to be careful to make it so that it can't touch other entities because it will disappear when that entity will move.

Here is my code:
PHP Code:
#define MAX_NETS 10
#define TASK_LASTTOUCH 3300
#define TASK_SHOWNET 1000
#define REFRESH_TIME 2.0
#define CHANGE_TIME 5.0

new _szType[][32]=
{
    
"CTZONE",
    
"CANTEEN",
    
"CELLS",
    
"WORKOUT"
}

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    
register_forward(FM_PlayerPreThink"PlayerPreThink"0)
    for(new 
0typeZn++)
    {
        
register_touch(_szType[i], "player""FwdTouch");
    }
    for(new 
133++)
    {
        
g_LastTouch[i] = -1;
        
g_MenuType[i] = 0;
    }
}
CreateNet(szType[32], Float:firstPoint[3], Float:lastPoint[3])
{
    new 
ent
    
new Float:fCenter[3], Float:fSize[3]
    new 
Float:fMins[3], Float:fMaxs[3]
        
    for ( new 
03i++ )
    {
        
fCenter[i] = (firstPoint[i] + lastPoint[i]) / 2.0
                
        fSize
[i] = get_float_difference(firstPoint[i], lastPoint[i])
                
        
fMins[i] = fSize[i] / -2.0
        fMaxs
[i] = fSize[i] / 2.0
    
}
    
    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    
    if (
ent) {
        
engfunc(EngFunc_SetOriginentfCenter)
        
        
set_pev(entpev_classnameszType)
    
        
dllfunc(DLLFunc_Spawnent)
    
        
set_pev(entpev_movetypeMOVETYPE_FLY)
        
set_pev(entpev_solidSOLID_TRIGGER)
    
        
engfunc(EngFunc_SetSizeentfMinsfMaxs)
    }
}

public 
getZonesType (Classname[32])
{
    for(new 
0<typeZni++)
    {
        if(
equal(Classname,_szType[i]))
        {
            return 
i
        
}
    }
    return -
1
}

public 
FwdTouch(entid)
{
    if(
is_user_alive(id))
    {
        static 
szNameEnt[32]
        
pev(ent,pev_classnameszNameEnt,sizeof szNameEnt 1)
        
        static 
Float:fGameTime
        fGameTime 
get_gametime()
        if((
fGameTime g_fLastTouch[id]) > REFRESH_TIME)
        {
            
set_hudmessage(2552020, -1.00.411.01.50.10.12)
            
show_hudmessage(id"** You are in %s ! **",szNameEnt)
            
            
g_fLastTouch[id] = fGameTime
            g_LastTouch
[id] = getZonesType(szNameEnt)
            
remove_task(TASK_LASTTOUCH id)
            
set_task(CHANGE_TIME,"resetLastTouch",TASK_LASTTOUCH id)            
        }
    }

The net thing was taken from a kickball plugin.
Thanks in advance

Last edited by IEcliPsEI95; 01-08-2016 at 12:21.
IEcliPsEI95 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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