Raised This Month: $ Target: $400
 0% 

Register Touch...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vancold
Member
Join Date: Jan 2015
Old 09-03-2015 , 02:33   Re: Register Touch...
Reply With Quote #1

Quote:
Originally Posted by redivcram View Post
I tried fakemeta and still get the same results... It spawns, but when I touch it nothing happens...

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new gClassName[] = "weponbocks"
new gEntModel[] = "models/w_weaponbox.mdl"
new Score[33]

public 
plugin_init()
{
    
register_plugin("EntFM""1.0""EsprimoP")
    
    
register_clcmd("say /spawnent""cmd_spawn_entity")
    
register_clcmd("say /myscore""cmd_show_score")
    
    
register_forward(FM_Touch"FwTouchEnt")
}

public 
plugin_precache()
{
    
precache_model(gEntModel)
}

public 
cmd_show_score(id)
{
    
client_print(idprint_chat"Your score: %d"Score[id])
    return 
PLUGIN_HANDLED
}


public 
cmd_spawn_entity(id)
{
    new 
origin[3]
    
get_user_origin(idorigin3)
    
    new 
weaponbox engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    
    if(!
weaponbox)
        return 
PLUGIN_HANDLED
    
    
new Float:vec[3]
    
IVecFVec(originvec)
    
    
set_pev(weaponboxpev_classnamegClassName)
    
engfunc(EngFunc_SetOriginweaponboxvec)
    
engfunc(EngFunc_SetModelweaponboxgEntModel)
    
set_pev(weaponboxpev_solidSOLID_TRIGGER)
    
engfunc(EngFunc_SetSizeweaponboxFloat:{-50.0, -50.0, -50.0}, Float:{50.050.050.0})
    
set_pev(weaponboxpev_ownerid)
    
dllfunc(DLLFunc_Spawnweaponbox)
    
    return 
PLUGIN_HANDLED
}

public 
FwTouchEnt(PtdPtr)
{
    new 
ClassName[33], weaponbox Ptdid Ptr
    pev
(Ptdpev_classnameClassNamesizeof(ClassName) - 1)
    
    if(!
equal(ClassNamegClassName))
    {
        
weaponbox Ptr
        id 
Ptd
        
        pev
(Ptrpev_classnameClassNamesizeof(ClassName) - 1)
        
        if(!
equal(ClassNamegClassName))
            return
    }
    
    new 
Owner pev(weaponboxpev_owner)
    
    if(
Owner !=  id)
        return

    
Score[id]++
    
client_print(idprint_chat"You picked up a Weapon Box and earned 1 score")

You could use RegisterHam Ham_Touch.
Works fine. just read up on it

Last edited by Vancold; 09-03-2015 at 02:34.
Vancold is offline
teh ORiON
Member
Join Date: Sep 2011
Location: Denmark
Old 09-03-2015 , 10:05   Re: Register Touch...
Reply With Quote #2

Hey, you gotta set solid and size after the entity has been spawned, this should work for you:

Spoiler


EDIT: There isn't really a reason to call the spawn function for the entity in the first place I think, so just remove "dllfunc(DLLFunc_Spawn, weaponbox)".

And the reason is that the spawn function for CPointEntity sets the entity's solid to SOLID_NOT.

PHP Code:
// Landmark class
void CPointEntity :: Spawnvoid )
{
    
pev->solid SOLID_NOT;
//    UTIL_SetSize(pev, g_vecZero, g_vecZero);

__________________
CTFGasGrenade :: GasThePlace(void)

Last edited by teh ORiON; 09-03-2015 at 10:37.
teh ORiON is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-03-2015 , 10:57   Re: Register Touch...
Reply With Quote #3

https://github.com/Arkshine/CSSDK/bl...pons.cpp#L1412
WeaponBox has a specific spawn function, which can be called by simply using Ham_Spawn. It seems you forgot to set movetype MOVETYPE_TOSS.
__________________
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 09-03-2015 , 14:02   Re: Register Touch...
Reply With Quote #4

for god sake i just posted on the previous page what your entity code and touch code should look like
is it that hard to edit the model line?
Depresie 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 22:14.


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