array must be indexed
#1

Hello..what i need to do ?

Код:
D:\Los Santos Roleplay\lsrp\gamemodes\ls-rp.pwn(10259) : error 033: array must be indexed (variable "bodypart")
D:\Los Santos Roleplay\lsrp\gamemodes\ls-rp.pwn(10259) : error 033: array must be indexed (variable "bodypart")

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
	if(PlayerIsWounded(playerid))
	{
		SetPlayerHealth(playerid, 1000.0);
	}
	if((0 <= weaponid <= 46) || weaponid == 54)
	{
	    new bodypart[128];
		if(BODY_PART_TORSO <= bodypart <= BODY_PART_HEAD) Damage[playerid][(bodypart - 3)][weaponid]++;
	}
    return 1;
}
Here i heve this errors:

Код:
if(BODY_PART_TORSO <= bodypart <= BODY_PART_HEAD) Damage[playerid][(bodypart - 3)][weaponid]++;
Reply
#2

Show bodypart
Reply
#3

Код:
GetBodyPartName(bodypart)
{
	new part[20];
	switch(bodypart)
	{
		case BODY_PART_TORSO: part = "BUST";
		case BODY_PART_GROIN: part = "SOLD";
		case BODY_PART_LEFT_ARM: part = "MANA STANGA";
		case BODY_PART_RIGHT_ARM: part = "MANA DREAPTA";
		case BODY_PART_LEFT_LEG: part = "PICIORUL STANG";
		case BODY_PART_RIGHT_LEG: part = "PICIORUL DREPT";
		case BODY_PART_HEAD: part = "CAP";
		default: part = "NIMIC";
	}
	return part;
}
This ?
Reply
#4

Anyone please ?
Reply
#5

pawn Код:
if(BODY_PART_TORSO <= bodypart <= BODY_PART_HEAD) Damage[playerid][(bodypart - 3)][weaponid]++;
Your issue is here, as far as I can tell. "<= bodypart <=" & "bodypart", as you've used 'new bodypart[INDEX]', and you're not using it correctly.
Reply
#6

if(BODY_PART_TORSO <= "bodypart" <= BODY_PART_HEAD) Damage[playerid][(bodypart - 3)][weaponid]++;

It's correctly ?
Reply
#7

Anybody ?
Reply
#8

"bodypart" is supposed to be a variable and it can be retrieved from the callback itself than defining an array. This is how it should look like:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(PlayerIsWounded(playerid))
    {
        SetPlayerHealth(playerid, 1000.0);
    }
    if((0 <= weaponid <= 46) || weaponid == 54)
    {
       // new bodypart[128];
        if(BODY_PART_TORSO <= bodypart <= BODY_PART_HEAD) Damage[playerid][(bodypart - 3)][weaponid]++;
    }
    return 1;
}
Reply
#9

Now i have a error : function heading differs from prototype

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
Reply
#10

You were using integer operations on strings, you can't compare strings that way.

pawn Код:
new bodypart[128];
if(BODY_PART_TORSO <= bodypart <= BODY_PART_HEAD)
You are checking 2 integer values (BODY_PART_TORSO and BODY_PART_HEAD) against a string-type variable (bodypart), which btw is empty as you just declared it but you didn't put anything inside it.

As for the bodypart parameter, you need to upgrade your server to 0.3z.
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)