Quote:
Originally Posted by fysiks
One of the most important skills in programming is debugging. In this case, find out what code is executing when the plugin crashes the server. Comment out that code and see if it's still causing the crash. This will tell you what code is causing the issue.
However, there is a major issue in your code. All of your while loops are very likely causing infinite or near infinite loops. What you've implemented is a non-deterministic loop meaning that it's not guaranteed to execute in a predictable manner.
Also, using a random number based on the number of alive players as your "id" is wrong. To get a valid id of an alive player, you'd need to use something like get_players() and then index that array to get a valid id.
|
I realized that the error is when I add a new class to the plugin
PHP Code:
#include <zp50_class_knifer>
PHP Code:
cvar_nightmare_kni_hp_multi
cvar_nightmare_kni_hp_multi = register_cvar("zp_nightmare_knife_hp_multi", "0.25")
I believe the error is in that part
PHP Code:
//new knife_count = floatround(alive_count * 0.25, floatround_ceil)
new knife_count = survivor_count
// Turn specified amount of players into Knifer
new iKnife, iMaxKnife = knife_count
while (iKnife < iMaxKnife)
{
// Choose random guy
id = GetRandomAlive(random_num(1, alive_count))
// Already a survivor or nemesis?
if (zp_class_survivor_get(id) || zp_class_nemesis_get(id) || zp_class_sniper_get(id) || zp_class_knifer_get(id))
continue;
// If not, turn him into one
zp_class_knifer_set(id)
iKnife++
// Apply Knife health multiplier
set_user_health(id, floatround(get_user_health(id) * get_pcvar_float(cvar_nightmare_kni_hp_multi)))
}
Without the class add the plugin works perfectly