[Tutorial] Plugin development guide
#81

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 ?
Reply
#82

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

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
Reply
#84

Amazing , good job.
Reply
#85

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!
Reply
#86

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!
Reply
#87

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

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

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?
Reply
#90

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

Where is the latest SDK?
Reply
#92

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

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

Thanks
Reply
#95

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.
Reply
#96

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, _}: ...);
Reply
#97

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
Reply
#98

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

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?
Reply

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?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)