AlliedModders
XFactor Servers

Give Item (Engine)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Karma: Good
Location: Lithuania
Old 11-06-2009 , 11:11   Give Item (Engine)
Reply With Quote #1

Code:
#include <amxmodx> #include <engine>   stock Engine_GiveItem(const Client, const Weapon[]) {         new Entity = create_entity(Weapon);           if (!is_valid_ent(Entity))                 return;           DispatchSpawn(Entity);         fake_touch(Entity, Client); }
4 natives. No need for more if used carefully. I wonder if this can be treated as the best method after Fun's. I did some tests (but not too many) and it worked flawlessly.

THIS HAS NOTHING TO DO WITH USING ENGINE INSTEAD OF FUN!
__________________
UT3 Announcer Rewards
I never created plugins and have no idea how to script.
So don't fucking PM me with your fucking requests!

Last edited by hleV; 11-06-2009 at 11:35..
hleV is offline
xPaw
Veteran Member
Karma: Good
Location: Reach The Sun
Old 11-06-2009 , 11:32   Re: Give Item (Engine)
Reply With Quote #2

I'd use fun anyway, its faster than that stock
__________________

[ My homepage - My plugins ]
[ I DONT HELP IN PM ]

Last edited by xPaw; 11-06-2009 at 11:34..
xPaw is offline
ot_207
Veteran Member
Karma: Good
Location: Right above you ... [Ro]
Old 11-06-2009 , 11:51   Re: Give Item (Engine)
Reply With Quote #3

Quote:
Originally Posted by xPaw View Post
I'd use fun anyway, its faster than that stock
The fakemeta flu has passed now the engine flu season has come...
__________________
My approved plug-ins | Do not let the good music die! | Good for newbies! | Problems?
No support/suggestions through PM! Post in plugin topic!
ot_207 is offline
Jon
Veteran Member
Karma: Neutral
Old 11-06-2009 , 11:55   Re: Give Item (Engine)
Reply With Quote #4

Quote:
Originally Posted by hleV View Post
THIS HAS NOTHING TO DO WITH USING ENGINE INSTEAD OF FUN!
Then this thread is useless. Fun exists and is better/more efficient.
__________________
My plugins AGAGAGAGAGAGAAAAAGAGAGAGAGAGAAGGGG
Jon is offline
Arkshine
AMX Mod X French Moderator
Karma: Good
Old 11-06-2009 , 12:03   Re: Give Item (Engine)
Reply With Quote #5

Well, there is not really a reason to do that when you can use give_item() directly for sure.

GiveNamedItem() from HLSDK :

Code:
void CBasePlayer::GiveNamedItem( const char *pszName ) {     edict_t *pent;     int istr = MAKE_STRING(pszName);     pent = CREATE_NAMED_ENTITY(istr);     if ( FNullEnt( pent ) )     {         ALERT ( at_console, "NULL Ent in GiveNamedItem!\n" );         return;     }     VARS( pent )->origin = pev->origin;     pent->v.spawnflags |= SF_NORESPAWN;     DispatchSpawn( pent );     DispatchTouch( pent, ENT( pev ) ); }

It seems you forget to add the SF_NORESPAWN flag. About the origin, I'm not sure to understand if it's really needed.
__________________
  • Working on : MonsterAI
Arkshine is offline
ConnorMcLeod
Veteran Member
Karma: Good
Location: France (95)
Old 11-06-2009 , 16:39   Re: Give Item (Engine)
Reply With Quote #6

Full conversion needs both engine and fakemeta, to limit natives calls.
But fun is the only one that should be used.

PHP Code:
GiveNamedItemid, const pszName[] )
{
    new 
iEnt create_entity(pszName)
    if( !
iEnt // create_entity returns 0 on failure
    
{
        
engfunc(EngFunc_AlertMessageat_console"NULL Ent in GiveNamedItem!\n" )
        return
    }

    new 
Float:fVecOrigin[3]
    
entity_get_vector(idEV_VEC_originfVecOrigin)
    
entity_set_vector(iEntEV_VEC_originfVecOrigin// don't need SetOrigin as you spawn it later
    
entity_set_int(iEntEV_INT_spawnflagsentity_get_int(iEntEV_INT_spawnflags) | SF_NORESPAWN)

    
DispatchSpawniEnt )
    
fake_touchiEntid )

__________________
my plugins


No free help via PMs.
ConnorMcLeod is offline
Arkshine
AMX Mod X French Moderator
Karma: Good
Old 11-06-2009 , 17:28   Re: Give Item (Engine)
Reply With Quote #7

I'm not sure that EngFunc_AlertMessage would be useful here. I would use log_amx.
__________________
  • Working on : MonsterAI
Arkshine is offline
Hawk552
AMX Mod X Plugin Approver
Karma: Good
Location: Freelance Gynecologist
Old 11-16-2009 , 13:11   Re: Give Item (Engine)
Reply With Quote #8

Or you could just stop fretting over these 0.00001% optimizations and write whatever is easiest. I wonder how many plugins could have been written in the time that people used to pointlessly optimize instead.
__________________

| My Plugins | My YouTube | Mises Economics Blog | Apollo RP |
Looking for private/paid plugins? PM me for information.
Hawk552 is offline
Send a message via AIM to Hawk552
SnoW
Veteran Member
Karma: Good
Location: Finland WisdomNuggets: 8
Old 11-17-2009 , 10:11   Re: Give Item (Engine)
Reply With Quote #9

Quote:
Originally Posted by Hawk552 View Post
Or you could just stop fretting over these 0.00001% optimizations and write whatever is easiest. I wonder how many plugins could have been written in the time that people used to pointlessly optimize instead.
Since all new plugins suck, people focuse to make the old ones better.
__________________

SnoW is offline
Send a message via MSN to SnoW
Styles
Veteran Member
Karma: Good
Location: California
Old Yesterday , 01:47   Re: Give Item (Engine)
Reply With Quote #10

Quote:
Originally Posted by SnoW View Post
Since all new plugins suck, people focuse to make the old ones better.
Correct.

Hawk, not everyone can come up with an idea to build an entire role playing idea like you and somehow make it successful. I mean I could, and a few more here, you know who you are, but fuck it. It's not worth it and to be honest, most of the members here don't deserve it. There are a bunch of new people who are ignorant, rude and stupid. I refuse to help anyone like this. I don't care what you guys say about it but that's my feeling.

And Hawk, don't say you don't care about optimizations. You were on this bandwagon at one point too. Look at ApolloRP, besides the fact that the first datalayer was basically a prototype, you did redo it and in fact optimization a lot of it. You also did to the core and many other parts of it.
__________________


Fast download services never got so, fast! Try out Pacific Host!
Highly recommend by me !
Styles is online now
Send a message via AIM to Styles Send a message via MSN to Styles
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 21:11.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Theme made by Freecode Sponsored by Layered Technologies