AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Acquiring a #define from another plugin (https://forums.alliedmods.net/showthread.php?t=74315)

JFeldon 07-16-2008 08:57

Acquiring a #define from another plugin
 
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 :P


+Karma for helpfullness

-JFeldon

ot_207 07-16-2008 17:33

Re: Acquiring a #define from another plugin
 
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

JFeldon 07-17-2008 02:51

Re: Acquiring a #define from another plugin
 
Cool thanks. +karma :D


All times are GMT -4. The time now is 05:32.

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