server-sided health problem.
#1

solved
Reply
#2

Well i think zHealth[playerid] should be Float because the amount is Float

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
also i don't know OnPlayerUpdate is too quick it will set your health or not better Update it under OnPlayerTakeDamage.

Код:
new Float:zHealth[MAX_PLAYERS];

  switch(weaponid)
                {
                    case 30: if(DoubleTap[issuerid] == 1) zHealth[playerid] -= 2*amount;
                    case 8: zHealth[playerid] -= 250;
                    case 33: zHealth[playerid] -= amount + 10;
                    case 24: zHealth[playerid] -= 80;
                    case 34: zHealth[playerid] -= amount + 25;
                    case 25: zHealth[playerid] -= amount + 6;
                    case 27: zHealth[playerid] -= amount + 55;
                    case 31: zHealth[playerid] -= amount + 79;
                    case 29: zHealth[playerid] -= amount + 63;
                    default: zHealth[playerid] -= amount;
                }
Reply
#3

Quote:
Originally Posted by MBilal
Посмотреть сообщение
Well i think zHealth[playerid] should be Float because the amount is Float

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
also i don't know OnPlayerUpdate is too quick it will set your health or not better Update it under OnPlayerTakeDamage.

Код:
new Float:zHealth[MAX_PLAYERS];

  switch(weaponid)
                {
                    case 30: if(DoubleTap[issuerid] == 1) zHealth[playerid] -= 2*amount;
                    case 8: zHealth[playerid] -= 250;
                    case 33: zHealth[playerid] -= amount + 10;
                    case 24: zHealth[playerid] -= 80;
                    case 34: zHealth[playerid] -= amount + 25;
                    case 25: zHealth[playerid] -= amount + 6;
                    case 27: zHealth[playerid] -= amount + 55;
                    case 31: zHealth[playerid] -= amount + 79;
                    case 29: zHealth[playerid] -= amount + 63;
                    default: zHealth[playerid] -= amount;
                }
That didn't work either, thanks though.
Reply
#4

Are you sure that it isn't decreasing ? The maximum value that can be shown in health HUD is 100. If you are above it you will still see it as 100 until it goes below 100. You are setting the health to 5000 (a lot before it reaches 100) at spawn. Try using printf with the value of zHealth below the code in OnPlayerTakeDamage and see its actual value. If it is actually decreasing, then it's alright, maybe you would want to increase that spawn health.
Reply
#5

case 31: zHealth[playerid] -= amount + 79;

I'm quite sure this will actually increase health...
If I remember correctly (long time since I worked with weapon ids and damages) ID 31 is an M4 and that makes 10 damage per shot... uhm so what that does is actuall zHealth[playerid] = zHealth[playerid] - 10 + 79 = zHealth[playerid] + 69

Are you sure you want to use the + there?
Reply
#6

Quote:
Originally Posted by Kimossab
Посмотреть сообщение
case 31: zHealth[playerid] -= amount + 79;

I'm quite sure this will actually increase health...
If I remember correctly (long time since I worked with weapon ids and damages) ID 31 is an M4 and that makes 10 damage per shot... uhm so what that does is actuall zHealth[playerid] = zHealth[playerid] - 10 + 79 = zHealth[playerid] + 69

Are you sure you want to use the + there?
No I wasnt even going to use a + because I knew it will increase lol.
Fixed anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)