Raised This Month: $51 Target: $400
 12% 

Solved Overflow because of a respawn plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vov
Junior Member
Join Date: Nov 2016
Old 07-11-2018 , 07:47   Overflow because of a respawn plugin
Reply With Quote #1

I am still learning coding, so I built this monstrosity out of a few plugins to make terrorists always respawn and never have any weapons. It works, but the problem is that after a round ends, I get an overflow error. Is there anyone out there willing to help me optimize this plugin? Thank you all in advance.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <amxmisc>
#include <fun>
 
#define RESPAWN_DELAY 2.0
#define TEAM_T 1
 
public plugin_init()
{
        
register_plugin("CT Respawn""1.2""hleV")
        
register_clcmd("say /respawn""PlayerCmdRespawn")
        
RegisterHam(Ham_Killed"player""PlayerKilled"1)
        
register_event("CurWeapon","knife","b","1=1")
}
 
public 
PlayerKilled(id)
{
        if(
is_user_alive(id))
                return 
HAM_IGNORED
 
        
if(get_user_team(id) == TEAM_T)
                
set_task(RESPAWN_DELAY"PlayerRespawn"id)
 
        return 
HAM_IGNORED
}
 
public 
PlayerCmdRespawn(id)
{
        if(
get_user_team(id) == TEAM_T)
                
set_task(RESPAWN_DELAY"PlayerRespawn"id)
        else
                
client_print(idprint_chat"Only Terrorists.")
 
        return 
PLUGIN_HANDLED
}
 
public 
PlayerRespawn(id)
{
        if(!
is_user_alive(id))
                
ExecuteHamB(Ham_CS_RoundRespawnid)  
}

public  
knife(id)
{
    if(
get_user_team(id) == TEAM_T){
        new 
wpID read_data(2)
        if(
wpID != CSW_KNIFE)
        {
            
strip_user_weapons(id)
            
give_item(id"weapon_knife")
            
engclient_cmd(id"weapon_knife")
        }
    }


Last edited by vov; 07-11-2018 at 12:35.
vov is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-11-2018 , 09:34   Re: Overflow because of a respawn plugin
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <amxmisc>
#include <cstrike>
#include <fun>
 
#define RESPAWN_DELAY 2.0
#define TEAM_T 1

new bool:HasC4[33]

public 
plugin_init()
{
        
register_plugin("CT Respawn""1.2""hleV")
        
register_clcmd("say /respawn""PlayerCmdRespawn")
        
RegisterHam(Ham_Killed"player""PlayerKilled"1)
}
 
public 
PlayerKilled(id)
{
        if(
is_user_alive(id))
                return 
HAM_IGNORED
 
        
if(get_user_team(id) == TEAM_T)
                
set_task(RESPAWN_DELAY"PlayerRespawn"id)
 
        return 
HAM_IGNORED
}
 
public 
PlayerCmdRespawn(id)
{
        if(
get_user_team(id) == TEAM_T)
                
set_task(RESPAWN_DELAY"PlayerRespawn"id)
        else
                
client_print(idprint_chat"Only Terrorists.")
 
        return 
PLUGIN_HANDLED
}
 
public 
PlayerRespawn(id)
{
    if(!
is_user_alive(id))
    {
        
ExecuteHamB(Ham_CS_RoundRespawnid)
        
set_task(0.5"knife, id")
    }
}

public 
knife(id)
{
    if (
user_has_weapon(idCSW_C4))
        
HasC4[id] = true
    
else
        
HasC4[id] = false
            
    strip_user_weapons
(id)
    
give_item(id"weapon_knife")
    
engclient_cmd(id"weapon_knife")
        
    if(
HasC4[id])
    {
        
give_item(id"weapon_c4")
        
cs_set_user_plantid )
    }
}

public 
client_putinserver(id)
    
HasC4[id] = false 
Not tested.

Last edited by iceeedr; 07-11-2018 at 10:08.
iceeedr is offline
Send a message via Skype™ to iceeedr
vov
Junior Member
Join Date: Nov 2016
Old 07-11-2018 , 09:47   Re: Overflow because of a respawn plugin
Reply With Quote #3

Quote:
Originally Posted by iceeedr View Post
Not tested.
Thank you for your a try.
Sadly, I get a bad load and the plugin doesn't even start.
vov is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-11-2018 , 09:51   Re: Overflow because of a respawn plugin
Reply With Quote #4

There's makes no sense..I tested now and loads normal
iceeedr is offline
Send a message via Skype™ to iceeedr
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-11-2018 , 10:03   Re: Overflow because of a respawn plugin
Reply With Quote #5

set_task(0.5, "knife") >> set_task(0.5, "knife", id)

The first plugin that you have made seems to be fine, did you disabled the plugin and test if server crash?
Do not make sense
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-11-2018 at 10:03.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
vov
Junior Member
Join Date: Nov 2016
Old 07-11-2018 , 10:04   Re: Overflow because of a respawn plugin
Reply With Quote #6

Quote:
Originally Posted by iceeedr View Post
There's makes no sense..I tested now and loads normal
Strange. I wonder what I could've done wrong then. I noticed that most plugins that include <cstrike> don't load properly, could it be because of podbots? I'll try some testing. Thanks.

Quote:
Originally Posted by ^SmileY View Post
set_task(0.5, "knife") >> set_task(0.5, "knife", id)

The first plugin that you have made seems to be fine, did you disabled the plugin and test if server crash?
Do not make sense
I disabled the plugin, everything works fine then. The cause of the crash is that plugin.
I get this error:

Last edited by vov; 07-11-2018 at 10:11.
vov is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-11-2018 , 10:10   Re: Overflow because of a respawn plugin
Reply With Quote #7

Quote:
Originally Posted by vov View Post
Strange. I wonder what I could've done wrong then. I noticed that most plugins that include <cstrike> don't load properly, could it be because of podbots? I'll try some testing. Thanks.
Test again, I made the change pointed out by the smiley.
iceeedr is offline
Send a message via Skype™ to iceeedr
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-11-2018 , 10:14   Re: Overflow because of a respawn plugin
Reply With Quote #8

Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
{
	register_plugin("Respawn Test","0.1","SmileY");
	
	register_clcmd("say respawn","HamKilled");
	
	RegisterHam(Ham_Killed,"player","HamKilled",true,true);
	RegisterHam(Ham_AddPlayerItem,"player","HamAddPlayerItem",true,true);
}

public HamKilled(id)
{
	if(cs_get_user_team(id) == CS_TEAM_T)
	{
		set_task(0.75,"Respawn",id);
	}
}

public Respawn(id)
{
	if(is_user_connected(id))
	{
		if(!is_user_alive(id))
		{
			ExecuteHamB(Ham_CS_RoundRespawn,id);
		}
	}
}

public HamAddPlayerItem(id,Ent)
{
	if(cs_get_user_team(id) == CS_TEAM_T)
	{
		if(cs_get_weapon_id(Ent) != CSW_KNIFE)
		{
			set_pev(Ent,pev_flags,FL_KILLME);
			SetHamReturnInteger(0);
			
			return HAM_SUPERCEDE;
		}
	}
	
	return HAM_IGNORED;
}
Code for AMXX 1.8.3, but i still have sure that is caused by mixed plugin between amxx versions.
Did you use same compiler that amxx you have installed in server?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-11-2018 at 10:30.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
vov
Junior Member
Join Date: Nov 2016
Old 07-11-2018 , 10:19   Re: Overflow because of a respawn plugin
Reply With Quote #9

I tested it with no other custom plugins and no podbots and I get this:


Quote:
Originally Posted by ^SmileY View Post
Code for AMXX 1.8.3, but i still have sure that is caused by mixed plugin between amxx versions.
Did you use same compiler that amxx you have installed in server?
I am not sure. I installed the full setup from the official website which created both the server and the compilers for me at once.

Your code doesn't even compile for me...


I must have installed the wrong setup or something, not sure why I'm getting these errors.

Last edited by vov; 07-11-2018 at 10:21.
vov is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-11-2018 , 10:24   Re: Overflow because of a respawn plugin
Reply With Quote #10

Now code is for amxx 1.8.2


Try it
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-11-2018 at 10:30. Reason: Try it
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 11:40.


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