Raised This Month: $12 Target: $400
 3% 

How can i connect an array from one plugin to another?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 06-23-2011 , 12:03   How can i connect an array from one plugin to another?
Reply With Quote #1

I want to use a shop with ghw's cs bank, how would i connect the array "bank[id]" so the shop will take money out of the users bank if they have money in there?
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME
r4ndomz is offline
Send a message via Skype™ to r4ndomz
Nyuszy
Senior Member
Join Date: Apr 2009
Old 06-23-2011 , 13:24   Re: How can i connect an array from one plugin to another?
Reply With Quote #2

you can use fake natives

add to the bank plugin:
PHP Code:
public plugin_natives()
{
    
register_native("get_user_bank""_get_user_bank")
    
register_native("set_user_bank""_set_user_bank")
}
// ...
public _get_user_bank(pluginparams)
{
    if(
params != 1)
        return 
PLUGIN_CONTINUE
    
new id get_param(1)
    return 
bank[id]
}

public 
_set_user_bank(pluginparams)
{
    if(
params != 2)
        return 
PLUGIN_CONTINUE
    
new id get_param(1)
    new 
money get_param(2)
    
bank[id] = money
    
return PLUGIN_HANDLED

add this to your plugin:
PHP Code:
native get_user_bank(id)
native set_user_bank(idmoney
and then you can use get_user_bank and set_user_bank in your plugin to handle the player's bank
Nyuszy is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 06-23-2011 , 15:59   Re: How can i connect an array from one plugin to another?
Reply With Quote #3

Or you could achieve the same with one line of code by using xvars.
SnoW is offline
Send a message via MSN to SnoW
Nyuszy
Senior Member
Join Date: Apr 2009
Old 06-23-2011 , 16:06   Re: How can i connect an array from one plugin to another?
Reply With Quote #4

you can't use xvars with arrays
Nyuszy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2011 , 22:55   Re: How can i connect an array from one plugin to another?
Reply With Quote #5

Quote:
Originally Posted by Nyuszy View Post
you can't use xvars with arrays
You should have shown an example of a native that uses arrays.
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-23-2011 , 23:33   Re: How can i connect an array from one plugin to another?
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
You should have shown an example of a native that uses arrays.
His example is using arrays.
He is indexing the array and returning it's value, not copying the array to the plugin.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-24-2011 , 00:13   Re: How can i connect an array from one plugin to another?
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
His example is using arrays.
He is indexing the array and returning it's value, not copying the array to the plugin.
Oh, you're correct. I was thinking passing an array byref which would be incorrect in this situation.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-24-2011 , 01:46   Re: How can i connect an array from one plugin to another?
Reply With Quote #8

http://www.amxmodx.org/funcwiki.php?...rray&go=search
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Nyuszy
Senior Member
Join Date: Apr 2009
Old 06-24-2011 , 04:13   Re: How can i connect an array from one plugin to another?
Reply With Quote #9

but passing the whole array has no sense (i think)
Nyuszy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-24-2011 , 05:24   Re: How can i connect an array from one plugin to another?
Reply With Quote #10

Quote:
Originally Posted by Nyuszy View Post
but passing the whole array has no sense (i think)
You are correct. Your example was the correct example. I was mistaken on what was actually suppose to be happening.
__________________
fysiks is offline
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 20:44.


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