forked from Hereticbeast/sampgdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelloworld.cpp
61 lines (51 loc) · 1.78 KB
/
helloworld.cpp
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
#include <stdio.h>
#include <string.h>
#include <sampgdk/a_players.h>
#include <sampgdk/a_samp.h>
#include <sampgdk/core.h>
#include <sampgdk/sdk.h>
void SAMPGDK_CALL PrintTickCountTimer(int timerid, void *params) {
sampgdk::logprintf("Tick count: %d", GetTickCount());
}
PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
SetGameModeText("Hello, World!");
AddPlayerClass(0, 1958.3783f, 1343.1572f, 15.3746f, 269.1425f,
0, 0, 0, 0, 0, 0);
SetTimer(1000, true, PrintTickCountTimer, 0);
return true;
}
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect(int playerid) {
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the HelloWorld server!");
return true;
}
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerRequestClass(int playerid,
int classid) {
SetPlayerPos(playerid, 1958.3783f, 1343.1572f, 15.3746f);
SetPlayerCameraPos(playerid, 1958.3783f, 1343.1572f, 15.3746f);
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];
GetPlayerName(playerid, name, sizeof(name));
char message[MAX_CLIENT_MESSAGE];
sprintf(message, "Hello, %s!", name);
SendClientMessage(playerid, 0x00FF00FF, message);
return true;
}
return false;
}
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
return sampgdk::Load(ppData);
}
PLUGIN_EXPORT void PLUGIN_CALL Unload() {
sampgdk::Unload();
}
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
sampgdk::ProcessTick();
}