AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to restrict weapons without server crashes? (https://forums.alliedmods.net/showthread.php?t=187207)

neverminde 06-10-2012 07:29

How to restrict weapons without server crashes?
 
Hi,
I want restrict
PHP Code:

weapon_sg550
weapon_g3sg1 

but restmenu.amxx crashes server

I also write this small plugin, but it crashes server too :oops:
PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin"PLUGIN""VERSION""AUTHOR" )
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
}

public 
Event_CurWeapon(id)
{
    if(!
is_user_alive(id) || !is_user_connected(id)) 
        return 
PLUGIN_CONTINUE
        
    
new temp[2], weapon get_user_weapon(idtemp[0], temp[1])
    if( (
weapon == CSW_G3SG1) || (weapon == CSW_SG550) )
    {
        
engclient_cmd(id"drop""weapon_sg550")
        
engclient_cmd(id"drop""weapon_g3sg1")
    }
    return 
PLUGIN_CONTINUE


For restricting shield I use noshield.amxx plugin by ConnorMcLeod
http://forums.alliedmods.net/showthread.php?p=1308465
It works perfectly and server works stable with it

Can anybody tell me how rewrite noshield.sma for my case ?

tcPane 06-10-2012 07:47

Re: How to restrict weapons without server crashes?
 
PHP Code:

#include <amxmodx> 

public plugin_init() 

    
register_plugin"PLUGIN""VERSION""AUTHOR" 
    
register_event("CurWeapon""Event_CurWeapon""be""1=1"


public 
Event_CurWeapon(id

    if(!
is_user_alive(id) || !is_user_connected(id))  
        return 
PLUGIN_CONTINUE 
         
    
new temp[2], weapon get_user_weapon(idtemp[0], temp[1]) 
    if( (
weapon == CSW_G3SG1) || (weapon == CSW_SG550) ) 
    { 
        
engclient_cmd(id"drop"
    } 
    return 
PLUGIN_CONTINUE 


try that

hleV 06-10-2012 10:15

Re: How to restrict weapons without server crashes?
 
restmenu.amxx doesn't crash the server unless you fucked something up.

claudiuhks 06-10-2012 10:26

Re: How to restrict weapons without server crashes?
 
You could do it hooking CreateNamedEntity
So, you have to write an extension!

PHP Code:

edict_t *CreateNamedEntityint iClassName )
{
  
RETURN_META( !strcmpSTRINGiClassName ), "weapon_g3sg1" ) ? MRES_SUPERCEDE MRES_IGNORED );


@hleV, I don't think you are impressing using your trivial language.


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

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