attack cells to open/close
I want the door to open/close when I shoot
But with this plugin that I have, you can only open/close all doors with the "say /open" command
Someone has a code to open the door by firing or hitting?
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> // dumb access command... #include <hamsandwich> #include <fakemeta> #include <cstrike> #include <fun>
new const VERSION[] = "1.6"
new bool:b_Freeday
new found[10]
public plugin_init() { register_plugin( "Auto Cells Opener", VERSION, "Wrecked" ) // :avast: register_concmd( "say /open", "Push_Button" ) register_event( "HLTV", "EVENT_NewRound", "a", "1=0", "2=0" ) register_dictionary("autocellopener.txt") // zomg crazyeffect hawt
RegisterHam( Ham_Use, "func_button", "HAM_Button_Pushed", 1 ) }
public HAM_Button_Pushed( iButton ) // someone pushed a button, so see if it's the button used to open cells { new targ[32] pev( iButton, pev_target, targ, 31 ) // get name of what the button affects new target = engfunc( EngFunc_FindEntityByString, 0, "targetname", targ ) // get ent that is affected if( !pev_valid( target ) ) return; new classname[32] pev( target, pev_classname, classname, 31 ) // func_door, func_button, worldspawn, etc. if( equal( classname, "func_door" ) ) // if button pushed opened a door { Push_Button() } }
public Push_Button() { new ent = 1 new ent3 new Float:origin[3] new Float:radius = 200.0 new class[32] new name[32] while( 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)) < 1)) { ExecuteHamB(Ham_Use, ent3, 0, 0, 1, 1.0) // zomg poosh it break // break from current while loop } } } }
stock in_array(needle, data[], size) { for(new i = 0; i < size; i++) { if(data[i] == needle) return i } return -1 }
|