Hello, im creating a plugin just learned few stuff from
@habi hello world plugin so i had a question how would we print helloworld inside game?
/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendClientMessage) (int32_t playerId, uint32_t colour, const char* format, ...);
Header:
extern PluginFuncs* api;
Source:
PluginFuncs* api;
extern "C" unsigned int VcmpPluginInit(PluginFuncs* pluginFuncs, PluginCallbacks* pluginCalls, PluginInfo* pluginInfo) {
api = pluginFuncs;
return 1;
}
// and to use it:
api -> SendClientMessage(playerID, 0xFFFFFFFF, "stuff");
Refer to the VCMP API for the function calls.
thanks Xmair for pointing it out.
@MEGAMIND, in our template it is named VCMP
So VCMP->SendClientMessage(......)
Quote from: Xmair on May 13, 2020, 11:47 AM/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendClientMessage) (int32_t playerId, uint32_t colour, const char* format, ...);
Header:
extern PluginFuncs* api;
Source:
PluginFuncs* api;
extern "C" unsigned int VcmpPluginInit(PluginFuncs* pluginFuncs, PluginCallbacks* pluginCalls, PluginInfo* pluginInfo) {
api = pluginFuncs;
return 1;
}
// and to use it:
api -> SendClientMessage(playerID, 0xFFFFFFFF, "stuff");
Refer to the VCMP API for the function calls.
hey um im getting playerid is undefined.. are there any other headerfiles?
Quote from: MEGAMIND on May 13, 2020, 12:08 PMQuote from: Xmair on May 13, 2020, 11:47 AM/* vcmpErrorNoSuchEntity, vcmpErrorNullArgument, vcmpErrorTooLargeInput */
vcmpError (*SendClientMessage) (int32_t playerId, uint32_t colour, const char* format, ...);
Header:
extern PluginFuncs* api;
Source:
PluginFuncs* api;
extern "C" unsigned int VcmpPluginInit(PluginFuncs* pluginFuncs, PluginCallbacks* pluginCalls, PluginInfo* pluginInfo) {
api = pluginFuncs;
return 1;
}
// and to use it:
api -> SendClientMessage(playerID, 0xFFFFFFFF, "stuff");
Refer to the VCMP API for the function calls.
hey um im getting playerid is undefined.. are there any other headerfiles?
You need to replace
playerID with the player's ID.
how do i send to all isntead of a playerid
i just made one, it is working
char buf[10];
for ( int i = 0; i < VCMP->GetMaxPlayers(); i++ )
{
int b = VCMP->GetPlayerName(i, buf, 10);
if (b == 0)
{
VCMP->SendClientMessage(i, 0xFFFFFFFF, "hello");
}
}
Quote from: habi on May 13, 2020, 01:04 PMi just made one, it is working
char buf[10];
for ( int i = 0; i < VCMP->GetMaxPlayers(); i++ )
{
int b = VCMP->GetPlayerName(i, buf, 10);
if (b == 0)
{
VCMP->SendClientMessage(i, 0xFFFFFFFF, "hello");
}
}
ok plugins loads successfully but no ingame message
I'm not sure about this but in Java, we pass
null instead of the ID to message it to everyone. It might or might not work in C++, give it a try.
Quote from: habi on May 13, 2020, 01:04 PMi just made one, it is working
char buf[10];
for ( int i = 0; i < VCMP->GetMaxPlayers(); i++ )
{
int b = VCMP->GetPlayerName(i, buf, 10);
if (b == 0)
{
VCMP->SendClientMessage(i, 0xFFFFFFFF, "hello");
}
}
for (int i = 0; i < VCMP -> GetMaxPlayers(); ++ i) {
if (VCMP -> IsPlayerConnected(i))
VCMP -> SendClientMessage(i, 0xFFFFFFFF, "hello");
}
Quote from: MEGAMIND on May 13, 2020, 01:19 PMok plugins loads successfully but no ingame message
Are you using that code upon the plugin being loaded? If yes then it won't show any message because no players are connected to the server when the plugins are being loaded initially.
Quote from: Xmair on May 13, 2020, 02:28 PMI'm not sure about this but in Java, we pass null instead of the ID to message it to everyone. It might or might not work in C++, give it a try.
Quote from: habi on May 13, 2020, 01:04 PMi just made one, it is working
char buf[10];
for ( int i = 0; i < VCMP->GetMaxPlayers(); i++ )
{
int b = VCMP->GetPlayerName(i, buf, 10);
if (b == 0)
{
VCMP->SendClientMessage(i, 0xFFFFFFFF, "hello");
}
}
for (int i = 0; i < VCMP -> GetMaxPlayers(); ++ i) {
if (VCMP -> IsPlayerConnected(i))
VCMP -> SendClientMessage(i, 0xFFFFFFFF, "hello");
}
Quote from: MEGAMIND on May 13, 2020, 01:19 PMok plugins loads successfully but no ingame message
Are you using that code upon the plugin being loaded? If yes then it won't show any message because no players are connected to the server when the plugins are being loaded initially.
so how do i just send a message to a user uppon his join
Quote from: MEGAMIND on May 13, 2020, 03:27 PMQuote from: Xmair on May 13, 2020, 02:28 PMI'm not sure about this but in Java, we pass null instead of the ID to message it to everyone. It might or might not work in C++, give it a try.
Quote from: habi on May 13, 2020, 01:04 PMi just made one, it is working
char buf[10];
for ( int i = 0; i < VCMP->GetMaxPlayers(); i++ )
{
int b = VCMP->GetPlayerName(i, buf, 10);
if (b == 0)
{
VCMP->SendClientMessage(i, 0xFFFFFFFF, "hello");
}
}
for (int i = 0; i < VCMP -> GetMaxPlayers(); ++ i) {
if (VCMP -> IsPlayerConnected(i))
VCMP -> SendClientMessage(i, 0xFFFFFFFF, "hello");
}
Quote from: MEGAMIND on May 13, 2020, 01:19 PMok plugins loads successfully but no ingame message
Are you using that code upon the plugin being loaded? If yes then it won't show any message because no players are connected to the server when the plugins are being loaded initially.
so how do i just send a message to a user uppon his join
void playerCreated(int32_t playerId) {
VCMP -> SendClientMessage(playerId, 0xFFFFFFFF, "hello");
}
unsigned int VcmpPluginInit(PluginFuncs* pluginFuncs, PluginCallbacks* pluginCalls, PluginInfo* pluginInfo) {
pluginCalls -> OnPlayerConnect = playerCreated;
}
You should wrap up player and other entities into classes for better accessibility.
In SQMain.cpp, find VcmpPluginInit function.
You can see a line
pluginCalls->OnServerInitialise = OnServerInitialise
This is attaching the function on Right hand side to server. Right hand side can be renamed as anything you like. But there must be a function with that name.
Also to make the function, you can see it's details by moving mouse to pluginCalls->onPlayerConnect
(https://i.imgur.com/of1OTEr.png)
So
void myFunction( int32_t playerID )
{
//your code
}
Thanks to
@Xmair &
@habi Solved, locking topic..