Raised This Month: $ Target: $400
 0% 

Acquiring a #define from another plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JFeldon
Member
Join Date: Feb 2007
Location: United Kingdom
Old 07-16-2008 , 08:57   Acquiring a #define from another plugin
Reply With Quote #1

Hi,

I'm scripting something for TSRP and am calling the itemamount function from HarbuRP_Talkarea.amxx. The 3 parameters are "id","itemid","table". The ID is the player id, no problem. The table is money, no problem again. But the ItemID I want is in a #define in HarbuRP_Talkarea.amxx. I could just get the value of it (Which I believe is 14) and manually use
PHP Code:
callfunc_push_int(14
So if the server owner decides to change the ItemID's (Not likely but possible), the plugin wouldn't work.

Is there anyway I can get the #define from the plugin, put it into a variable in my plugin and then use it in callfunc_push_int?
The define is
PHP Code:
#define CELLPHONE_TWO_ID 14 


The code I wanna use it in is
PHP Code:
Public Function(id)
{
    
callfunc_begin("itemamount","HarbuRP_Talkarea.amxx")
    
callfunc_push_int(id)
    
callfunc_push_int(?????)
    
callfunc_push_str(money)
    
//... 
Also, if there's a more efficient way of doing this tell me


+Karma for helpfullness

-JFeldon
__________________
+Karma if I helped! ;)
JFeldon is offline
Send a message via MSN to JFeldon
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 07-16-2008 , 17:33   Re: Acquiring a #define from another plugin
Reply With Quote #2

This is how I would do it.
I will create a forward that will execute after the plugins have been loaded in the main plugin that holds the defines.

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

#define DEFINE 4

#define PLUGIN    "Fake Forward"
#define AUTHOR    "OT"
#define VERSION    "1.0"

new g_forward
new g_return

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_forward CreateMultiForward("api_get_the_defines",ET_IGNORE,FP_CELL)
    
set_task(0.5,"plugin_spread_defines")
}

public 
plugin_spread_defines()
{
    
ExecuteForward(g_forward,g_return,DEFINE)
    
    
DestroyForward(g_forward)

To hook the forward in your plugins you need to put the function name
PHP Code:
public api_get_the_defines(define)
{
      
define

Anyway this will be helpfull -> PLUGIN API TUTORIAL
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
JFeldon
Member
Join Date: Feb 2007
Location: United Kingdom
Old 07-17-2008 , 02:51   Re: Acquiring a #define from another plugin
Reply With Quote #3

Cool thanks. +karma
__________________
+Karma if I helped! ;)
JFeldon is offline
Send a message via MSN to JFeldon
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:35.


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