aboutsummaryrefslogtreecommitdiff
path: root/sample/main.c
blob: 27e5bc372fa0a372f48ebf478e5766184deafa1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "../plugin/plugin.h"

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

const uint32_t epg_version = 1;

const char *epg_name = "Test Plugin";
const char *epg_id = "test";

int epg_load(struct epg_handle *handle)
{
	printf("[%s]: Loaded.\n", handle->id);
	int r = 0;
	r = handle->rcon_send(11, "list uuid");
	printf("[%s]: rcon_send: %d\n", handle->id, r);
	int id = -1;
	char out[RCON_DATA_BUFFSIZE];
	r = handle->rcon_recv(&id, out);
	printf("[%s]: rcon_recv: %d. ID: %d, out: '%s'.\n", handle->id, r, id, out);
	return 0;
}

int epg_unload(struct epg_handle *handle)
{
	printf("[%s]: Unloading.\n", handle->id);
	return 0;
}

int epg_player_join(struct epg_handle *handle,
		char *player)
{
	printf("[%s]: %s joined.\n", handle->id, player);
	sleep(10);
	int r = 0;
	r = handle->rcon_send(11, "list");
	printf("[%s]: rcon_send: %d\n", handle->id, r);
	int id = -1;
	char out[RCON_DATA_BUFFSIZE];
	r = handle->rcon_recv(&id, out);
	printf("[%s]: rcon_recv: %d. ID: %d, out: '%s'.\n", handle->id, r, id, out);
	return 0;
}

int epg_player_leave(struct epg_handle *handle,
		char *player,
		char *reason)
{
	printf("[%s]: %s left: %s.\n", handle->id, player, reason);
	return 0;
}

int epg_player_say(struct epg_handle *handle,
		char *player,
		char *content)
{
	printf("[%s]: %s said: %s.\n", handle->id, player, content);
	return 0;
}

int epg_player_die(struct epg_handle *handle,
		char *player,
		char *source)
{
	printf("[%s]: %s died because of %s.\n", handle->id, player, source);
	return 0;
}

int epg_player_achievement(struct epg_handle *handle,
		char *player,
		char *achievement)
{
	printf("[%s]: %s achieved %s.\n", handle->id, player, achievement);
	return 0;
}

int epg_player_challenge(struct epg_handle *handle,
		char *player,
		char *challenge)
{
	printf("[%s]: %s made the challenge: %s.\n", handle->id, player, challenge);
	return 0;
}

int epg_player_goal(struct epg_handle *handle,
		char *player,
		char *goal)
{
	printf("[%s]: %s made the goal: %s.\n", handle->id, player, goal);
	return 0;
}

int epg_server_stopping(struct epg_handle *handle)
{
	printf("[%s]: Server stopped.\n", handle->id);
	return 0;
}

int epg_server_starting(struct epg_handle *handle,
		char *version)
{
	printf("[%s]: Server is starting, version: %s.\n", handle->id, version);
	return 0;
}

int epg_server_started(struct epg_handle *handle,
		char *took)
{
	printf("[%s]: Server started, took: %s.\n", handle->id, took);
	return 0;
}