SA-MP Forums Archive
[Tutorial] Plugin development guide - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Tutorial] Plugin development guide (/showthread.php?tid=295798)

Pages: 1 2 3 4 5 6 7 8 9


Re: Plugin development guide - Isolated - 08.07.2013

would I be able to use:

pawn Код:
CallNative(&PAWN::mysql_connect, RAWR, RAWR, RAWR, RAWR); // For example.
Without the g_Invoke, or will I need to add it ?


Re: Plugin development guide - RebeloX - 13.07.2013

Hello, i'm using devc++ can i use the same code?


Re: Plugin development guide - OrMisicL - 13.07.2013

Quote:
Originally Posted by BlueX
Посмотреть сообщение
Hello, i'm using devc++ can i use the same code?
As far as i know, SAMP plugin SDK is only compatible with Visual Studio IDE, due to the need of the .def (Definition) file in it, so as a short response, its NO


Re: Plugin development guide - Chipotle - 12.08.2013

Amazing , good job.


Re: Plugin development guide - Dolby - 25.09.2013

I have these errors:
Код:
Main.obj : error LNK2019: unresolved external symbol _amx_Register referenced in function _AmxLoad@4
Main.obj : error LNK2001: unresolved external symbol "void * pAMXFunctions" (?pAMXFunctions@@3PAXA)
How to solve this?
@Solved!


Re: Plugin development guide - GWMPT - 16.10.2013

I'm afraid that this SDK doesn't works with the newest version of the sa-mp server.
Код:
#include "SDK\amx\amx.h"
#include "SDK\plugincommon.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) 
{
    logprintf = (logprintf_t) ppData[PLUGIN_DATA_LOGPRINTF];
    pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
    logprintf(" * Test plugin was loaded.");
    return 1;
}

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

const 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;
}
That code compiles well[Like it was supposed to!] but the output, from the server, is:
Код:
Plugin does not conform to architecture.
Any ideas of a work around to avoid this issue?
Or am i doing something wrong?
Thanks!


Re: Plugin development guide - OrMisicL - 16.10.2013

@Kikito: you've pobably forgot the .def file


Re: Plugin development guide - GWMPT - 16.10.2013

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
@Kikito: you've pobably forgot the .def file
@edit: Oh nvm, i really did forgot it... lol


Re: Plugin development guide - Rancho - 16.03.2014

I want to ask one question.

The index value which I get with amx_FindPublic(...) is static? If I store it in Plugin Load, can I use it everytime?


Re: Plugin development guide - GWMPT - 16.03.2014

If the callback you want to call in the script is the same, it doesn't change(IF not mistaken).


Re: Plugin development guide - iFarbod - 19.04.2014

Where is the latest SDK?


Re: Plugin development guide - iZN - 19.04.2014

Quote:
Originally Posted by iFarbod
Посмотреть сообщение
Where is the latest SDK?
https://github.com/Zeex/sampgdk/releases


Re: Plugin development guide - xeeZ - 19.04.2014

The SDK is the same for all SA-MP versions, there's no "latest" SDK.


Re: Plugin development guide - iFarbod - 20.04.2014

Thanks


Respuesta: Plugin development guide - JustBored - 20.04.2014

Does anyone of you guys know the equivalent of the PAWN function getarg in C? i searched in ****** but all i found are things that have nothing to do with.


Re: Plugin development guide - RCON1 - 20.04.2014

Could anyone suggest how to create a plugin that would format the message? (I use y_va but want a plugin)

Код:
native SendClientFormatMessage (playerid, color, const format [], {Float, _}: ...);



Re: Respuesta: Plugin development guide - xeeZ - 20.04.2014

Quote:
Originally Posted by JustBored
Посмотреть сообщение
Does anyone of you guys know the equivalent of the PAWN function getarg in C? i searched in ****** but all i found are things that have nothing to do with.
Here you go: http://en.cppreference.com/w/cpp/utility/variadic


Respuesta: Re: Respuesta: Plugin development guide - JustBored - 20.04.2014

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Thanks +rep.


Re: Plugin development guide - RCON1 - 20.04.2014

Code:
cell AMX_NATIVE_CALL formatEx(AMX* amx, cell* params)
{
	char string__[128];	

	sprintf(string__, (const char *) params[1],  params[2]);

    logprintf(string__);
    return 1;
}
Code:
#include <a_samp>


native formatEx(const format[], {Float,_}:...);
public OnGameModeInit()
{
 
	formatEx("test %s, %d", "abc", 11);


    return 1;
}
 

main(){}
What could be the cause of the crash?


#edit

Code:
#include <a_samp>
native formatEx(const format[], {Float,_}:...);
public OnGameModeInit()
{
 formatEx("My test: string: %s, int: %d", "blablabla", 123);
    return 1;
}
main(){}
+
Code:
cell AMX_NATIVE_CALL formatEx(AMX* amx, cell* params)
{
	
	char string__[128];	
	 
  int 
        len = NULL,
        ret = NULL,
		argc = params[0]/4;

    cell *addr  = NULL;


    amx_GetAddr(amx, params[1], &addr); 
    amx_StrLen(addr, &len);
    if(len)
    {

        len++;

     
        char* formats = new char[ len ];
	
        amx_GetString(formats, addr, 0, len);
		
		sprintf(string__, formats,  &params[2]);

        logprintf("%d L: %s",argc, string__);

        delete[] formats;
    }


	return 1;
}
=


Anyone know why bad formatting text?


Respuesta: Plugin development guide - JustBored - 28.04.2014

I dont get what are you trying to do, you are trying to make a formatEx function but what that function is supposed to do?