AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Calling custom classes (https://forums.alliedmods.net/showthread.php?t=245115)

proffs 07-28-2014 13:33

Calling custom classes
 
It doesn't work to calling custom classes
I can't compile it.

Code:

Error: Invalid expression, assumed zero on line 19
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "g"
#define VERSION "1.0"
#define AUTHOR "g"

#define RIC "debris/metal6.wav"
#define BLOCK "BMd_Block"

public plugin_precache()
    
precache_sound(RIC)


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHamFromEntity(Ham_TraceAttack,, BLOCK"shoot_item")
}

public 
shoot_item(entattackerFloat:damageFloat:direction[3], tracedamagebits)
{
    static 
Float:endpoint[3]
    
get_tr2(traceTR_vecEndPosendpoint)
    
draw_spark(endpoint)
    
    
engfunc(EngFunc_EmitSoundentCHAN_ITEMRIC0.5ATTN_STATIC0PITCH_NORM)

    return 
HAM_IGNORED
}

stock draw_spark(const Float:origin[3])
{
    
message_begin(MSG_ALLSVC_TEMPENTITY)
    
write_byte(TE_SPARKS)
    
engfunc(EngFunc_WriteCoordorigin[0])
    
engfunc(EngFunc_WriteCoordorigin[1])
    
engfunc(EngFunc_WriteCoordorigin[2])
    
message_end()


Class from main plugin:
PHP Code:

new const g_block_classname[] =                 "BMd_Block"


Flick3rR 07-28-2014 13:49

Re: Calling custom classes
 
PHP Code:

RegisterHamFromEntity(Ham_TraceAttack,, BLOCK"shoot_item"

You have double comma afetr Ham_TraceAttack...

proffs 07-28-2014 14:09

Re: Calling custom classes
 
Quote:

Originally Posted by Flick3rR (Post 2175231)
PHP Code:

RegisterHamFromEntity(Ham_TraceAttack,, BLOCK"shoot_item"

You have double comma afetr Ham_TraceAttack...

I need to add classid there I think. I don' know how to do it.

From the hamsandwhich.inc
PHP Code:

native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0); 


NikKOo31 07-28-2014 14:40

Re: Calling custom classes
 
Class is BLOCK, then

PHP Code:

RegisterHamFromEntity(Ham_TraceAttackBLOCK"shoot_item"

Just delete the comma :crab:

proffs 07-28-2014 14:55

Re: Calling custom classes
 
Quote:

Originally Posted by NikKOo31 (Post 2175262)
Class is BLOCK, then

PHP Code:

RegisterHamFromEntity(Ham_TraceAttackBLOCK"shoot_item"

Just delete the comma :crab:

Guys that is justa typo and it will still not work if I remove that typo,,,,
Check the hamsandwich.inc which i quoted on

YamiKaitou 07-28-2014 15:08

Re: Calling custom classes
 
You need to find the entity index first. It doesn't accept classnames

baneado 07-28-2014 15:19

Re: Calling custom classes
 
show us how do you create that entity

proffs 07-28-2014 15:26

Re: Calling custom classes
 
Quote:

Originally Posted by YamiKaitou (Post 2175278)
You need to find the entity index first. It doesn't accept classnames

And How do I do that? I am new to entities lol.
I just know to create it and make it breakable etc..

proffs 07-28-2014 15:27

Re: Calling custom classes
 
Quote:

Originally Posted by baneado (Post 2175284)
show us how do you create that entity

PHP Code:

new ent create_entity("info_target");
        if ( !
is_valid_ent(ent) ) return 0;
       
        
entity_set_string(entEV_SZ_classnameg_block_classname);
        
entity_set_int(entEV_INT_solidSOLID_BBOX);
        
entity_set_int(entEV_INT_movetypeMOVETYPE_NONE); 


baneado 07-28-2014 16:07

Re: Calling custom classes
 
you must change the BLOCK on RegisterHam by "info_target" and then check if the classname of the entity is BLOCK inside the function.

I see you change BLOCK per g_block_classname, so use that constant

ohh and change RegisterHamFromEntity by only RegisterHam


All times are GMT -4. The time now is 13:09.

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