Raised This Month: $32 Target: $400
 8% 

Solved Can I create new entity with property in Game Engine using AMXX


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LiZou Mapper
Member
Join Date: Oct 2018
Location: Morocco
Old 08-10-2020 , 04:21   Can I create new entity with property in Game Engine using AMXX
Reply With Quote #1

Hello :)
So, I try create new entities to use that in maps (mapping), entity when triggered print message in chat !
But it's not work, when connected server,when triggered it
Create entity in the information's
classname : game_cprinter
keyValue :
targetname : Name
message : Message
spawnflags:
1:All Players
2:Remove On fire

PHP Code:
/*
    Classname : game_cprinter 
    Role : Print Message in chat !

    KeyValue :
        targetname : Name 
        message : Message 

    Spawn Flags : 
        1: All Players
        2: Remove On fire
*/

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
// #include <reapi>

public plugin_init()
{
    
// Load Plugin
    
register_plugin("[Entity] Game Chat Printer""1.0""LiZou Mapper")

    
// Ham
    
RegisterHam(Ham_Use"game_cprinter""CGameChatPrinter")
}

public 
CGameChatPrinter(const Entity, const Activator)
{
    new 
Message/*, Spawnflags*/

    // Get message from entity 
    // get_entvar(Entity, var_message, Message)
    // get_entvar(Entity, var_spawnflags, Spawnflags)
    
pev(Entitypev_messageMessage)

    
// Print message for all players ! 
    
client_print_color(0print_chat"%s"Message)
}

/*
stock mapper_remove_entity(const Entity)
{
        // Remove entity from map !
    engfunc(EngFunc_RemoveEntity, Entity)
}
*/ 
but when connected server, i see it in console !
Code:
L 08/10/2020 - 07:56:51: [HAMSANDWICH] Failed to retrieve classtype for "game_cprinter", hook for "CGameChatPrinter" not active.
L 08/10/2020 - 07:56:51: [AMXX] Run time error 10 (plugin "entity_game_cprinter.amxx") (native "RegisterHam") - debug not enabled!
L 08/10/2020 - 07:56:51: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quote
You can see photo's
Attached Images
File Type: jpg lizou2.jpg (59.6 KB, 80 views)
File Type: jpg lizou.jpg (97.2 KB, 92 views)
__________________

-------------
My Maps !
Zombie Escape Mod !
-------------


Last edited by LiZou Mapper; 06-21-2022 at 21:53. Reason: change little something
LiZou Mapper is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-10-2020 , 07:20   Re: Problem with hamsandwich ham_use !
Reply With Quote #2

I assume that your entity class is a button, so you need to register your ham func as a post function, because the message is triggered AFTER you pressed that button.
btw, I see you tried to make it with reAPI, so, you can try also engine's register_think():
register_think(const Classname[], const function[]);
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
LiZou Mapper
Member
Join Date: Oct 2018
Location: Morocco
Old 08-10-2020 , 17:13   Re: Problem with hamsandwich ham_use !
Reply With Quote #3

Quote:
Originally Posted by Shadows Adi View Post
I assume that your entity class is a button, so you need to register your ham func as a post function, because the message is triggered AFTER you pressed that button.
btw, I see you tried to make it with reAPI, so, you can try also engine's register_think():
register_think(const Classname[], const function[]);
Not exactly, from func_button can be triggered entity from another entity For example:
trigger_multiple or trigger_relay or func_door, the important when entity triggered from another entity :)
__________________

-------------
My Maps !
Zombie Escape Mod !
-------------

LiZou Mapper is offline
LiZou Mapper
Member
Join Date: Oct 2018
Location: Morocco
Old 08-10-2020 , 17:29   Re: Problem with hamsandwich ham_use !
Reply With Quote #4

Quote:
Originally Posted by Shadows Adi View Post
I assume that your entity class is a button, so you need to register your ham func as a post function, because the message is triggered AFTER you pressed that button.
btw, I see you tried to make it with reAPI, so, you can try also engine's register_think():
register_think(const Classname[], const function[]);
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <reapi>

public plugin_init()
{
    
// Load plugin 
    
register_plugin("[Entity] Chat Printer""1.0""LiZou Mapper")

    
// Think 
    
register_think("game_cprinter""CGameChatPrinter")
}

public 
CGameChatPrinter(Entity)
{
    new 
MessageSpawnflags
    
// Get message from entity 
    
get_entvar(Entityvar_messageMessage)

    
// Get spawnflag from entity 
    // get_entvar(Entity, var_spawnflags, Spawnflags)

    
client_print_color(0print_chat"%s"Message)

    
// Print chat for player 
    /*if(Spawnflags == 0)
        client_print_color(Entity, print_chat, "%s", Message)

    if(Spawnflags & 1)
        client_print_color(0, print_chat, "%s", Message)

    if(Spawnflags & 2)
        Util_RemoveEntity(Entity)*/
}

public 
Util_RemoveEntity(const Entity)
{
    
engfunc(EngFunc_RemoveEntityEntity)

Not work !
__________________

-------------
My Maps !
Zombie Escape Mod !
-------------

LiZou Mapper is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-10-2020 , 20:29   Re: Problem with hamsandwich ham_use !
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <reapi>

public plugin_init()
{
    
// Load plugin 
    
register_plugin("[Entity] Chat Printer""1.0""LiZou Mapper")

    
// Think 
    
register_think("game_cprinter""CGameChatPrinter")

    
register_clcmd("say /test""clcmd_test");
}

public 
clcmd_test(id)
{
    new 
ent = -1;
    while( (
ent=engfunc(EngFunc_FindEntityByStringent"classname""game_cprinter")) > )
    {
        
DLLFunc(DLLFunc_Thinkent);
    }
}

public 
CGameChatPrinter(Entity)
{
    new 
Message[64], Spawnflags
    
// Get message from entity 
    
get_entvar(Entityvar_messageMessagecharsmax(Message))

    
// Get spawnflag from entity 
    // get_entvar(Entity, var_spawnflags, Spawnflags)

    
client_print_color(0print_chat"%s"Message)

    
// Print chat for player 
    /*if(Spawnflags == 0)
        client_print_color(Entity, print_chat, "%s", Message)

    if(Spawnflags & 1)
        client_print_color(0, print_chat, "%s", Message)

    if(Spawnflags & 2)
        Util_RemoveEntity(Entity)*/
}

public 
Util_RemoveEntity(const Entity)
{
    
engfunc(EngFunc_RemoveEntityEntity)

try to call think manually..

and btw Message should be string not an integer.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-10-2020 at 20:30.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
LiZou Mapper
Member
Join Date: Oct 2018
Location: Morocco
Old 08-10-2020 , 21:37   Re: Problem with hamsandwich ham_use !
Reply With Quote #6

Quote:
try to call think manually..

and btw Message should be string not an integer.
not working
__________________

-------------
My Maps !
Zombie Escape Mod !
-------------


Last edited by LiZou Mapper; 06-21-2022 at 21:54.
LiZou Mapper is offline
LiZou Mapper
Member
Join Date: Oct 2018
Location: Morocco
Old 08-10-2020 , 21:38   Re: Problem with hamsandwich ham_use !
Reply With Quote #7

Like in client side :
PHP Code:
/* 
    ==== CONSOLE ENTITIES ====
    They do stuff in the console.
*/

#include "extdll.h"
#include "util.h"
#include "cbase.h"

class CTriggerConsolePrinter : public CBaseEntity
{
public:
    
void Spawn();
    
void KeyValue(KeyValueData *pkvd);

    
void Use(CBaseEntity *pActivatorCBaseEntity *pCallerUSE_TYPE useTypefloat value);

private:
    
string_t m_iszMessage;
};

LINK_ENTITY_TO_CLASS(trigger_conprintCTriggerConsolePrinter);

void CTriggerConsolePrinter::Spawn()
{
    
// Nothing
}

void CTriggerConsolePrinter::KeyValue(KeyValueData *pkvd)
{
    if (
FStrEq(pkvd->szKeyName"conmessage"))
    {
        
m_iszMessage ALLOC_STRING(pkvd->szValue);
        
pkvd->fHandled TRUE;
    }

    else
        
CBaseEntity::KeyValue(pkvd);
}

void CTriggerConsolePrinter::Use(CBaseEntity *pActivatorCBaseEntity *pCallerUSE_TYPE useTypefloat value)
{
    
ALERT(at_console"%s"STRING(m_iszMessage));

__________________

-------------
My Maps !
Zombie Escape Mod !
-------------

LiZou Mapper is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-11-2020 , 03:18   Re: i can't create new entity game_cprinter
Reply With Quote #8

You can't create a new entity out of thin air. It needs to be defined in the game code first. You can try creating a module and using LINK_ENTITY_TO_CLASS to create a new entity type.
__________________
HamletEagle is offline
LiZou Mapper
Member
Join Date: Oct 2018
Location: Morocco
Old 08-13-2020 , 23:05   Re: i can't create new entity game_cprinter
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
You can't create a new entity out of thin air. It needs to be defined in the game code first. You can try creating a module and using LINK_ENTITY_TO_CLASS to create a new entity type.
thanks
i'm understand
__________________

-------------
My Maps !
Zombie Escape Mod !
-------------


Last edited by LiZou Mapper; 11-30-2020 at 14:29.
LiZou Mapper is offline
Reply


Thread Tools
Display Modes

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 17:20.


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