Variable can't be changed
#1

Hello it's me again with an odd bug;

pawn Код:
new Float:bki[MAX_PLAYERS];
    new Float:boymetre[MAX_PLAYERS];
    new Float:boycarpimi[MAX_PLAYERS];
    boymetre[playerid] = pInfo[playerid][Boy] / 100;
    boycarpimi[playerid] = boymetre[playerid] * boymetre[playerid];
    bki[playerid] = pInfo[playerid][Kilo] / boycarpimi[playerid];
    new obezite[MAX_PLAYERS];
    if(bki[playerid] < 30.0) // obez degil
        obezite[playerid] = 0;
    else if(bki[playerid] >= 30.0) // obez
        obezite[playerid] = 1;
This is the code, sorry if pawn tags ruined the indentation. Everything works fine, bki, boymetre and boycarpimi are acquired just like it should be acquired but obezite variable can't be changed regardless of what I've tried. So far I've tried;

- Commenting both if statements and just writing "obezite[playerid] = 1;"
- Renaming the variable to whole another variable to see if it was getting a standard value from somewhere in the script
- Printing out everything this function calculates to see if anything else was bugged.

It's the obezite variable that is bugged, I am certain of it at this point. No matter what I do, it's value is always 0, furthermore, it's not a standard zero as the code gives skins based on obezite variable and it doesn't work, but it works when I comment the obezite check. It's kind of odd. I've wasted an hour trying to figure out what was wrong, I hope it is not something easy that I've been missing for the past hour lol

Edit: This is the whole function;

pawn Код:
stock SkinAlgoritma(playerid)
{
    new Float:bki[MAX_PLAYERS];
    new Float:boymetre[MAX_PLAYERS];
    new Float:boycarpimi[MAX_PLAYERS];
    boymetre[playerid] = pInfo[playerid][Boy] / 100;
    boycarpimi[playerid] = boymetre[playerid] * boymetre[playerid];
    bki[playerid] = pInfo[playerid][Kilo] / boycarpimi[playerid];
    new obezite[MAX_PLAYERS];
    if(bki[playerid] < 30.0) // obez degil
        obezite[playerid] = 0;
    if(bki[playerid] >= 30.0) // obez
        obezite[playerid] = 0;
    if(obezite[playerid] = 0) // oyuncu obez degilse
    {
        if(pInfo[playerid][Cinsiyet] == 0) // oyuncu erkekse
        {
            if(pInfo[playerid][TenRengi] == 0) // oyuncu beyazsa
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 23);
                else // oyuncu yasliysa
                    SetPlayerSkin(playerid, 235);
            }
            else if(pInfo[playerid][TenRengi] == 1) // oyuncu siyahiyse
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 7);
                else
                    SetPlayerSkin(playerid, 6);
            }
        }
        else if(pInfo[playerid][Cinsiyet] == 1) // oyuncu bayansa
        {
            if(pInfo[playerid][TenRengi] == 0) // oyuncu beyazsa
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 93);
                else // oyuncu yasliysa
                    SetPlayerSkin(playerid, 224);
            }
            else if(pInfo[playerid][TenRengi] == 1) // oyuncu siyahiyse
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 190);
                else
                    SetPlayerSkin(playerid, 76);
            }
        }
    }
    if(obezite[playerid] == 1) // oyuncu obezse
    {
        if(pInfo[playerid][Cinsiyet] == 0) // oyuncu erkekse
        {
            if(pInfo[playerid][TenRengi] == 0) // oyuncu beyazsa
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 242);
                else // oyuncu yasliysa
                    SetPlayerSkin(playerid, 258);
            }
            else if(pInfo[playerid][TenRengi] == 1) // oyuncu siyahiyse
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 5);
                else
                    SetPlayerSkin(playerid, 220);
            }
        }
        else if(pInfo[playerid][Cinsiyet] == 1) // oyuncu bayansa
        {
            if(pInfo[playerid][TenRengi] == 0) // oyuncu beyazsa
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 151);
                else // oyuncu yasliysa
                    SetPlayerSkin(playerid, 39);
            }
            else if(pInfo[playerid][TenRengi] == 1) // oyuncu siyahiyse
            {
                if(pInfo[playerid][Yas] < 50) // oyuncu genзse
                    SetPlayerSkin(playerid, 219);
                else
                    SetPlayerSkin(playerid, 10);
            }
        }
    }
    ShowPlayerDialog(playerid, DIALOG_DOGRULAMA, DIALOG_STYLE_MSGBOX, "{0174DF}[T-RP]: {FFFFFF}Dogrulama", "{FFFFFF}Olusturdugunuz karakterle devam etmek istiyor musunuz?\nUnutmayin; istediginiz zaman karakterinizin goruntusunu degistirebilirsiniz, bu sadece gecici bir karakter!","Devam","Geri Don");
    printf("%d",obezite[playerid]);
    return 1;
}
Reply
#2

PHP код:
new obezite[MAX_PLAYERS]; 
I think you have to put this outside the function, try to put it under main() (it's at the top of your script)
Reply
#3

In the code you are setting it as 0 on both cases(as I see in the last code posted) also you are using assignment operator instead of == in the coming if check. so ultimately it will be zero

Код:
if(bki[playerid] < 30.0) // obez degil
		obezite[playerid] = 0;
	if(bki[playerid] >= 30.0) // obez
		obezite[playerid] = 1;
	if(obezite[playerid] = 0) // should be ==
	{
Reply
#4

Quote:
Originally Posted by PeanutButter
Посмотреть сообщение
PHP код:
new obezite[MAX_PLAYERS]; 
I think you have to put this outside the function, try to put it under main() (it's at the top of your script)
Nope, didn't work :/
Reply
#5

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
In the code you are setting it as 0 on both cases(as I see in the last code posted) also you are using assignment operator instead of == in the coming if check. so ultimately it will be zero
Aaand yeah, I think I must sleep lol, another dumb question from me. Thanks a lot! The setting both as 0 was a result of me testing whether or not the script was bugged, it was setting one 0 and the other one 1 at first.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)