Raised This Month: $ Target: $400
 0% 

Access variables in other plugins?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XeroXer
Junior Member
Join Date: Sep 2006
Location: Västerås, Sweden
Old 09-06-2008 , 08:06   Access variables in other plugins?
Reply With Quote #1

Hi all!

On my server I have a lot of different plugins running and most of them all access the ip, steamid and an id from my database for every user.
Since this makes a lot of the same variables in the different plugins I was thinking that maybe there is a better way.

Can I in plugin 1 access a variable set in plugin 2?
I know about the callfunc but I want to get to the variable without calling a function for it.

So in globalvars.amxx I create:
PHP Code:
new playerDbId[32], playerSteamId[32], playerIp[32]; 
I then sen these to the correct information when the user connects, and reset them at disconnect.

Now in savedeaths.amxx I want to save that the player XeroXer dies.
I then want to send it to the database with his db id.
Can I then access the playerDbId[id] from globalvars.amxx?

Any help and/or suggestions are welcome...
__________________
::: From the Gates of Hell :::
XeroXer is offline
Send a message via ICQ to XeroXer Send a message via AIM to XeroXer Send a message via MSN to XeroXer
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 09-06-2008 , 08:23   Re: Access variables in other plugins?
Reply With Quote #2

X-olent made a include file for his hide'n'seek plugin
So u can use get_hidenseek_on or summink in a different plugin if it uses #include <hidenseek>
My guess is that u can do the same if u create a include file
I have no idea how to make 1 though
__________________
minimiller is offline
Send a message via MSN to minimiller
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-06-2008 , 13:49   Re: Access variables in other plugins?
Reply With Quote #3

If you are just sending information to between plugins, use Dynamic Natives.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
XeroXer
Junior Member
Join Date: Sep 2006
Location: Västerås, Sweden
Old 09-07-2008 , 06:13   Re: Access variables in other plugins?
Reply With Quote #4

Quote:
Originally Posted by Exolent[jNr] View Post
If you are just sending information to between plugins, use Dynamic Natives.
I read there that the speed is the same or slightly faster that callfunc.
Would I gain anything from using Dynamic Natives instead of callfunc to get the information?
Or maybe callfunc doesn't work that way, can I use a function in another plugin and get a result back with it?
__________________
::: From the Gates of Hell :::
XeroXer is offline
Send a message via ICQ to XeroXer Send a message via AIM to XeroXer Send a message via MSN to XeroXer
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-07-2008 , 06:58   Re: Access variables in other plugins?
Reply With Quote #5

A dynamic natives to get users ips is non-sense, juste use get_user_ip in each plugin ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
XeroXer
Junior Member
Join Date: Sep 2006
Location: Västerås, Sweden
Old 09-07-2008 , 07:04   Re: Access variables in other plugins?
Reply With Quote #6

Yeah the ip and steamid might just be easier to get in each plugin, but not the databaseid right.
Then I have five plugins that each time a user connects make the same query to the same database to get the same information.
That is what I want another plugin to do for them, just do the query and store the id for the other plugins to use.
__________________
::: From the Gates of Hell :::
XeroXer is offline
Send a message via ICQ to XeroXer Send a message via AIM to XeroXer Send a message via MSN to XeroXer
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-07-2008 , 07:07   Re: Access variables in other plugins?
Reply With Quote #7

my bad
You may send a forward right after client_putinserver to send all datas to other plugins.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-07-2008 , 12:52   Re: Access variables in other plugins?
Reply With Quote #8

You could use a forward:

Include:
Code:
#if defined _your_include_included     #endinput #endif #define _your_include_included #define PLUGIN_LIBRARY "your_plugin_library" #if AMXX_VERSION_NUM >= 175     #pragma reqlib PLUGIN_LIBRARY     #if !defined AMXMODX_NOAUTOLOAD         #pragma loadlib PLUGIN_LIBRARY     #endif #else     #pragma library PLUGIN_LIBRARY #endif forward received_client_information(client, authid[], ip[], /* etc */);

Main plugin:
Code:
new g_fwd_received; new g_fwd_result; public plugin_init() {     g_fwd_received = CreateMultiForward("received_client_information", ET_IGNORE, FP_CELL, FP_STRING, FP_STRING); } public plugin_natives() {     register_library("your_plugin_library"); } public client_putinserver(client) {     new authid[35], ip[64];         // get your information         ExecuteForward(g_fwd_received, g_fwd_result, client, authid, ip); }

Other plugins:
Code:
#include <that include file> new g_authid[33][35]; new g_ip[33][64]; public received_client_info(client, authid[], ip[]) {     copy(g_authid[client], sizeof(g_authid[]) - 1, authid);     copy(g_ip[client], sizeof(g_ip[]) - 1, ip); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 03:17.


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