#include <stdio.h>
#include <string.h>
#include <sampgdk/a_players.h>
#include <sampgdk/a_samp.h>
#include <sampgdk/core.h>
static ThisPlugin helloworld;
int rgeral = 0;
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);
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[128];
sprintf(message, "Hello, %s!", name);
SendClientMessage(playerid, 0x00FF00FF, message);
return true;
}
return false;
}
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerUpdate(int playerid) {
if (rgeral == 5) {
float health;
char msg[128];
sampgdk_GetPlayerHealth(playerid, &health);
sprintf(msg, "%f", health);
SendClientMessage(playerid, -1, msg);
rgeral = 0;
}
else {
rgeral++;
}
return true;
}
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerTakeDamage(int playerid, int issuerid, float amount, int weaponid, int bodypart) {
float vida;
sampgdk_GetPlayerHealth(playerid, &vida);
char msg[128];
sprintf(msg, "%f, %f", vida, amount);
SendClientMessageToAll(0x00FF00FF, msg);
return true;
}
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
return SUPPORTS_VERSION | SUPPORTS_PROCESS_TICK;
}
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
return helloworld.Load(ppData) >= 0;
}
PLUGIN_EXPORT void PLUGIN_CALL Unload() {
helloworld.Unload();
}
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
helloworld.ProcessTimers();
}
#include <a_samp>
new rgeral = 0;
main() {}
public OnGameModeInit() {
SetGameModeText("Hello, World!");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return true;
}
public OnPlayerConnect( playerid) {
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the HelloWorld server!");
return true;
}
public OnPlayerRequestClass( playerid, classid) {
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746, CAMERA_CUT);
return true;
}
public OnPlayerCommandText( playerid, cmdtext[]) {
return false;
}
public OnPlayerUpdate( playerid) {
if (rgeral == 5) {
new Float:health;
new msg[128];
GetPlayerHealth(playerid, health);
format(msg, 128, "%f", health);
SendClientMessage(playerid, -1, msg);
rgeral = 0;
}
else {
rgeral++;
}
return true;
}
public OnPlayerTakeDamage( playerid, issuerid, Float:amount, weaponid, bodypart) {
new Float:vida;
GetPlayerHealth(playerid, vida);
new msg[128];
format(msg, 128, "%f, %f", vida, amount);
SendClientMessageToAll(0x00FF00FF, msg);
return true;
}
To me it looks stupid, because we get a FLOAT point of damage amount, and the heath is counted like INTEGER, but ok!
|