Raised This Month: $ Target: $400
 0% 

Need help with plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asdfdsdf
AlliedModders Donor
Join Date: Aug 2010
Location: Belgium
Old 06-03-2013 , 14:21   Need help with plugin
Reply With Quote #1

Hello guys i need help with this plugin the cellsopener for jailbreak now its only once per map when you type !open i need to fix so admins can use it every round can someoen help me or what do i have to change n this code thx grtz

PHP Code:
/*

Thread Link: https://forums.alliedmods.net/showthread.php?p=1130946#post1130946

Jail Cells Opener
v1.6
Wrecked

Changelog:

1.0 - Released
1.1 - Config file added with method to get custom maps / button ids
1.2 - Replaced button ID with targetname since ID's aren't static (thanks xPaw and joropito for feedback)
1.3 - Auto button detector added in with a big thanks to jorpito for the code!
1.4 - Now functions with maps that have more than one cell opener.
1.5 - Manual push task removal, thanks to D.Skript for reporting
1.6 - Multilingual added (crazyeffect) / commented the code
*/

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
//#include <cstrike>
//#include <fun>

new const VERSION[] = "1.6"

new found[10]

public 
plugin_init()
{
    
register_plugin"Auto Cells Opener"VERSION"Wrecked" )
    
    
register_clcmd"say !open""CMD_PushButton"ADMIN_LEVEL_E )
}

public 
CMD_PushButtonidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED
    
}
    
    else
    {
        new 
name[32]
        
get_user_nameidname31 )
        
        
client_print0print_chat"%s has released the prisoners!"name )
        
        
Push_Button() // open cells
    
}
    
    return 
PLUGIN_HANDLED
}

public 
Push_Button() 

        new 
ent 
        
new ent3 
        
new Float:origin[3
        new 
Float:radius 200.0 
        
new class[32
        new 
name[32]
        new 
pos 
        
while((pos <= sizeof(found)) && (ent engfunc(EngFunc_FindEntityByStringent"classname""info_player_deathmatch"))) // info_player_deathmatch = tspawn
        

                new 
ent2 
                pev
(entpev_originorigin
                while((
ent2 engfunc(EngFunc_FindEntityInSphereent2originradius)))  // find doors near T spawn
                

                        if(!
pev_valid(ent2)) 
                                continue 

                        
pev(ent2pev_classname, class, charsmax(class)) 
                        if(!
equal(class, "func_door")) // if it's not a door, move on to the next iteration
                                
continue 

                        
pev(ent2pev_targetnamenamecharsmax(name)) 
                        
ent3 engfunc(EngFunc_FindEntityByString0"target"name// find button that opens this door
                        
if(pev_valid(ent3) && (in_array(ent3foundsizeof(found)) < 0)) 
                        { 
                                
ExecuteHamB(Ham_Useent30011.0// zomg poosh it
                                
found[pos] = ent3 
                                pos
++ // next
                                
break // break from current while loop
                        

                } 
        } 
        return 
pos 


stock in_array(needledata[], size

        for(new 
0sizei++) 
        { 
                if(
data[i] == needle
                        return 

        

        return -


asdfdsdf is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-03-2013 , 14:52   Re: Need help with plugin
Reply With Quote #2

try this
Code:
/* 

Thread Link: https://forums.alliedmods.net/showthread.php?p=1130946#post1130946 

Jail Cells Opener 
v1.6 
Wrecked 

Changelog: 

1.0 - Released 
1.1 - Config file added with method to get custom maps / button ids 
1.2 - Replaced button ID with targetname since ID's aren't static (thanks xPaw and joropito for feedback) 
1.3 - Auto button detector added in with a big thanks to jorpito for the code! 
1.4 - Now functions with maps that have more than one cell opener. 
1.5 - Manual push task removal, thanks to D.Skript for reporting 
1.6 - Multilingual added (crazyeffect) / commented the code 
*/ 

#include <amxmodx> 
#include <amxmisc> 
#include <hamsandwich> 
#include <fakemeta> 
//#include <cstrike> 
//#include <fun> 

new const VERSION[] = "1.6" 

new found[10] 

public plugin_init() 
{ 
    register_plugin( "Auto Cells Opener", VERSION, "Wrecked" ) 
     
    register_clcmd( "say !open", "CMD_PushButton", ADMIN_LEVEL_E ) 
	
	register_event( "HLTV", "OnRoundStart" "a", "1=0", "2=0" );
} 

publoc OnRoundStart( )
	Push_Button( ); // Reset doors

public CMD_PushButton( id, level, cid ) 
{ 
    if( !cmd_access( id, level, cid, 1 ) ) 
    { 
        return PLUGIN_HANDLED 
    } 
     
    else 
    { 
        new name[32] 
        get_user_name( id, name, 31 ) 
         
        client_print( 0, print_chat, "%s has released the prisoners!", name ) 
         
        Push_Button() // open cells 
    } 
     
    return PLUGIN_HANDLED 
} 

public Push_Button()  
{  
        new ent = 1  
        new ent3  
        new Float:origin[3]  
        new Float:radius = 200.0  
        new class[32]  
        new name[32] 
        new pos  
        while((pos <= sizeof(found)) && (ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "info_player_deathmatch"))) // info_player_deathmatch = tspawn 
        {  
                new ent2 = 1  
                pev(ent, pev_origin, origin)  
                while((ent2 = engfunc(EngFunc_FindEntityInSphere, ent2, origin, radius)))  // find doors near T spawn 
                {  
                        if(!pev_valid(ent2))  
                                continue  

                        pev(ent2, pev_classname, class, charsmax(class))  
                        if(!equal(class, "func_door")) // if it's not a door, move on to the next iteration 
                                continue  

                        pev(ent2, pev_targetname, name, charsmax(name))  
                        ent3 = engfunc(EngFunc_FindEntityByString, 0, "target", name) // find button that opens this door 
                        if(pev_valid(ent3) && (in_array(ent3, found, sizeof(found)) < 0))  
                        {  
                                ExecuteHamB(Ham_Use, ent3, 0, 0, 1, 1.0) // zomg poosh it 
                                found[pos] = ent3  
                                pos++ // next 
                                break // break from current while loop 
                        }  
                }  
        }  
        return pos  
}  

stock in_array(needle, data[], size)  
{  
        for(new i = 0; i < size; i++)  
        {  
                if(data[i] == needle)  
                        return i  
        }  
        return -1  
}
TheDS1337 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-03-2013 , 15:27   Re: Need help with plugin
Reply With Quote #3

Ripped from jbextreme, try this :

Spoiler
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 06-03-2013 at 15:33.
ConnorMcLeod is offline
asdfdsdf
AlliedModders Donor
Join Date: Aug 2010
Location: Belgium
Old 06-03-2013 , 16:39   Re: Need help with plugin
Reply With Quote #4

Ok wil ltest it thx for the replys Grtz
asdfdsdf is offline
Cheezpuff
BANNED
Join Date: Oct 2012
Location: City of the Dead
Old 06-03-2013 , 18:46   Re: Need help with plugin
Reply With Quote #5

Code:
/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < fakemeta >

new const plugin_info[ 3 ][ ] = 
{
    "Open & Close Cells",
    "v0.1",
    "+ColdWar"
}


public plugin_init() {
    register_plugin( plugin_info[ 0 ] , plugin_info[ 1 ] , plugin_info[ 2 ] )
    
    register_clcmd( "say /close", "CmdCloseCells" );
    register_clcmd( "say !close", "CmdCloseCells" );
    
    register_clcmd( "say /open", "CmdOpenCells" );
    register_clcmd( "say !open", "CmdOpenCells" );
}

public CmdOpenCells( client )
{
    if( ( get_user_team( client ) != 2 || !is_user_alive( client ) ) && !( get_user_flags( client ) & ADMIN_KICK ) )
        return 1;
        
    new szName[ 32 ];
    get_user_name( client, szName, sizeof szName - 1 );
    client_print( 0, 3, "%s has opened the cells!", szName );
    
    new ent = -1

    while( (ent = engfunc( EngFunc_FindEntityByString, ent, "classname", "func_door" ) ) )
        dllfunc( DLLFunc_Use, ent, 0 );
        
    ent = -1
    
    while( ( ent = engfunc( EngFunc_FindEntityByString, ent, "classname", "func_door_rotating" ) ) )
        dllfunc( DLLFunc_Use, ent, 0 );
    
    return 0;
}

public CmdCloseCells( client )
{
    if( ( get_user_team( client ) != 2 || !is_user_alive( client ) ) && !( get_user_flags( client ) & ADMIN_KICK ) )
        return 1;
    
    new szName[ 32 ];
    get_user_name( client, szName, sizeof szName - 1 );
    client_print( 0, 3, "%s has closed the cells!", szName );
    
    new ent = -1

    while( (ent = engfunc( EngFunc_FindEntityByString, ent, "classname", "func_door" ) ) )
        dllfunc( DLLFunc_Think, ent, 0 );
        
    ent = -1
    
    while( ( ent = engfunc( EngFunc_FindEntityByString, ent, "classname", "func_door_rotating" ) ) )
        dllfunc( DLLFunc_Think, ent, 0 );
    return 0;
}
with close cells and open
and admin_kick access

Last edited by Cheezpuff; 06-03-2013 at 18:46.
Cheezpuff is offline
Send a message via Skype™ to Cheezpuff
asdfdsdf
AlliedModders Donor
Join Date: Aug 2010
Location: Belgium
Old 06-04-2013 , 15:02   Re: Need help with plugin
Reply With Quote #6

Thx ConnorMcLeod it works perfect
asdfdsdf 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:25.


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