rounding health value
#1

well, it's hard to explain, so, look at the image. the code is below. I don't understand, why is it rouding. Or it's normal?



this is the code i used with sampgdk 3.7, but i'm using sampgdk4, and it's the same... I thought the problema in the sampgdk version, but when i change a the error persists, i realized that not

pawn Код:
#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();
}

if anyone can help me, i'm very grateful
Have a good day/night
Reply


Messages In This Thread
[SOLVED] rounding health value - by DartakousLien - 03.07.2014, 23:49
Re: rounding health value - by DartakousLien - 04.07.2014, 00:17
Re: rounding health value - by Inverse - 04.07.2014, 11:10
Re: rounding health value - by Vince - 04.07.2014, 11:11

Forum Jump:


Users browsing this thread: 1 Guest(s)