Raised This Month: $ Target: $400
 0% 

[TF2] ED_Alloc: no free edicts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bitl
Senior Member
Join Date: Jul 2012
Old 10-22-2013 , 20:06   [TF2] ED_Alloc: no free edicts
Reply With Quote #1

Today I was working on a gamemode and testing it with bots when I seen the crash error "ED_Alloc: no free edicts"

Is there anything in this code that triggered this?

Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <tf2>
#include <tf2_stocks>
#include <tf2items_giveweapon>
#undef REQUIRE_PLUGIN
#tryinclude <tf2itemsinfo>

#if !defined _tf2itemsinfo_included
new TF2ItemSlot = 8;
#endif

new Handle:sm_spyscreed_maxspies;
new Handle:sm_spyscreed_itemid;

public Plugin:myinfo = 
{
    name = "[TF2] Spy's Creed",
    author = "Bitl",
    description = "Move or be killed.",
    version = "1.0",
    url = ""
}

public OnPluginStart()
{
    CheckGame();
    
    HookEvent("player_spawn", event_Spawn, EventHookMode_Pre);
    HookEvent("post_inventory_application", event_inventory);
    sm_spyscreed_maxspies = CreateConVar("sm_spyscreed_maxspies", "1", "Max amount of spies to be on the BLU team.", FCVAR_NOTIFY);
    sm_spyscreed_itemid = CreateConVar("sm_spyscreed_itemid", "99999", "Item ID for cloaking device.", FCVAR_NOTIFY);
    AutoExecConfig(true, "spyscreed");
}

public OnAllPluginsLoaded()
{
        TF2Items_CreateWeapon( GetConVarInt(sm_spyscreed_itemid), "tf_weapon_invis", 297, 4, 9, 10, "160 ; 1 ; 35 ; 20 ; 34 ; -10 ; 414 ; 1", -1, _, true );
}

CheckGame()
{
    decl String:strModName[32]; GetGameFolderName(strModName, sizeof(strModName));
    if (StrEqual(strModName, "tf")) return;
    SetFailState("[SM] This plugin is only for Team Fortress 2.");
}

public event_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{    
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
    new iClients[MaxClients+1];
    new iNumClients;
    
    for(new i=1; i<=MaxClients; i++)
    {
        if(IsClientInGame(i) && IsPlayerAlive(i))
        {
            iClients[iNumClients++] = i;
        }
    }
    
    new iRandomClient = iClients[GetRandomInt(0, iNumClients-1)];
    new maxspies = 0;
    
    if (client == iRandomClient)
    {
        TF2_SetPlayerClass(client, TFClass_Spy);
        for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
        TF2_RemoveWeaponSlot(client, iSlot );
        TF2_RemoveWeaponSlot(client, 0);
        TF2_RemoveWeaponSlot(client, 1);
        TF2_RemoveWeaponSlot(client, 3);
        ChangeClientTeam(client, _:TFTeam_Blue);
        TF2Items_GiveWeapon(client, 638);
        TF2Items_GiveWeapon(client, GetConVarInt(sm_spyscreed_itemid)); 
        maxspies +=1;
        if (maxspies == GetConVarInt(sm_spyscreed_maxspies))
        {
            ChangeClientTeam(client, _:TFTeam_Red);
        }
    }
    else
    {
        ChangeClientTeam(client, _:TFTeam_Red);
    }
}

public event_inventory(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    if (GetClientTeam(client) == 3)
    {
        for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
        TF2_RemoveWeaponSlot(client, iSlot );
        TF2_RemoveWeaponSlot(client, 0);
        TF2_RemoveWeaponSlot(client, 1);
        TF2_RemoveWeaponSlot(client, 3);
        TF2Items_GiveWeapon(client, 638); 
        TF2Items_GiveWeapon(client, GetConVarInt(sm_spyscreed_itemid));
    }
}
Thanks.
__________________
My Plugins
Modified Plugins:
Building Spawner
Monster
It's Raining Men!
Tutorials:
Custom Gamemode

I DON'T DO PLUGIN REQUESTS.
Bitl is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-23-2013 , 01:11   Re: [TF2] ED_Alloc: no free edicts
Reply With Quote #2

Lol.. Them for loops. Why are you removing 9 item slots in a loop, and then 3 more after?
http://docs.sourcemod.net/api/index....d=show&id=858&

Dont use giveweapon? It does tonshit of thnings, and is probably not freeing entities properly, who knows. Regardless, there is no reason not to, use tf2 items api directly. This is all the wrong ways to make a plugin
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 10-23-2013 at 01:13.
friagram is offline
Bitl
Senior Member
Join Date: Jul 2012
Old 10-23-2013 , 19:44   Re: [TF2] ED_Alloc: no free edicts
Reply With Quote #3

Quote:
Originally Posted by friagram View Post
Lol.. Them for loops. Why are you removing 9 item slots in a loop, and then 3 more after?
http://docs.sourcemod.net/api/index....d=show&id=858&

Dont use giveweapon? It does tonshit of thnings, and is probably not freeing entities properly, who knows. Regardless, there is no reason not to, use tf2 items api directly. This is all the wrong ways to make a plugin
Thanks.

I use Give Weapon because it is easier to give the weapons to the player. I'll try using the API this time.
__________________
My Plugins
Modified Plugins:
Building Spawner
Monster
It's Raining Men!
Tutorials:
Custom Gamemode

I DON'T DO PLUGIN REQUESTS.
Bitl is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-24-2013 , 03:18   Re: [TF2] ED_Alloc: no free edicts
Reply With Quote #4

do you kniow that programmers are lazy people?
so if some code is repeated somethere more that one - then it's better to use some functions instead.
I mean this part:
Code:
        for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
        TF2_RemoveWeaponSlot(client, iSlot );
        TF2_RemoveWeaponSlot(client, 0); // oh my
        TF2_RemoveWeaponSlot(client, 1); // dude
        TF2_RemoveWeaponSlot(client, 3); // why?
also, what's the point of 'maxspies'?
also2, do you know that ChangeClientTeam will slay player? so giving weapons before or at same frame with ChangeClientTeam is useless.
Leonardo is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-24-2013 , 10:22   Re: [TF2] ED_Alloc: no free edicts
Reply With Quote #5

Quote:
Originally Posted by Leonardo View Post
do you kniow that programmers are lazy people?
so if some code is repeated somethere more that one - then it's better to use some functions instead.
I mean this part:
Code:
        for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
        TF2_RemoveWeaponSlot(client, iSlot );
        TF2_RemoveWeaponSlot(client, 0); // oh my
        TF2_RemoveWeaponSlot(client, 1); // dude
        TF2_RemoveWeaponSlot(client, 3); // why?
also, what's the point of 'maxspies'?
also2, do you know that ChangeClientTeam will slay player? so giving weapons before or at same frame with ChangeClientTeam is useless.
Did u see that new TF2ItemSlot = 8 ?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-24-2013 , 12:13   Re: [TF2] ED_Alloc: no free edicts
Reply With Quote #6

Quote:
Originally Posted by friagram View Post
Did u see that new TF2ItemSlot = 8 ?
so?
this is my vision of ЯEALITY
Leonardo is offline
HKAnson
Member
Join Date: Oct 2011
Location: Hong Kong
Old 04-11-2014 , 08:02   Re: [TF2] ED_Alloc: no free edicts
Reply With Quote #7

That is already a looping code,

TF2_RemoveWeaponSlot(client, 0); // oh my
TF2_RemoveWeaponSlot(client, 1); // dude
TF2_RemoveWeaponSlot(client, 3); // why?
ALREADY DUPLICATED
__________________
HKAnson 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 14:43.


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