Ability to press the created entity with the e key!

Сообщения
43
Реакции
1
Hello everyone!
There is a plugin that I wrote myself, I create an object with this plugin and when I press the e key on the object, I give some properties to the player.
However, only the middle part of the object I created can be pressed with the e key. The entire model is not pressed, how can I solve this problem?


1647166764590.png

Related line of code;
Код:
    new Float:szData[ArrayData];
    GetRandomOrigin(szData);
    
    new Entity = rg_create_entity("func_button")
    if(!Entity)
        return PLUGIN_HANDLED
        
    GlobalEntityID = Entity
    new Float:OriginThrow[3]
    new Float:OriginalChange[3]
    
    OriginThrow[0] = szData[X]
    OriginThrow[1] = szData[Y]
    OriginThrow[2] = szData[Z]
    
    OriginalChange[1] = szData[ANGLES]
    OriginalChange[0] = 0.0
    OriginalChange[2] = szData[ANGLES2]
    
    set_entvar(Entity, var_classname,NESNEMODEL)
    
    set_entvar(Entity, var_origin, OriginThrow);
    set_entvar(Entity, var_angles, OriginalChange)
    
    set_entvar(Entity, var_model, NESNEMODEL)
    set_entvar(Entity, var_modelindex, NesneModelIndex)
    set_entvar(Entity, var_movetype, MOVETYPE_FLY)
    set_entvar(Entity, var_solid, SOLID_SLIDEBOX)
                
    EntitySetGlow(Entity, random_num(0, 255),random_num(0, 255), random_num(0, 255))
    
    emit_sound(Entity, CHAN_ITEM, "boxextra/activated.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

    SetUse(Entity, "@UseEntity")
    return Entity

@UseEntity(Entity, id)
{
   set_user_health(id,100)
}
 
Сообщения
857
Реакции
532
Помог
13 раз(а)
Size of the object is equal to model?
 
Сообщения
857
Реакции
532
Помог
13 раз(а)
By changing SetSize and look for best equal value with the model
or open in milkshape editor (or another 3d editors) and check valid size
 
Сообщения
494
Реакции
341
Помог
11 раз(а)
kralik43, You can choose the size through the plugin.

Код:
#include <amxmodx>
#include <fakemeta_util>

new const MODEL[] = "models/ps/coin.mdl"; // Path to model
new g_iEnt;
new Float: g_fMins[3];
new Float: g_fMaxs[3];
new g_iNum = 1;

public plugin_precache()
{
    precache_model(MODEL);
}

public plugin_init()
{
    register_clcmd("say /box", "Box");
    register_clcmd("say /ent", "Ent");
  
    register_forward(FM_PlayerPreThink, "PlayerPreThink");
}

public Box(id, iNum)
{
    if(!g_iEnt)
        return;
      
    new sItem[128];
    format(sItem, 127, "[N: %i] [%.1f %.1f %.1f] [%.1f %.1f %.1f]", g_iNum, g_fMins[0], g_fMins[1], g_fMins[2], g_fMaxs[0], g_fMaxs[1], g_fMaxs[2]);
    new g_iMenu = menu_create(sItem, "Bbox_Handler");
  
    menu_additem(g_iMenu, "[MIN] X+");
    menu_additem(g_iMenu, "[MIN] Y+");
    menu_additem(g_iMenu, "[MIN] Z+");
    menu_additem(g_iMenu, "[MIN] X-");
    menu_additem(g_iMenu, "[MIN] Y-");
    menu_additem(g_iMenu, "[MIN] Z-");
    menu_additem(g_iMenu, "[MAX] X+");
    menu_additem(g_iMenu, "[MAX] Y+");
    menu_additem(g_iMenu, "[MAX] Z+");
    menu_additem(g_iMenu, "[MAX] X-");
    menu_additem(g_iMenu, "[MAX] Y-");
    menu_additem(g_iMenu, "[MAX] Z-");
    menu_additem(g_iMenu, "[MIN/MAX]++");
    menu_additem(g_iMenu, "[MIN/MAX]--");
    menu_additem(g_iMenu, "Result");
      
    menu_display(id, g_iMenu);
}

public Bbox_Handler(id, iMenu, iItem)
{
    if(iItem == MENU_EXIT)
        return;

    switch(iItem)
    {
        case 0: if(g_fMins[0] == 0) client_print(id, print_center, "Mins only<= 0"); else g_fMins[0] += g_iNum;
        case 1: if(g_fMins[1] == 0) client_print(id, print_center, "Mins only<= 0"); else g_fMins[1] += g_iNum;
        case 2: if(g_fMins[2] == 0) client_print(id, print_center, "Mins only<= 0"); else g_fMins[2] += g_iNum;
        case 3: g_fMins[0] -= g_iNum;
        case 4: g_fMins[1] -= g_iNum;
        case 5: g_fMins[2] -= g_iNum;  
        case 6: g_fMaxs[0] += g_iNum;
        case 7: g_fMaxs[1] += g_iNum;
        case 8: g_fMaxs[2] += g_iNum;
        case 9: if(g_fMaxs[0] == 0) client_print(id, print_center, "Maxs only>= 0"); else g_fMaxs[0] -= g_iNum;
        case 10: if(g_fMaxs[1] == 0) client_print(id, print_center, "Maxs only>= 0"); else g_fMaxs[1] -= g_iNum;
        case 11: if(g_fMaxs[2] == 0) client_print(id, print_center, "Maxs only >= 0"); else g_fMaxs[2] -= g_iNum;
        case 12: g_iNum++;
        case 13: g_iNum--;
        case 14: client_print(id, print_chat, "Mins: [%f | %f | %f] Maxs: [%f | %f | %f]", g_fMins[0], g_fMins[1], g_fMins[2], g_fMaxs[0], g_fMaxs[1], g_fMaxs[2]);
    }
  
    engfunc(EngFunc_SetSize, g_iEnt, g_fMins, g_fMaxs);
  
    Box(id, iItem / 6);
}

public Ent(id)
{
    if(g_iEnt)
        return;
  
    new Float: fOrigin[3];
    pev(id, pev_origin, fOrigin);
  
    g_iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_null"));
    set_pev(g_iEnt, pev_origin, fOrigin);
    engfunc(EngFunc_SetModel, g_iEnt, MODEL);
}

public PlayerPreThink(id)
{
    if(!is_user_alive(id))
        return;
      
    if(!pev_valid(g_iEnt))
        return;
      
    static Float: fOrigin[3], Float: fMins[3], Float: fMaxs[3];
    pev(g_iEnt, pev_origin, fOrigin);
    pev(g_iEnt, pev_mins, fMins);
    pev(g_iEnt, pev_maxs, fMaxs);
  
    xs_vec_add(fOrigin, fMins, fMins);
    xs_vec_add(fOrigin, fMaxs, fMaxs);
      
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
    write_byte(TE_BOX);
    engfunc(EngFunc_WriteCoord, fMins[0]);
    engfunc(EngFunc_WriteCoord, fMins[1]);
    engfunc(EngFunc_WriteCoord, fMins[2]);
    engfunc(EngFunc_WriteCoord, fMaxs[0]);
    engfunc(EngFunc_WriteCoord, fMaxs[1]);
    engfunc(EngFunc_WriteCoord, fMaxs[2]);
    write_short(1);
    write_byte(255);
    write_byte(0);
    write_byte(0);
    message_end();
}
say /ent - create ent
say /box - show menu

The plugin is not for public use. I'm looking for the size.
 
Сообщения
43
Реакции
1
kralik43, You can choose the size through the plugin.

Код:
#include <amxmodx>
#include <fakemeta_util>

new const MODEL[] = "models/ps/coin.mdl"; // Path to model
new g_iEnt;
new Float: g_fMins[3];
new Float: g_fMaxs[3];
new g_iNum = 1;

public plugin_precache()
{
    precache_model(MODEL);
}

public plugin_init()
{
    register_clcmd("say /box", "Box");
    register_clcmd("say /ent", "Ent");
 
    register_forward(FM_PlayerPreThink, "PlayerPreThink");
}

public Box(id, iNum)
{
    if(!g_iEnt)
        return;
     
    new sItem[128];
    format(sItem, 127, "[N: %i] [%.1f %.1f %.1f] [%.1f %.1f %.1f]", g_iNum, g_fMins[0], g_fMins[1], g_fMins[2], g_fMaxs[0], g_fMaxs[1], g_fMaxs[2]);
    new g_iMenu = menu_create(sItem, "Bbox_Handler");
 
    menu_additem(g_iMenu, "[MIN] X+");
    menu_additem(g_iMenu, "[MIN] Y+");
    menu_additem(g_iMenu, "[MIN] Z+");
    menu_additem(g_iMenu, "[MIN] X-");
    menu_additem(g_iMenu, "[MIN] Y-");
    menu_additem(g_iMenu, "[MIN] Z-");
    menu_additem(g_iMenu, "[MAX] X+");
    menu_additem(g_iMenu, "[MAX] Y+");
    menu_additem(g_iMenu, "[MAX] Z+");
    menu_additem(g_iMenu, "[MAX] X-");
    menu_additem(g_iMenu, "[MAX] Y-");
    menu_additem(g_iMenu, "[MAX] Z-");
    menu_additem(g_iMenu, "[MIN/MAX]++");
    menu_additem(g_iMenu, "[MIN/MAX]--");
    menu_additem(g_iMenu, "Result");
     
    menu_display(id, g_iMenu);
}

public Bbox_Handler(id, iMenu, iItem)
{
    if(iItem == MENU_EXIT)
        return;

    switch(iItem)
    {
        case 0: if(g_fMins[0] == 0) client_print(id, print_center, "Mins only<= 0"); else g_fMins[0] += g_iNum;
        case 1: if(g_fMins[1] == 0) client_print(id, print_center, "Mins only<= 0"); else g_fMins[1] += g_iNum;
        case 2: if(g_fMins[2] == 0) client_print(id, print_center, "Mins only<= 0"); else g_fMins[2] += g_iNum;
        case 3: g_fMins[0] -= g_iNum;
        case 4: g_fMins[1] -= g_iNum;
        case 5: g_fMins[2] -= g_iNum; 
        case 6: g_fMaxs[0] += g_iNum;
        case 7: g_fMaxs[1] += g_iNum;
        case 8: g_fMaxs[2] += g_iNum;
        case 9: if(g_fMaxs[0] == 0) client_print(id, print_center, "Maxs only>= 0"); else g_fMaxs[0] -= g_iNum;
        case 10: if(g_fMaxs[1] == 0) client_print(id, print_center, "Maxs only>= 0"); else g_fMaxs[1] -= g_iNum;
        case 11: if(g_fMaxs[2] == 0) client_print(id, print_center, "Maxs only >= 0"); else g_fMaxs[2] -= g_iNum;
        case 12: g_iNum++;
        case 13: g_iNum--;
        case 14: client_print(id, print_chat, "Mins: [%f | %f | %f] Maxs: [%f | %f | %f]", g_fMins[0], g_fMins[1], g_fMins[2], g_fMaxs[0], g_fMaxs[1], g_fMaxs[2]);
    }
 
    engfunc(EngFunc_SetSize, g_iEnt, g_fMins, g_fMaxs);
 
    Box(id, iItem / 6);
}

public Ent(id)
{
    if(g_iEnt)
        return;
 
    new Float: fOrigin[3];
    pev(id, pev_origin, fOrigin);
 
    g_iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_null"));
    set_pev(g_iEnt, pev_origin, fOrigin);
    engfunc(EngFunc_SetModel, g_iEnt, MODEL);
}

public PlayerPreThink(id)
{
    if(!is_user_alive(id))
        return;
     
    if(!pev_valid(g_iEnt))
        return;
     
    static Float: fOrigin[3], Float: fMins[3], Float: fMaxs[3];
    pev(g_iEnt, pev_origin, fOrigin);
    pev(g_iEnt, pev_mins, fMins);
    pev(g_iEnt, pev_maxs, fMaxs);
 
    xs_vec_add(fOrigin, fMins, fMins);
    xs_vec_add(fOrigin, fMaxs, fMaxs);
     
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
    write_byte(TE_BOX);
    engfunc(EngFunc_WriteCoord, fMins[0]);
    engfunc(EngFunc_WriteCoord, fMins[1]);
    engfunc(EngFunc_WriteCoord, fMins[2]);
    engfunc(EngFunc_WriteCoord, fMaxs[0]);
    engfunc(EngFunc_WriteCoord, fMaxs[1]);
    engfunc(EngFunc_WriteCoord, fMaxs[2]);
    write_short(1);
    write_byte(255);
    write_byte(0);
    write_byte(0);
    message_end();
}
say /ent - create ent
say /box - show menu

The plugin is not for public use. I'm looking for the size.
It works very well but I rotate the object I created to the right or left according to its position on the map. If the object is straight, it's fine, but if the object is looking to the right, the invisible wall still remains flat.

1647192449050.png
 
Сообщения
494
Реакции
341
Помог
11 раз(а)
kralik43, set my plugin to the same pev_angles as your plugin.
 
Сообщения
43
Реакции
1
I failed, can you do this please?

Код:
public ExtraBoxCreate()
{

    new Float:szData[ArrayData];
    GetRandomOrigin(szData);
    
    new Entity = rg_create_entity("func_button")
    if(!Entity)
        return PLUGIN_HANDLED
        
    GlobalEntityID = Entity
    new Float:OriginThrow[3]
    new Float:OriginalChange[3]
    
    OriginThrow[0] = szData[X]
    OriginThrow[1] = szData[Y]
    OriginThrow[2] = szData[Z]
    
    OriginalChange[1] = szData[ANGLES]
    OriginalChange[0] = 0.0
    OriginalChange[2] = szData[ANGLES2]
    
    set_entvar(Entity, var_classname,NESNEMODEL)
    
    set_entvar(Entity, var_origin, OriginThrow);
    set_entvar(Entity, var_angles, OriginalChange)
    
    set_entvar(Entity, var_model, NESNEMODEL)
    set_entvar(Entity, var_modelindex, NesneModelIndex)
    set_entvar(Entity, var_movetype, MOVETYPE_FLY)
    set_entvar(Entity, var_solid, SOLID_SLIDEBOX )

                
    EntitySetGlow(Entity, random_num(0, 255),random_num(0, 255), random_num(0, 255))
    
    emit_sound(Entity, CHAN_ITEM, "boxextra/activated.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

    SetUse(Entity, "@UseEntity")
    return Entity
    
}
 
Сообщения
494
Реакции
341
Помог
11 раз(а)
Add to your code before set model:
Код:
engfunc(EngFunc_SetSize, Entity, Float: {-42.0, -6.0, -1.0}, Float: {42.0, 10.0, 71.0});
The correct size will be established regardless of the angles
 
Последнее редактирование:

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу