AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Access variables in other plugins? (https://forums.alliedmods.net/showthread.php?t=77139)

XeroXer 09-06-2008 08:06

Access variables in other plugins?
 
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... :mrgreen:

minimiller 09-06-2008 08:23

Re: Access variables in other plugins?
 
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

Exolent[jNr] 09-06-2008 13:49

Re: Access variables in other plugins?
 
If you are just sending information to between plugins, use Dynamic Natives.

XeroXer 09-07-2008 06:13

Re: Access variables in other plugins?
 
Quote:

Originally Posted by Exolent[jNr] (Post 682156)
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?

ConnorMcLeod 09-07-2008 06:58

Re: Access variables in other plugins?
 
A dynamic natives to get users ips is non-sense, juste use get_user_ip in each plugin ;)

XeroXer 09-07-2008 07:04

Re: Access variables in other plugins?
 
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.

ConnorMcLeod 09-07-2008 07:07

Re: Access variables in other plugins?
 
my bad :)
You may send a forward right after client_putinserver to send all datas to other plugins.

Exolent[jNr] 09-07-2008 12:52

Re: Access variables in other plugins?
 
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); }


All times are GMT -4. The time now is 03:17.

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