PDA

View Full Version : OnPlayerTakeDamage problem


Reignbow
17/12/2016, 07:50 AM
So, i wrote this code so that people would fall over if shot in either of the legs. It worked and compiled fine but when i tried it ingame it crashed the server and i had to restart to be able to actually do anything again. Would anyone tell me if it's the code? and also how to fix the Animation as it doesnt play through or work properly.

Here's the code;
if(weaponid >= 22 && weaponid <= 34 && bodypart == 7 || bodypart == 8)
{
ApplyAnimation(playerid,"PED","KO_skid_front",4.1, 1, 0, 0, 0, 100, 1);
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, COLOR_RED, "You were shot in the legs, you cant walk properly");
SetTimerEx("damagedlegs", 5000, false, "i", playerid);
return 1;
}

forward damagedlegs(playerid);
public damagedlegs(playerid)
{
TogglePlayerControllable(playerid, 1);
KillTimer(damagedlegs(playerid));
return 1;
}

Logic_
17/12/2016, 07:58 AM
Use crashdetect and post the server log with the backtraces form the server log.

Reignbow
17/12/2016, 08:10 AM
Use crashdetect and post the server log with the backtraces form the server log.

The server doesnt shut down, that's the thing. It just breaks all the code in the server. It stops me being able to do all commands and the other person can still walk around but not use commands. It's really confusing and weird.

Logic_
17/12/2016, 08:22 AM
Do as I said, without the backtraces we can't find out what's the problem.

Reignbow
17/12/2016, 08:51 AM
Do as I said, without the backtraces we can't find out what's the problem.

I did it, installed it and the server didnt crash but it timed out me and the other person without a crash log. Which is weird. All i want it to do is make the player fall over whenever they're shot in the leg for like 5 seconds or something :(

Logic_
17/12/2016, 08:54 AM
You still didn't get me, Crashdetect is a server plugin, load it, test out the feature, and post the server log. I want the server log to investigate the issue, without it finding where the problem persists is hard.

Reignbow
17/12/2016, 08:59 AM
You still didn't get me, Crashdetect is a server plugin, load it, test out the feature, and post the server log. I want the server log to investigate the issue, without it finding where the problem persists is hard.

[08:51:54] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[08:51:54] [debug] Stack pointer (STK) is 0x38296D8, heap pointer (HEA) is 0x382969C
[08:51:54] [debug] AMX backtrace:
[08:51:54] [debug] #0 00298160 in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #1 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #2 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #3 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #4 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #5 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #6 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #7 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #8 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #9 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #10 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #11 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #12 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #13 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #14 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #15 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #16 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #17 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #18 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #19 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #20 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #21 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #22 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #23 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #24 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #25 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #26 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #27 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #28 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #29 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #30 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #31 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #32 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #33 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #34 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #35 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #36 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #37 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #38 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #39 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #40 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #41 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #42 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #43 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #44 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #45 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #46 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #47 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #48 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #49 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #50 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #51 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #52 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #53 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #54 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #55 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #56 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #57 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #58 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #59 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #60 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #61 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #62 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #63 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #64 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #65 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #66 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #67 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #68 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #69 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #70 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #71 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #72 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #73 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #74 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #75 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #76 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #77 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #78 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #79 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #80 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #81 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #82 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #83 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #84 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #85 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #86 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #87 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #88 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #89 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #90 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #91 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #92 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #93 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #94 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #95 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #96 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #97 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #98 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #99 002981ac in public damagedlegs (1) from RWRP.amx
[08:51:54] [debug] #100 002981ac in public damagedlegs (1) from RWRP.amx

[08:51:54] [warning] client exceeded 'ackslimit' 86.16.36.129:26416 (6538) Limit: 3000/sec

here it is, and it doesnt play the animation at all for the player being shot.

Logic_
17/12/2016, 09:14 AM
Animation isn't applied because of the TogglePlayerControllable.
Try this code;


if((weaponid >= 22 && weaponid <= 34) && (bodypart == 7 || bodypart == 8))
{
ApplyAnimation(playerid, "PED", "KO_skid_front", 4.1, 0, 0, 1, 0, 1);
SendClientMessage(playerid, COLOR_RED, "You were shot in the legs, you cant walk properly");
SetTimerEx("damagedlegs", 5000, false, "i", playerid);
return 1;
}



forward damagedlegs(playerid);
public damagedlegs(playerid)
{
ClearAnimations(playerid);
return 1;
}

Reignbow
17/12/2016, 09:27 AM
Animation isn't applied because of the TogglePlayerControllable.
Try this code;


if((weaponid >= 22 && weaponid <= 34) && (bodypart == 7 || bodypart == 8))
{
ApplyAnimation(playerid, "PED", "KO_skid_front", 4.1, 0, 0, 1, 0, 1);
SendClientMessage(playerid, COLOR_RED, "You were shot in the legs, you cant walk properly");
SetTimerEx("damagedlegs", 5000, false, "i", playerid);
return 1;
}



forward damagedlegs(playerid);
public damagedlegs(playerid)
{
ClearAnimations(playerid);
return 1;
}


It still crashes, so i've removed the code for now. Thank you for the help, i +reppped for the effort and support.

Logic_
17/12/2016, 09:32 AM
No need to remove the code, but optimize your script, you script is using too many resources, and also raise your ackslimit count to 4000 in the server.cfg. I got some information by searching 'Stack/heap collision samp' on ******.

@Vince's post: http://forum.sa-mp.com/showpost.php?p=1981666&postcount=4

Reignbow
17/12/2016, 09:59 AM
No need to remove the code, but optimize your script, you script is using too many resources, and also raise your ackslimit count to 4000 in the server.cfg. I got some information by searching 'Stack/heap collision samp' on ******.

@Vince's post: http://forum.sa-mp.com/showpost.php?p=1981666&postcount=4

I'm unsure of how to optimize it. So currently it's set as a note for the code using /* and */. Not completely removed but it doesnt do anything in the game. Thank you again :)

Logic_
17/12/2016, 12:24 PM
If you are unsure, check out my 'Important Tutorials' thread, link in the signature. I've also added tutorials on how to optimize scripts.

NaS
17/12/2016, 12:59 PM
EDIT sorry, I'm blind. :X