AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get global via native (https://forums.alliedmods.net/showthread.php?t=224895)

Rirre 08-29-2013 11:20

Get global via native
 
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]++     } }

ConnorMcLeod 08-29-2013 13:29

Re: Get global via native
 
There is a tutorial about dynamic natives.
Also, i think i have read that style 1 is deprecated, so use rather style 0.

red_bull2oo6 08-29-2013 14:59

Re: Get global via native
 
here it is:
http://forums.alliedmods.net/showthread.php?t=41251

Rirre 07-21-2014 16:15

Re: Get global via native
 
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) }

mottzi 07-21-2014 16:25

Re: Get global via native
 
What are you trying to achieve? The code above makes no sense to me.

Rirre 07-21-2014 16:45

Re: Get global via native
 
Quote:

Originally Posted by mottzi (Post 2171534)
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))

Flick3rR 07-21-2014 16:53

Re: Get global via native
 
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)!

hornet 07-22-2014 03:18

Re: Get global via native
 
Quote:

Originally Posted by Rirre (Post 2171543)
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.

Bos93 07-22-2014 15:54

Re: Get global via native
 
return g_iDamage[get_param(1), get_param(2)] += get_param(3)// gDoneDamage(id, victim, damage)
-->>
return g_iDamage[id][victim] += get_param(3);


All times are GMT -4. The time now is 19:14.

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