Raised This Month: $ Target: $400
 0% 

Calling custom classes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
proffs
Senior Member
Join Date: Jul 2013
Old 07-28-2014 , 13:33   Calling custom classes
Reply With Quote #1

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"
proffs is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-28-2014 , 13:49   Re: Calling custom classes
Reply With Quote #2

PHP Code:
RegisterHamFromEntity(Ham_TraceAttack,, BLOCK"shoot_item"
You have double comma afetr Ham_TraceAttack...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
proffs
Senior Member
Join Date: Jul 2013
Old 07-28-2014 , 14:09   Re: Calling custom classes
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
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); 

Last edited by proffs; 07-28-2014 at 14:09.
proffs is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 07-28-2014 , 14:40   Re: Calling custom classes
Reply With Quote #4

Class is BLOCK, then

PHP Code:
RegisterHamFromEntity(Ham_TraceAttackBLOCK"shoot_item"
Just delete the comma
__________________
Hey ^_^
NikKOo31 is offline
proffs
Senior Member
Join Date: Jul 2013
Old 07-28-2014 , 14:55   Re: Calling custom classes
Reply With Quote #5

Quote:
Originally Posted by NikKOo31 View Post
Class is BLOCK, then

PHP Code:
RegisterHamFromEntity(Ham_TraceAttackBLOCK"shoot_item"
Just delete the comma
Guys that is justa typo and it will still not work if I remove that typo,,,,
Check the hamsandwich.inc which i quoted on
proffs is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 07-28-2014 , 17:00   Re: Calling custom classes
Reply With Quote #6

Quote:
Originally Posted by proffs View Post
Guys that is justa typo and it will still not work if I remove that typo,,,,
Check the hamsandwich.inc which i quoted on
Oh sorry, I missread

Then just
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)
    
RegisterHamFromEntity(Ham_TraceAttackent"shoot_item"
Or register at any time
PHP Code:
    new ent
    
while((ent engfunc(EngFunc_FindEntityByStringent"classname"BLOCK)) != 0)
    { 
//requires fakemeta
        
RegisterHamFromEntity(Ham_TraceAttackent"shoot_item")
    } 
__________________
Hey ^_^

Last edited by NikKOo31; 07-28-2014 at 17:01. Reason: typo
NikKOo31 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-28-2014 , 15:08   Re: Calling custom classes
Reply With Quote #7

You need to find the entity index first. It doesn't accept classnames
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
proffs
Senior Member
Join Date: Jul 2013
Old 07-28-2014 , 15:26   Re: Calling custom classes
Reply With Quote #8

Quote:
Originally Posted by YamiKaitou View Post
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 is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 07-28-2014 , 15:19   Re: Calling custom classes
Reply With Quote #9

show us how do you create that entity
baneado is offline
proffs
Senior Member
Join Date: Jul 2013
Old 07-28-2014 , 15:27   Re: Calling custom classes
Reply With Quote #10

Quote:
Originally Posted by baneado View Post
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); 
proffs 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 13:09.


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