Leg Break help, Please help. (+rep)
#1

Okay so ive been working on a leg breaking system, there are two things going wrong, if a player hits them with fists it will break their leg, and if they get hit in the chest or torso it will still break their leg, i have it set to bodypart = 7 and bodypart = 8 but it still does it, i've added teams but when i have the teams and test it, it doesnt carry out the function.

// Body parts
#define BODY_PART_GROIN 4
#define BODY_PART_RIGHT_ARM 5
#define BODY_PART_LEFT_ARM 6
#define BODY_PART_RIGHT_LEG 7
#define BODY_PART_LEFT_LEG 8
new boolLegBroken[MAX_PLAYERS];

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID || weaponid == 22 || weaponid == 23 || weaponid == 24 || weaponid == 25 || weaponid == 26 || weaponid == 27 || weaponid == 28 || weaponid == 29 || weaponid == 30 || weaponid == 31 || weaponid == 32 || weaponid == 33 || weaponid == 34 || weaponid == 35 || weaponid == 36 || weaponid == 37 || weaponid == 38
    && bodypart == 7 || bodypart == 8)
    {
		if(pLegBroken[playerid] == false)
		{
			pLegBroken[playerid] = true;
			ApplyAnimation(playerid, "PED", "CLIMB_jump2fall", 4.1, 1, 0, 0, 1, 0);
   			SCM(playerid, COLOR_LIGHTRED, "-> You've been hit in the leg, you're going to struggle with running and jumping.");
    	}
	}
        return 1;
}
Код:
	if (pLegBroken[playerid])
	{
		if (newkeys & KEY_SPRINT || newkeys & KEY_JUMP)
		ApplyAnimation(playerid, "PED", "CLIMB_jump2fall", 4.1, 0, 0, 0, 1, 0);
	}
Reply
#2

so u only want when a player hits someone on their leg it break right?
Reply
#3

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && weaponid >= 22 && weaponid <= 38 && (bodypart == 7 || bodypart == 8))
    {
		if(pLegBroken[playerid] == false)
		{
			pLegBroken[playerid] = true;
			ApplyAnimation(playerid, "PED", "CLIMB_jump2fall", 4.1, 1, 0, 0, 1, 0);
   			SCM(playerid, COLOR_LIGHTRED, "-> You've been hit in the leg, you're going to struggle with running and jumping.");
    	}
	}
        return 1;
}
Two things changed. First, use brackets to group certain conditions.
Код:
weaponid == 37 || weaponid == 38 && bodypart == 7
would be true if either weaponid==37 or if weaponid==38 and bodypart==7
AND is always checked before OR if not in brackets. Thats why things got messed up.

Second, you can shorten
weaponid == 22 || weaponid == 23 || weaponid == 24 || ...
by checking if weaponid is in a certain range. Thats faster and the code is much easier to read.

Third, use a smaller image in your signature. I wont spend half an hour scrolling to the right to reach the quote button of your post
(Why is there only a height limit but no width limit in the forum signature btw?)
Reply
#4

Im sorry about the signuature, and i will try this, and and when ever a player gets shot in the leg it freezes them in the anim.
Reply
#5

Quote:
Originally Posted by Joron
Посмотреть сообщение
so u only want when a player hits someone on their leg it break right?
if you're fimilar with LS-RP i want it to bew like that, when a player gets shot in the leg they stumble and then whenever they try to sprint or jump they will go in the anim again and stumble, i have the keystatechange in its just whenever a player shoots a player it freezes them in the stumble.
Reply
#6

Try to replace all 1's with 0's in ApplyAnimation function:
PHP код:
ApplyAnimation(playerid"PED""CLIMB_jump2fall"4.100000); 
Reply
#7

I tried that and now he gets the message but he doesnt do an animation.
Reply
#8

Brackets are important..
4 - 2 * 2 is 0, (4-2)*2 is 4, Just as your code, if it's legs, it will break, if it's any of those guns, it will break, fix them with appropriate brackets.
That will solve the problem, I'm assuming the after breaking the leg everything works fine right ?
Reply
#9

Everything works fine with detecting bodyparts but now the player gets stuck at the start of the animation he doesnt fully stumble and then is unfreezed i cant make a video of example but i have a test server if you need to see it.
Reply
#10

bump, I tried another animation and it still freezes them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)