SA-MP Forums Archive
Health and Armor not setting. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Health and Armor not setting. (/showthread.php?tid=263703)



Health and Armor not setting. - Lynn - 23.06.2011

pawn Code:
new Float:DuelHealth;
new Float:DuelArmor;
pawn Code:
if(dialogid == DIALOG_DUEL3)
{
    if(response)
    {
        new Float:health = strlen(inputtext);
    DuelHealth = health;
    SendClientMessage(playerid, COLOR_WHITE, " ** You have set the Health ");
    }
}
pawn Code:
if(dialogid == DIALOG_DUEL3)
{
    if(response)
    {
        new Float:armor= strlen(inputtext);
    DuelHealth = armor;
    SendClientMessage(playerid, COLOR_WHITE, " ** You have set the Armor");
    }
}
pawn Code:
public NewSettings
{
    SetPlayerHealth(playerid, DuelHealth);
    SetPlayerArmour(playerid, DuelArmor);
}
This is not all the code, Just things involving HP/Armor


Re: Health and Armor not setting. - Farsek - 23.06.2011

pawn Code:
new Float:DuelHealth;
new Float:DuelArmor;

if(dialogid == DIALOG_DUEL3)
{
    if(response)
    {
        new Float:health = strlen(inputtext);
    DuelHealth = health;
    NewSettings(playerid);
    SendClientMessage(playerid, COLOR_WHITE, " ** You have set the Health ");
    }
}


if(dialogid == DIALOG_DUEL3)
{
    if(response)
    {
        new Float:armor= strlen(inputtext);
    DuelHealth = armor;
    NewSettings(playerid);
    SendClientMessage(playerid, COLOR_WHITE, " ** You have set the Armor");
    }
}
forward NewSettings(playerid);
public NewSettings(playerid)
{
    SetPlayerHealth(playerid, DuelHealth);
    SetPlayerArmour(playerid, DuelArmor);
}
https://sampwiki.blast.hk/wiki/Scripting_Basics#Functions


Re: Health and Armor not setting. - Lynn - 23.06.2011

Wrong.
It sets my HP to like 1 as-well as armor.
When I put any value into the Input box.

The only way I can have it as 100, is if I skip Health / Armor.
Because it sets it to 100 Auto if that step is skipped.
Removed the Float: and added = 100;
new DuelHealth = 100;
new DuelArmor = 100;


Re: Health and Armor not setting. - [HiC]TheKiller - 23.06.2011

Both of the dialogs have the same ID, I don't know how you are trying to work it but, that's obviously not going to work. Also, if you have it for more than one person? How is the variables going to save properly? Use Player Variables, they are probably the best for this situation. Also, player armour and health is not a integer, it's a Float.


Re: Health and Armor not setting. - Lorenc_ - 23.06.2011

pawn Code:
new Float:health = strlen(inputtext); // ?
So, the length of Inputtext will be your health, wont it?

pawn Code:
new Float:health = strval(inputtext); // the value of inputtext



Re: Health and Armor not setting. - Lynn - 23.06.2011

Dialogs are not the Same ID, I just didn't change it when typing the code on here.

EDIT: Fixed, Forgot the main DuelHealth to make it a Float.xD

Thanks !


Re: Health and Armor not setting. - Markx - 23.06.2011

Nevermind.


Re: Health and Armor not setting. - [HiC]TheKiller - 23.06.2011

Quote:
Originally Posted by Lynn
View Post
Dialogs are not the Same ID, I just didn't change it when typing the code on here.

Anyways:
new Float:health = strval(inputtext);
DuelHealth = health;

That gives me a Tag Mismatch error.
On Like; DuelHealth = health;
Of course it would. You are trying to set a Float to a integer.


Re: Health and Armor not setting. - PrawkC - 23.06.2011

pawn Code:
new Float:DuelHealth;
new Float:DuelArmor;

if(dialogid == DIALOG_DUEL3)
{
    if(response)
    {
        DuelHealth = strval(inputtext);
        SetPlayerHealth(playerid, DuelHealth);
        SendClientMessage(playerid, COLOR_WHITE, " ** You have set the Health ");
    }
}


if(dialogid == DIALOG_DUEL3)
{
    if(response)
    {
        DuelArmor = strval(inputtext);
        SetPlayerArmour(playerid, DuelArmor);
        SendClientMessage(playerid, COLOR_WHITE, " ** You have set the Armor");
    }
}
Why not just do it like this ?

Edit: didn't see that you fixed it!