27.07.2014, 00:21
Try with just "amx\amx.h" (removing SDK\).
I also had the problem but that was solved doin this.
I also had the problem but that was solved doin this.
This was printed from the Test plugin! Yay ММММММММММММММММММММММММММММЃ\PЈLћі¶@!
cell AMX_NATIVE_CALL CheckUser(AMX* amx, cell* params) { char name[24]; g_Invoke->callNative(&PAWN::GetPlayerName, params[1], name); logprintf("This was printed from the Test plugin! Yay %s!",name); return 1; }
#include <sampgdk\a_players.h>
using sampgdk::logprintf;
#define AMX_DECLARE_NATIVE(native) \
cell AMX_NATIVE_CALL native(AMX* amx, cell* params)
AMX_DECLARE_NATIVE(CheckUser)
{
if(!IsPlayerConnected(params[1])) return logprintf("The user %d isn't connected !", params[1]), 1;
char name[25];
GetPlayerName(params[1], &name, 25);
logprintf("This was printed from the Test plugin! Yay %s!", name);
return 1;
}
I personally use sampGDK and it works correctly with this syntax :
pawn Code:
|
#include "sampgdk/a_players.h" #include "sampgdk/a_samp.h" #include "sampgdk/core.h" #include "sampgdk/sdk.h" #include "Invoke.h" #include <string> #include <vector> #include <cstdlib> #include <ctime> using sampgdk::logprintf; typedef void(*logprintf_t)(char* format, ...); extern void *pAMXFunctions; using namespace std; #define AMX_DECLARE_NATIVE(native) \ cell AMX_NATIVE_CALL native(AMX* amx, cell* params) PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() { return true; } ///////////////////////////////////// AMX_DECLARE_NATIVE(CheckUser) { if (!IsPlayerConnected(params[1])) return printf("The user %d isn't connected !", params[1]), 1; char name[25]; GetPlayerName(params[1], name, 25); printf("This was printed from the Test plugin! Yay %s!", name); return 1; } ///////////////////////////////////// PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() { return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES; } PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) { g_Invoke = new Invoke; pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS]; printf(" * plugin was loaded."); return true; } PLUGIN_EXPORT void PLUGIN_CALL Unload() { printf(" * plugin was unloaded."); } AMX_NATIVE_INFO PluginNatives[] = { { "CheckUser", CheckUser }, { 0, 0 } }; PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx) { g_Invoke->amx_list.push_back(amx); return amx_Register(amx, PluginNatives, -1); } PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx) { for (list<AMX *>::iterator i = g_Invoke->amx_list.begin(); i != g_Invoke->amx_list.end(); ++i) { if (*i == amx) { g_Invoke->amx_list.erase(i); break; } } return AMX_ERR_NONE; }
Thanks, but I get this error:
(Reference to unresolved external symbol) My Code: Code:
#include "sampgdk/a_players.h" #include "sampgdk/a_samp.h" #include "sampgdk/core.h" #include "sampgdk/sdk.h" #include "Invoke.h" #include <string> #include <vector> #include <cstdlib> #include <ctime> using sampgdk::logprintf; typedef void(*logprintf_t)(char* format, ...); extern void *pAMXFunctions; using namespace std; #define AMX_DECLARE_NATIVE(native) \ cell AMX_NATIVE_CALL native(AMX* amx, cell* params) PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() { return true; } ///////////////////////////////////// AMX_DECLARE_NATIVE(CheckUser) { if (!IsPlayerConnected(params[1])) return printf("The user %d isn't connected !", params[1]), 1; char name[25]; GetPlayerName(params[1], name, 25); printf("This was printed from the Test plugin! Yay %s!", name); return 1; } ///////////////////////////////////// PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() { return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES; } PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) { g_Invoke = new Invoke; pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS]; printf(" * plugin was loaded."); return true; } PLUGIN_EXPORT void PLUGIN_CALL Unload() { printf(" * plugin was unloaded."); } AMX_NATIVE_INFO PluginNatives[] = { { "CheckUser", CheckUser }, { 0, 0 } }; PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx) { g_Invoke->amx_list.push_back(amx); return amx_Register(amx, PluginNatives, -1); } PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx) { for (list<AMX *>::iterator i = g_Invoke->amx_list.begin(); i != g_Invoke->amx_list.end(); ++i) { if (*i == amx) { g_Invoke->amx_list.erase(i); break; } } return AMX_ERR_NONE; } |
#include "../SDK/amx/amx.h" #include "../SDK/plugincommon.h"
1>------ Build started: Project: projectname, Configuration: Release Win32 ------ 1> main.cpp 1>src/main.cpp(1): fatal error C1083: Cannot open include file: '../sdk/amx/amx.h': No such file or directory 1> testproject.def 1>testproject.def(1): error C2143: syntax error : missing ';' before 'string' 1>testproject.def(1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#include "sdk\amx\amx.h" #include "sdk\plugincommon.h"
------ Build started: Project: projectname, Configuration: Release Win32 ------ 1> main.cpp 1> testproject.def 1>testproject.def(1): error C2143: syntax error : missing ';' before 'string' 1>testproject.def(1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========