AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Writing an module. (https://forums.alliedmods.net/showthread.php?t=292634)

Craxor 01-10-2017 10:15

Writing an module.
 
Hello guys, i have someeee questions, i'm realy noob so be patient with me :twisted::twisted:

ok :)

1 . - amxmodx SDK and HLSDK , Microsoft Visual Studio are the only things i need to write a module ? ( i have also metamod sdk ).


2. For compiling the following code ( i'm trying to make a simple native just for learn ) i don't need metamod sdk no ? i read some tut. but are they very confusing , i learn more when i talk with people so :

PHP Code:

#include "amxxmodule.h"


// Empty an array, like array_set,  but that's require just the array: empty_array( Array )
static cell AMX_NATIVE_CALL empty_array(AMX *amxcell *params)
{
    
cell *Arr get_amx_addr(amxparams[1]);

    for (
int i 0i<sizeof(Arr); i++)
    {
        
Arr[i] = 0;
    }
}

AMX_NATIVE_INFO EmptyArray_Natives[] =
{
    { 
"empty_array" ,empty_array };
    { 
NULL,        ,NULL }
};

void OnAmxxAttach(EmptyArray_Natives)
{
    
MF_AddNatives(EmptyArray_Natives);



So ... i'm very confused if somebody can give me some answers :D

WildCard65 01-10-2017 17:34

Re: Writing an module.
 
1) Correct, general AMXX development requires AMXX source, MM source and HLSDK
2) Yes, only using API of AMXX allows you to only require AMXX source.

Note: Your native runs the risk of corrupting memory for the following reason:
sizeof() is a constexpr, what this means is that it's value is obtained at compile time of your module, so basically, your for loop iterates the values of 0, 1, 2, 3 (pointers are 4 bytes long, aka 32 bit integers, on 32bit machines), you have no guarantee input array is 16 bytes long (AMXX cells are 32-bit integers, 4 bytes, multiplied by 4 for num indexes your iterating), you 100% must have a parameter in your native definition to pass array's size in PAWN and use that param in your callback.

meTaLiCroSS 01-10-2017 21:27

Re: Writing an module.
 
Better look this:

https://github.com/alliedmodders/amx...modx.cpp#L4397

edon1337 01-17-2017 16:48

Re: Writing an module.
 
I wish Metamod and AMXX were written in C# : (

WildCard65 01-18-2017 16:51

Re: Writing an module.
 
Quote:

Originally Posted by edon1337 (Post 2487530)
I wish Metamod and AMXX were written in C# : (

That would require a C++ to C# binding API layer (either C++ /CLR or PInvoke).

edon1337 01-19-2017 10:18

Re: Writing an module.
 
Quote:

Originally Posted by WildCard65 (Post 2487834)
That would require a C++ to C# binding API layer (either C++ /CLR or PInvoke).

Eh, you're right at all. C# is mostly for apps, what about Java though?

WildCard65 01-19-2017 10:25

Re: Writing an module.
 
Quote:

Originally Posted by edon1337 (Post 2488018)
Eh, you're right at all. C# is mostly for apps, what about Java though?

same requirement as C# except using the JNI (and creating a Java VM instance at runtime of the binding API).

Shooting King 01-20-2017 04:31

Re: Writing an module.
 
What ? C# and Java ? When the original application i.e game engine is restricted to desktop environment, whats the use ? Unless for more overhead ?

WildCard65 01-20-2017 07:15

Re: Writing an module.
 
Quote:

Originally Posted by Shooting King (Post 2488280)
What ? C# and Java ? When the original application i.e game engine is restricted to desktop environment, whats the use ? Unless for more overhead ?

probably for OOP.

edon1337 01-20-2017 13:49

Re: Writing an module.
 
Is there OOP support in PAWN ?


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

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