Health and Armor not setting.
#1

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
Reply
#2

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
Reply
#3

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;
Reply
#4

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.
Reply
#5

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
Reply
#6

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 !
Reply
#7

Nevermind.
Reply
#8

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.
Reply
#9

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)