Raised This Month: $ Target: $400
 0% 

cs_set_user_team crashes server?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shino
Senior Member
Join Date: May 2006
Old 05-27-2006 , 16:18   cs_set_user_team crashes server?
Reply With Quote #1

i use this code:
Code:
public MakeBots(players[]) {     new players[32],num,i     get_players(players,num)     for(i = 0; i <= num; i++) {         new id = players[i]         new CsArmorType:ArmorType         if (is_user_alive(id) && is_user_bot(id)) {             set_user_health(id,get_cvar_num("amx_zombiebot_health"))             cs_set_user_armor(id,get_cvar_num("amx_zombiebot_armor"),ArmorType)             cs_set_user_model(id,"zombie")             }         }     return PLUGIN_CONTINUE }

after few seconds in game, server crashes with ED_Alloc: no free edicts error. i read somewhere in this forum, that reasons could be too many entities created or some entity handle was leaked, so it was never freed, and they kept building up.
i am almost sure that error occures because cs_set_user_armor. how could i fix that? thanks
shino is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-27-2006 , 16:19  
Reply With Quote #2

It's because you never assign a value to ArmorType, it's just 0, which AFAIK doesn't work.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-27-2006 , 16:21  
Reply With Quote #3

Some slight optimizations and fixes:

Code:
public MakeBots(players[]) {     new players[32],num,i,id,CsArmorType:ArmorType = CS_ARMOR_VESTHELM     get_players(players,num)     for(i = 0; i < num; i++) {         id = players[i]         if (is_user_alive(id) && is_user_bot(id)) {             set_user_health(id,get_cvar_num("amx_zombiebot_health"))             cs_set_user_armor(id,get_cvar_num("amx_zombiebot_armor"),ArmorType)             cs_set_user_model(id,"zombie")         }     }     return PLUGIN_CONTINUE }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
shino
Senior Member
Join Date: May 2006
Old 05-27-2006 , 16:48  
Reply With Quote #4

it doesn't work

here is whole script
Code:
#include <amxmodx> #include <cstrike> #include <fun> public plugin_init() {     register_plugin("ZombieBot", "1.1", "Shino")     register_dictionary("zombiebot.txt")         register_cvar("amx_zombiebot_health","450")     register_cvar("amx_zombiebot_armor","900")     register_event("WeapPickup","SetKnife","b")       register_logevent("round_start",2,"0=World triggered","1=Round_Start") } public plugin_precache() {     precache_model("models/zombiebot/zombie.mdl") } public client_putinserver() {     if (get_playersnum() == 1) {         set_cvar_num("sv_restartround", 1)     } } public round_start() {     set_task(0.1,"BotNumber")     set_task(0.5,"MakeBots")     set_task(1.0,"TeamCheck")     set_task(2.5,"StartMsg")     set_task(3.0,"SetKnife") } public BotNumber() {     new player_num, bot_num, rplayer_num     player_num = get_playersnum()     bot_num = get_cvar_num("bot_quota")     rplayer_num = player_num - bot_num     if (rplayer_num > 0 && rplayer_num < 3) {         set_cvar_num("bot_quota", 2)     }     if (rplayer_num > 2 && rplayer_num < 5) {         set_cvar_num("bot_quota", 4)     }     if (rplayer_num > 4 && rplayer_num < 7) {         set_cvar_num("bot_quota", 6)     }     if (rplayer_num > 6 && rplayer_num < 9) {         set_cvar_num("bot_quota", 8)     }     if (rplayer_num > 8 && rplayer_num < 11) {         set_cvar_num("bot_quota", 10)     }     if (rplayer_num > 10 && rplayer_num < 13) {         set_cvar_num("bot_quota", 12)     }     if (rplayer_num > 12 && rplayer_num < 15) {         set_cvar_num("bot_quota", 14)     }     if (rplayer_num > 14 && rplayer_num < 17) {         set_cvar_num("bot_quota", 16)     }     return PLUGIN_CONTINUE } public MakeBots(players[]) {     new players[32],num,i,id,CsArmorType:ArmorType = CS_ARMOR_VESTHELM     get_players(players,num)     for(i = 0; i < num; i++) {         id = players[i]         if (is_user_alive(id) && is_user_bot(id)) {             set_user_health(id,get_cvar_num("amx_zombiebot_health"))             cs_set_user_armor(id,get_cvar_num("amx_zombiebot_armor"),ArmorType)             cs_set_user_model(id,"zombie")         }     }     return PLUGIN_CONTINUE }   public TeamCheck(players[]) {     new players[32],num,i     get_players(players,num)     for(i = 0; i <= num; i++) {         new id = players[i]         if (is_user_alive(id)) {             if (is_user_bot(id) && cs_get_user_team(id) == CS_TEAM_CT) {                 cs_set_user_team(id,CS_TEAM_T)                 set_cvar_num("sv_restartround", 1)             } else {                 cs_set_user_team(id,CS_TEAM_CT)             }         }     } } public StartMsg() {     client_print(0,print_chat,"%L",LANG_PLAYER,"ZOMBIEBOT_STARTMSG",get_cvar_num("amx_zombiebot_health"))     client_print(0,print_chat,"%L",LANG_PLAYER,"ZOMBIEBOT_NUMBER",get_cvar_num("bot_quota"))     return PLUGIN_CONTINUE } public SetKnife(players[]) {     new players[32],num,i     get_players(players,num)     for(i = 0; i <= num; i++) {         new id = players[i]         if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T) {             strip_user_weapons(id)             give_item(id,"weapon_knife")         }     } }
shino is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-27-2006 , 17:08  
Reply With Quote #5

Try lowering the cvar.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
shino
Senior Member
Join Date: May 2006
Old 05-28-2006 , 14:02  
Reply With Quote #6

ok, i know what's the problem. here it is:

register_event("WeapPickup","SetKnife","b")

public SetKnife(players[]) {
new players[32],num,i
get_players(players,num)
for(i = 0; i <= num; i++) {
new id = players[i]
if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T) {
strip_user_weapons(id)
give_item(id,"weapon_knife")
}
}
}

anybody has any suggestions? thanks
shino is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-28-2006 , 14:06  
Reply With Quote #7

Change SetKnife(players[]) to SetKnife(index) or something like that.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
shino
Senior Member
Join Date: May 2006
Old 05-28-2006 , 14:22  
Reply With Quote #8

that doesn't work.
shino is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-28-2006 , 14:27  
Reply With Quote #9

Quote:
Originally Posted by shino
that doesn't work.
If they have the C4, it's not a good idea to strip their weapons.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
shino
Senior Member
Join Date: May 2006
Old 05-28-2006 , 15:38  
Reply With Quote #10

this whole problem is because of WeapPickup event. if i do not register this event, server won't crash, but bots still drop all their weapons at round start, including C4. this event is there, so zombies would be stripped from weapon they have picked up during the play from a dead player and knife would be given to them once again.
but if this event is registered, server crashes after about 3 seconds with ED_Alloc: no free edicts error.
shino is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode