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

Writing an module.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-10-2017 , 10:15   Writing an module.
Reply With Quote #1

Hello guys, i have someeee questions, i'm realy noob so be patient with me

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
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-10-2017 , 17:34   Re: Writing an module.
Reply With Quote #2

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.
__________________
WildCard65 is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viña del Mar, Chile
Old 01-10-2017 , 21:27   Re: Writing an module.
Reply With Quote #3

Better look this:

https://github.com/alliedmodders/amx...modx.cpp#L4397
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-17-2017 , 16:48   Re: Writing an module.
Reply With Quote #4

I wish Metamod and AMXX were written in C# : (
__________________
edon1337 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-18-2017 , 16:51   Re: Writing an module.
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
I wish Metamod and AMXX were written in C# : (
That would require a C++ to C# binding API layer (either C++ /CLR or PInvoke).
__________________
WildCard65 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-19-2017 , 10:18   Re: Writing an module.
Reply With Quote #6

Quote:
Originally Posted by WildCard65 View Post
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?
__________________
edon1337 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-19-2017 , 10:25   Re: Writing an module.
Reply With Quote #7

Quote:
Originally Posted by edon1337 View Post
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).
__________________
WildCard65 is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 01-20-2017 , 04:31   Re: Writing an module.
Reply With Quote #8

What ? C# and Java ? When the original application i.e game engine is restricted to desktop environment, whats the use ? Unless for more overhead ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-20-2017 , 07:15   Re: Writing an module.
Reply With Quote #9

Quote:
Originally Posted by Shooting King View Post
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.
__________________
WildCard65 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-20-2017 , 13:49   Re: Writing an module.
Reply With Quote #10

Is there OOP support in PAWN ?
__________________
edon1337 is offline
Reply


Thread Tools
Display Modes

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 10:56.


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