SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/01/2019, 05:48 PM   #1
lWiDuAlKl
Little Clucker
 
Join Date: Jan 2019
Posts: 5
Reputation: 0
Default Problem SA-MP Server C++

Hi I follow few tutorials and I make my script in visual studio.
I have:
https://github.com/Zeex/sampgdk/releases/tag/v4.6.2
https://github.com/Zeex/samp-plugin-sdk

separate folder: sdk
the project folder contains: sampgdk.h ,sampgdh.c source.def, source.cpp etc..
Settings:

Property Pages > C/C++ > General > Additional Include Directory : SDK folder and Project folder
Property Pages > C/C++ > General > Preprocesor WIN32 and SAMPGDK_CPP_WRAPPERS
Property Pages > Linker > Input > Source.def

I have NEW FILTER > Existent item SDK Library
ADD> Existent item> sampgdk.h and sampgdh.c

when I put my plugins I have:

HostName: SA-MP 0.3 Server
Address: localhost:7777
Players: 0 / 50
Ping: 2
Mode: Hello, World!
Language: English

C++ code:
Code:
#include <amx\amx.h>
#include <plugincommon.h>

#include <stdio.h>
#include <string.h>

#include <sampgdk.h>

void SAMPGDK_CALL PrintTickCountTimer(int timerid, void *params) 
{
	sampgdk::logprintf("Tick count: %d", sampgdk::GetTickCount());
}



PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() 
{

	sampgdk::SetGameModeText("Hello, World!");
	sampgdk::AddPlayerClass(0, 1958.3783f, 1343.1572f, 15.3746f, 269.1425f,0, 0, 0, 0, 0, 0);
	sampgdk::SetTimer(1000, true, PrintTickCountTimer, 0);
	return true;
}



PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect(int playerid) 
{

	sampgdk::SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the HelloWorld server!");
	return true;
}



PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerRequestClass(int playerid,int classid) 
{
	sampgdk::SetPlayerPos(playerid, 1958.3783f, 1343.1572f, 15.3746f);
	sampgdk::SetPlayerCameraPos(playerid, 1958.3783f, 1343.1572f, 15.3746f);
	sampgdk::SetPlayerCameraLookAt(playerid, 1958.3783f, 1343.1572f, 15.3746f, CAMERA_CUT);
	return true;
}



PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerCommandText(int playerid,const char *cmdtext) 
{

	if (strcmp(cmdtext, "/hello") == 0) 
	{
		char name[MAX_PLAYER_NAME];
		sampgdk::GetPlayerName(playerid, name, sizeof(name));
		char message[MAX_CLIENT_MESSAGE];
		//sprintf(message, "Hello, %s!", name);
		sampgdk::SendClientMessage(playerid, 0x00FF00FF, message);
		return true;
	}

	return false;

}



PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() 
{
	return sampgdk::Supports();
}



PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) 
{

	return sampgdk::Load(ppData);
}



PLUGIN_EXPORT void PLUGIN_CALL Unload() 
{
	return sampgdk::Unload();
}



PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() 
{
	return sampgdk::ProcessTick();
}
I'm spawned in LV work /hello and CamPos, but


I have the following warnings:
Code:
1>------ Rebuild All started: Project: SA-MP C++, Configuration: Debug Win32 ------
1>amxplugin.cpp
1>Source.cpp
1>d:\windows kits\10\include\10.0.17763.0\ucrt\malloc.h(174): warning C4005: 'alloca': macro redefinition
1>g:\proiect\sdk\amx\amx.h(87): note: see previous definition of 'alloca'
1>Generating Code...
1>getch.c
1>sampgdk.c
1>Generating Code...
1>   Creating library G:\Proiect\SA-MP C++\Debug\SA-MP C++.lib and object G:\Proiect\SA-MP C++\Debug\SA-MP C++.exp
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_Supports imported in function "unsigned int __cdecl sampgdk::Supports(void)" (?Supports@sampgdk@@YAIXZ)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_Load imported in function "bool __cdecl sampgdk::Load(void * *)" (?Load@sampgdk@@YA_NPAPAX@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_Unload imported in function "void __cdecl sampgdk::Unload(void)" (?Unload@sampgdk@@YAXXZ)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_ProcessTick imported in function "void __cdecl sampgdk::ProcessTick(void)" (?ProcessTick@sampgdk@@YAXXZ)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_vlogprintf imported in function "void __cdecl sampgdk::logprintf(char const *,...)" (?logprintf@sampgdk@@YAXPBDZZ)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_SendClientMessage imported in function "bool __cdecl sampgdk::SendClientMessage(int,int,char const *)" (?SendClientMessage@sampgdk@@YA_NHHPBD@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_GetTickCount imported in function "int __cdecl sampgdk::GetTickCount(void)" (?GetTickCount@sampgdk@@YAHXZ)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_SetGameModeText imported in function "bool __cdecl sampgdk::SetGameModeText(char const *)" (?SetGameModeText@sampgdk@@YA_NPBD@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_AddPlayerClass imported in function "int __cdecl sampgdk::AddPlayerClass(int,float,float,float,float,int,int,int,int,int,int)" (?AddPlayerClass@sampgdk@@YAHHMMMMHHHHHH@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_SetTimer imported in function "int __cdecl sampgdk::SetTimer(int,bool,void (__cdecl*)(int,void *),void *)" (?SetTimer@sampgdk@@YAHH_NP6AXHPAX@Z1@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_SetPlayerPos imported in function "bool __cdecl sampgdk::SetPlayerPos(int,float,float,float)" (?SetPlayerPos@sampgdk@@YA_NHMMM@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_GetPlayerName imported in function "int __cdecl sampgdk::GetPlayerName(int,char *,int)" (?GetPlayerName@sampgdk@@YAHHPADH@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_SetPlayerCameraPos imported in function "bool __cdecl sampgdk::SetPlayerCameraPos(int,float,float,float)" (?SetPlayerCameraPos@sampgdk@@YA_NHMMM@Z)
1>Source.obj : warning LNK4217: locally defined symbol _sampgdk_SetPlayerCameraLookAt imported in function "bool __cdecl sampgdk::SetPlayerCameraLookAt(int,float,float,float,int)" (?SetPlayerCameraLookAt@sampgdk@@YA_NHMMMH@Z)
1>SA-MP C++.vcxproj -> G:\Proiect\SA-MP C++\Debug\SA-MP C++.dll
1>Done building project "SA-MP C++.vcxproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
and I build with CTRL+F7
Code:
1>------ Build started: Project: SA-MP C++, Configuration: Debug Win32 ------
1>Source.cpp
1>d:\windows kits\10\include\10.0.17763.0\ucrt\malloc.h(174): warning C4005: 'alloca': macro redefinition
1>g:\proiect\sdk\amx\amx.h(87): note: see previous definition of 'alloca'
1>Done building project "SA-MP C++.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
How can I solve?
I don't have sampgdk.lib
I tried with old version 4.5.3, I don't have errors but my plugin is not loaded.
new.pwn:
Code:
#include <a_samp>



main()
{
}

public OnGameModeInit()
{
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}



public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

Last edited by lWiDuAlKl; 08/01/2019 at 09:10 PM.
lWiDuAlKl is offline   Reply With Quote
Old 08/01/2019, 07:17 PM   #2
lWiDuAlKl
Little Clucker
 
Join Date: Jan 2019
Posts: 5
Reputation: 0
Default Re: Problem SA-MP Server C++

someone?
lWiDuAlKl is offline   Reply With Quote
Old 08/01/2019, 07:36 PM   #3
AhmedMohamed
Huge Clucker
 
AhmedMohamed's Avatar
 
Join Date: Jan 2014
Location: Egypt
Posts: 338
Reputation: 3
Default Re: Problem SA-MP Server C++

Not so much players know how to script with c++, so unfortunately you may not found solution here.
They all prefer pawn code, me either.
AhmedMohamed is offline   Reply With Quote
Old 08/01/2019, 08:54 PM   #4
lWiDuAlKl
Little Clucker
 
Join Date: Jan 2019
Posts: 5
Reputation: 0
Default Re: Problem SA-MP Server C++

Quote:
Originally Posted by AhmedMohamed View Post
Not so much players know how to script with c++, so unfortunately you may not found solution here.
They all prefer pawn code, me either.
It's few member to know c++. I ask them.
lWiDuAlKl is offline   Reply With Quote
Old 08/01/2019, 10:03 PM   #5
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 394
Reputation: 32
Default Re: Problem SA-MP Server C++

As far i can see your code is mostly the example on github but with some parts missing. The includes like sampgdk/a_samp

Altough i would open an issue on the github page of the project with the warnings and the current code. There you might get a better response and who knows maybe from Zeex himself
Banditul18 is offline   Reply With Quote
Old 08/01/2019, 11:10 PM   #6
lWiDuAlKl
Little Clucker
 
Join Date: Jan 2019
Posts: 5
Reputation: 0
Default Re: Problem SA-MP Server C++

Quote:
Originally Posted by Banditul18 View Post
As far i can see your code is mostly the example on github but with some parts missing. The includes like sampgdk/a_samp

Altough i would open an issue on the github page of the project with the warnings and the current code. There you might get a better response and who knows maybe from Zeex himself
RO: Nu banditule, ideea e ca versiunea 4.6.2 e facuta sa nu ai nevoie decat de sampgdk.h si .c, poate si de un fisier .lib(acesta e inexistent) pentru ca tot ce se afla in a_samp a_players etc e scris intr-un singur header.

EN: No, version 4.6.2 it's build to use just sampgdk.h and .c, maybe .lib(but .lib don't exist).
lWiDuAlKl 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
Can't start the server, mysql problem ? [Windows hosted server] Kelzano Server Support 3 19/05/2017 01:10 AM
Problem opening a SA:MP server on Windows Server 2012 R2 GodLight Server Support 6 26/10/2016 02:52 PM
Problem on joining the server on samp server. Player985 Client Support 9 09/01/2014 12:56 AM
Problem with my server. Bought the server on hrvatski-hosting.com dynetictrinity Server Support 1 29/10/2012 09:55 PM
[SOLVED] Server Problem. Server not visible for friends. Juanxz Server Support 0 26/01/2010 08:34 AM


All times are GMT. The time now is 06:33 AM.


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