Raised This Month: $ Target: $400
 0% 

Get global via native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 08-29-2013 , 11:20   Get global via native
Reply With Quote #1

I don't really know how I can get g_ammo from the main plugin.
Only found about boolean and string.

Main plugin:
Code:
new g_ammo[33] public plugin_natives() {     register_native("g_ammo", "_g_ammo", 1) } public _g_ammo(id) {     return g_ammo[id] }
Example of Sub-Plugin, so I know it's wrong. Just explaining and hope you understand what I mean.
Sub-Plugin:
Code:
native g_ammo(id) stock _g_ammo(id) return g_ammo(id) public function(id) {     if(_g_ammo[id] < get_cvar_num("ammo"))     {         _g_ammo[id]++     } }

Last edited by Rirre; 08-29-2013 at 11:20.
Rirre is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-29-2013 , 13:29   Re: Get global via native
Reply With Quote #2

There is a tutorial about dynamic natives.
Also, i think i have read that style 1 is deprecated, so use rather style 0.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
red_bull2oo6
Senior Member
Join Date: Mar 2012
Location: Braila, Romania
Old 08-29-2013 , 14:59   Re: Get global via native
Reply With Quote #3

here it is:
http://forums.alliedmods.net/showthread.php?t=41251
red_bull2oo6 is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 07-21-2014 , 16:15   Re: Get global via native
Reply With Quote #4

Bumping since I don't understand the difference with either style 0 or 1. Have searched and read through the thread several times and still do not get it.
Also in need of help with this:
Code:
#define MAXPLAYERS 32 new g_iDamage[ MAXPLAYERS+1 ][ 900 ] register_native("gDamageDone", "native_damage") public native_damage(plugin, params) {     new id = get_param(1)     if(!id)         return false     new victim = get_param(2)     if(!victim)         return false     return g_iDamage[get_param(1), get_param(2)] += get_param(3) // gDoneDamage(id, victim, damage) }

Last edited by Rirre; 07-21-2014 at 16:17.
Rirre is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-21-2014 , 16:25   Re: Get global via native
Reply With Quote #5

What are you trying to achieve? The code above makes no sense to me.
mottzi is offline
Send a message via MSN to mottzi
Rirre
Veteran Member
Join Date: Nov 2006
Old 07-21-2014 , 16:45   Re: Get global via native
Reply With Quote #6

Quote:
Originally Posted by mottzi View Post
What are you trying to achieve? The code above makes no sense to me.
Look at the marked text, that line will not work since It's just an example how I want it which I don't know how to.
After the slashes is how I want it in the sub-plugin to return the damage done by a player to a entity.
gDamageDone (get_param(1), get_param(2), get_param(3))

Last edited by Rirre; 07-21-2014 at 17:01.
Rirre is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-21-2014 , 16:53   Re: Get global via native
Reply With Quote #7

Well, here is what am I using.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

new MyVariable[33], isDedicatediMaxPlayers

public plugin_init()
{
    
isDedicated is_dedicated_server()
    
iMaxPlayers get_maxplayers()
}

public 
plugin_natives()
{
    
register_native("get_user_gold""_get_user_gold")
}

public 
_get_user_gold(iPluginiParams)
{
    if(
iParams != 1)
        return 
PLUGIN_CONTINUE
        
    
new id get_param(1)
    
    if(!(
isDedicated <= id <= iMaxPlayers))
        return 
PLUGIN_CONTINUE
        
    
return MyVariable[id]

For me it's quite simple. Here are only the basic checks, and you just return your variable. There isn't anything much to explain, indeed.
P.S.: IsDedicated stuff, for the most clear check (because it depends for the loop. If the server is dedicated, they begin from 1, otherwise, they begin from 0). Thanks to Black Rose (again)!
__________________

Last edited by Flick3rR; 07-21-2014 at 16:54.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-22-2014 , 03:18   Re: Get global via native
Reply With Quote #8

Quote:
Originally Posted by Rirre View Post
Look at the marked text, that line will not work since It's just an example how I want it which I don't know how to.
After the slashes is how I want it in the sub-plugin to return the damage done by a player to a entity.
gDamageDone (get_param(1), get_param(2), get_param(3))
Give a better explanation for what your trying to achieve, rather than an example.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 07-22-2014 , 15:54   Re: Get global via native
Reply With Quote #9

return g_iDamage[get_param(1), get_param(2)] += get_param(3)// gDoneDamage(id, victim, damage)
-->>
return g_iDamage[id][victim] += get_param(3);
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
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 19:14.


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