AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Overflow because of a respawn plugin (https://forums.alliedmods.net/showthread.php?t=309034)

vov 07-11-2018 07:47

Overflow because of a respawn plugin
 
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")
        }
    }



iceeedr 07-11-2018 09:34

Re: Overflow because of a respawn plugin
 
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.

vov 07-11-2018 09:47

Re: Overflow because of a respawn plugin
 
Quote:

Originally Posted by iceeedr (Post 2602924)
Not tested.

Thank you for your a try.
Sadly, I get a bad load and the plugin doesn't even start. :cry:

iceeedr 07-11-2018 09:51

Re: Overflow because of a respawn plugin
 
There's makes no sense..I tested now and loads normal

^SmileY 07-11-2018 10:03

Re: Overflow because of a respawn plugin
 
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

vov 07-11-2018 10:04

Re: Overflow because of a respawn plugin
 
Quote:

Originally Posted by iceeedr (Post 2602932)
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 (Post 2602935)
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:
https://i.imgur.com/h9Yzees.png

iceeedr 07-11-2018 10:10

Re: Overflow because of a respawn plugin
 
Quote:

Originally Posted by vov (Post 2602936)
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.

^SmileY 07-11-2018 10:14

Re: Overflow because of a respawn plugin
 
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?

vov 07-11-2018 10:19

Re: Overflow because of a respawn plugin
 
I tested it with no other custom plugins and no podbots and I get this:
https://i.imgur.com/GXp2SX4.png

Quote:

Originally Posted by ^SmileY (Post 2602941)
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... :(
https://i.imgur.com/MQGbPQu.png

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

^SmileY 07-11-2018 10:24

Re: Overflow because of a respawn plugin
 
Now code is for amxx 1.8.2


Try it


All times are GMT -4. The time now is 18:48.

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