SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 06/08/2012, 09:04 PM   #61
misho1
Gangsta
 
misho1's Avatar
 
Join Date: Feb 2011
Location: Egypt
Posts: 757
Reputation: 23
Default Re: Plugin development guide

DELETED
__________________
196.205.159.181:7777
Gaming Overload server
Mappers needed, Reward setting him admin level 3 to level 5 and that depends on his mapping skills
misho1 is offline   Reply With Quote
Old 26/09/2012, 04:57 PM   #62
Edvin
Gangsta
 
Edvin's Avatar
 
Join Date: Dec 2010
Posts: 859
Reputation: 71
Default Re: Plugin development guide

Wow, awesome tutorial, very very good explained.
Edvin is offline   Reply With Quote
Old 11/11/2012, 06:52 AM   #63
Plovix
Huge Clucker
 
Plovix's Avatar
 
Join Date: Dec 2011
Location: Croatia
Posts: 481
Reputation: 92
Default Re: Plugin development guide

Thank you very much for tutorial,very useful for me!
Plovix is offline   Reply With Quote
Old 22/11/2012, 07:02 PM   #64
Megalock
Little Clucker
 
Join Date: Jan 2012
Posts: 6
Reputation: 0
Exclamation Respuesta: Plugin development guide

This code:

Code:
#include "..\SDK\amx\amx.h"
#include "..\SDK\plugincommon.h"
#include "..\SDK\Invoke.h"

typedef void (*logprintf_t)(char* format, ...);


logprintf_t logprintf;
extern void *pAMXFunctions;



cell AMX_NATIVE_CALL HelloWorld(AMX* amx, cell* params)
{
    logprintf("This was printed from the Test plugin! Yay!");
    return 1;
}

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() 
{
    return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
}

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) 
{
    pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
    logprintf = (logprintf_t) ppData[PLUGIN_DATA_LOGPRINTF];
    logprintf(" * Test plugin was loaded.");
    return true;
}

PLUGIN_EXPORT void PLUGIN_CALL Unload()
{
    logprintf(" * Test plugin was unloaded.");
}

cell AMX_NATIVE_CALL WhereIsPlayer(AMX* amx, cell* params)
{
    float
        x = NULL,
        y = NULL,
        z = NULL;

    //Get the player's position (and check to see if he is even connected).
    if(g_Invoke->callNative(&PAWN::GetPlayerPos, params[1], &x, &y, &z))
    {
        char name[24];

        //Get the rest of the player's information (name, interior, and virtualworld) and print it.
        g_Invoke->callNative(&PAWN::GetPlayerName, params[1], name);
        int interior = g_Invoke->callNative(&PAWN::GetPlayerInterior, params[1]);
        int virtualworld = g_Invoke->callNative(&PAWN::GetPlayerVirtualWorld, params[1]);

        logprintf("%s is at X: %.2f, Y: %.2f, Z: %.2f (Virtual world: %d, Interior %d).", name, x, y, z, virtualworld, interior);
        return 1;

    }
    return 0;
}

AMX_NATIVE_INFO PluginNatives[] =
{
    {"HelloWorld", HelloWorld},
    {0, 0}
};

PLUGIN_EXPORT int PLUGIN_CALL AmxLoad( AMX *amx ) 
{
    return amx_Register(amx, PluginNatives, -1);
}


PLUGIN_EXPORT int PLUGIN_CALL AmxUnload( AMX *amx ) 
{
    return AMX_ERR_NONE;
}
Give me errors:

Code:
     Creando biblioteca Test\Debug\Test.lib and object Test\Debug\Test.exp
Test.obj : error LNK2019: extern symbol "public: int __cdecl Invoke::callNative(struct PAWN::Native const *,...)" (?callNative@Invoke@@QAAHPBUNative@PAWN@@ZZ) unresolved external symbol referenced in function 'function' "long __cdecl WhereIsPlayer(struct tagAMX *,long *)" (?WhereIsPlayer@@YAJPAUtagAMX@@PAJ@Z)
Test.obj : error LNK2001: símbolo externo "class Invoke * g_Invoke" (?g_Invoke@@3PAVInvoke@@A) unresolved external symbol
Test\Debug\Test.dll : fatal error LNK1120: 2 unresolved external symbols
========== Generated: 0 corrects, 1 incorrect ==========
Sorry for language of compiler.

It's the same problem of:


on page 6, here, on this tutorial.

Last edited by Megalock; 22/11/2012 at 07:49 PM.
Megalock is offline   Reply With Quote
Old 02/12/2012, 10:10 AM   #65
Megalock
Little Clucker
 
Join Date: Jan 2012
Posts: 6
Reputation: 0
Default Respuesta: Plugin development guide

Please help.
Megalock is offline   Reply With Quote
Old 09/12/2012, 03:39 PM   #66
GWMPT
Gangsta
 
Join Date: Nov 2012
Location: Portugal.
Posts: 989
Reputation: 287
Default Re: Plugin development guide

I have a small nabass question.
So, via the plugin, we *can* use all functions that c/++ gives, right?
GWMPT is offline   Reply With Quote
Old 09/12/2012, 05:32 PM   #67
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,336
Reputation: 251
Default Re: Plugin development guide

Quote:
Originally Posted by klklt0 View Post
I have a small nabass question.
So, via the plugin, we *can* use all functions that c/++ gives, right?
In theory yes...but in some case you need to have install libraries or even clients.
__________________
TheArcher is offline   Reply With Quote
Old 18/01/2013, 12:28 PM   #68
steki.
High-roller
 
steki.'s Avatar
 
Join Date: Nov 2010
Location: São Paulo, Brasil
Posts: 2,558
Reputation: 315
Default Re: Plugin development guide

Am I using it wrongly?

pawn Code:
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
    logprintf("A");
}

This just seems to not print out.

Edit: I already have put the function to export:

Code:
LIBRARY "WItem"
EXPORTS
	Supports
	Load
	Unload
	AmxLoad
	AmxUnload
	ProcessTick
Forgot to add ProcessTick to Supports.
__________________
Rio

Last edited by steki.; 24/01/2013 at 07:44 PM.
steki. is offline   Reply With Quote
Old 14/02/2013, 02:07 PM   #69
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,421
Reputation: 271
Default Re: Plugin development guide

Quote:
Originally Posted by Kyosaur
AmxLoad(AMX*):
This is called when a new AMX instance is loaded into the server. This will be called for every filterscript/gamemode! Because of this it isn't a good idea to store a single AMX instance for the entire plugin, instead use a queue/list/vector. In this function we also register our custom native functions we wish to provide PAWN with
Could someone tell me why this needs to be done please? (storing instances of amx) A small example or explanation would be great if possible? Is that just for calling publics in an amx file, Or must it always be done regardless if your calling publics from the plugin or not?

I have had a look in other plugins but still not sure if or why i need to use this.

Thanks in advance.

EDIT: I know i need to use AmxLoad(AMX*) to register the natives to the amx, just wondering why i would need to store the amx in a container.

EDIT2: I think i get it now, if an amx is unloaded most data that it pointed to, in the plugin becomes redundant. Going to have to re-download the documentation.

Last edited by iggy1; 14/02/2013 at 09:48 PM.
iggy1 is offline   Reply With Quote
Old 22/02/2013, 03:56 PM   #70
KubiPL
Big Clucker
 
KubiPL's Avatar
 
Join Date: Feb 2012
Posts: 159
Reputation: 18
Default Re: Plugin development guide

Where can I get SAMP SDK (amx.h, plugincommon.h)?
And how to return value of function in plugin to pawno? I mean for e.g. GetPlayerMousePos and will return X and Y for player cursor pos.
KubiPL is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SA-MP 0.3c in development Kalcor News and Updates 883 19/09/2014 04:39 PM
0.3b Development bar gone WackoX General 94 02/08/2010 10:17 PM
A guide to install Jacob's IRC plugin? Celson Server Support 5 09/06/2009 07:06 AM


All times are GMT. The time now is 09:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.