I'm a total newbie in every respect (first time posting as well) and this plugin is very simple, so I'm going to assume I'm making a really stupid mistake somewhere here.
This is a very simple Sven Co-op plugin I'm writing that will automatically adjust certain cvars in proportion to the number of players currently connected. I just started writing it and it'll be for personal use, so I'm not worried about efficiency, redundancy, or the fact that there's unnecessary code scattered about. However, I
am worried about the fact that the plugin completely freezes the game every time I try to test it to the point where the only option I'm left with afterward is task manager. Removing it from my plugins.ini lets the game load normally and changing the set_task delay directly affects how long the game takes to freeze when loading, so the problem has to be in here somewhere.
Code:
#include <amxmodx>
#include <amxmisc>
#include <core>
#include <fun>
#include <engine>
#define VERSION "1.0"
#define LASTUPDATE "18th, December (12), 2018"
public plugin_init()
{
register_plugin("Autobalance",VERSION,"AxonVenom")
create_cvar("autobalance_level","0",FCVAR_NONE,"Sets the current balance level. Default is 0, which is automatic.",true,0.0,false)
set_task(0.5,"ab_balance",0,"",0,"b")
}
public ab_balance()
{
set_cvar_num("mp_respawntime",45)
while(get_cvar_num("autobalance_level")==0)
{
//for(new rate=0;rate<100;rate++)
//{
new level=get_playersnum()-1
ab_adjust(level)
//}
}
}
public ab_adjust(level)
{
set_cvar_float("sk_monster_head",4*(3.5-0.5*(level-1)))
set_cvar_float("sk_monster_chest",1*(3.5-0.5*(level-1)))
set_cvar_float("sk_monster_stomach",2.5*(3.5-0.5*(level-1)))
set_cvar_float("sk_monster_arm",0.25*(3.5-0.5*(level-1)))
set_cvar_float("sk_monster_leg",0.75*(3.5-0.5*(level-1)))
set_cvar_float("sk_player_head",4*(0.75-0.25*(level-1)))
set_cvar_float("sk_player_chest",1*(0.75-0.25*(level-1)))
set_cvar_float("sk_player_stomach",2.5*(0.75-0.25*(level-1)))
set_cvar_float("sk_player_arm",0.25*(0.75-0.25*(level-1)))
set_cvar_float("sk_player_leg",0.75*(0.75-0.25*(level-1)))
}