AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Door Options (https://forums.alliedmods.net/showthread.php?t=204044)

Mrki_Drakula 12-27-2012 00:29

[HELP] Door Options
 
Alright, I've searched and searched alot and tried coding myself, but I just couldn't find a right solution for my problem.

I need a code that opens closed jailbreak cells, close open ones, and same for all the doors.

This is my idea:

MENU:
- Open/Close Cells
- Open/Close Doors

How should I accomplish this?

simanovich 12-27-2012 03:18

Re: [HELP] Door Options
 
All doors have only 1 class, not possible to open only cells, Possible to open all doors

Mrki_Drakula 12-27-2012 03:38

Re: [HELP] Door Options
 
Wrong, you are able to check for the door class, and open only the one that fills your needs. Already done that.

Anyone?

simanovich 12-27-2012 03:43

Re: [HELP] Door Options
 
Quote:

Originally Posted by Mrki_Drakula (Post 1861085)
Wrong, you are able to check for the door class, and open only the one that fills your needs. Already done that.

Anyone?

You Wrong!!!

It's possible to open all doors, but not a specific door(s), in this case, cells.
All doors have only 1 class

Mrki_Drakula 12-27-2012 03:52

Re: [HELP] Door Options
 
Quote:

You Wrong!!!

It's possible to open all doors, but not a specific door(s), in this case, cells.
All doors have only 1 class
Aint you able to filter doors that are near TT spawn place, which means they are cells, then open them?

ironskillz1 12-27-2012 04:36

Re: [HELP] Door Options
 
Here you go :)

only admins and ct can write /open

Code:

#include <amxmodx>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "Open Cells"
#define VERSION "0.0.1"
#define AUTHOR "Freestyle"

#define PREFIX "Jailbreak"

public plugin_init
() {
   
register_plugin(PLUGIN, VERSION, AUTHOR
)
   
   
register_clcmd("say /open", "open_cells"
)
}

public
open_cells(id
)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT
)
    {
        new
szGuardName[32
]
       
get_user_name(id, szGuardName, charsmax(szGuardName
))
       
       
set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -1.0, 0, 6.0, 12.0
)
       
show_hudmessage(0, "[%s]^n= Guard %s open the cells =", PREFIX, szGuardName
)
       
        while(
engfunc(EngFunc_FindEntityByString, -1, "classname", "func_door"
))
        {
           
dllfunc(DLLFunc_Use, -1, 0
)
        }
    }
    else if(
get_user_flags(id) & ADMIN_BAN
)
    {
        new
szGuardName[32
]
       
get_user_name(id, szGuardName, charsmax(szGuardName
))
       
       
set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -1.0, 0, 6.0, 12.0
)
       
show_hudmessage(0, "[%s]^n= Admin %s open the cells =", PREFIX, szGuardName
)
       
        while(
engfunc(EngFunc_FindEntityByString, -1, "classname", "func_door"
))
        {
           
dllfunc(DLLFunc_Use, -1, 0
)
        }
    }
}



simanovich 12-27-2012 04:56

Re: [HELP] Door Options
 
Quote:

Originally Posted by ironskillz1 (Post 1861106)
Here you go :)

only admins and ct can write /open

Code:

#include <amxmodx>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "Open Cells"
#define VERSION "0.0.1"
#define AUTHOR "Freestyle"

#define PREFIX "Jailbreak"

public plugin_init
() {
   
register_plugin(PLUGIN, VERSION, AUTHOR
)
   
   
register_clcmd("say /open", "open_cells"
)
}

public
open_cells(id
)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT
)
    {
        new
szGuardName[32
]
       
get_user_name(id, szGuardName, charsmax(szGuardName
))
       
       
set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -1.0, 0, 6.0, 12.0
)
       
show_hudmessage(0, "[%s]^n= Guard %s open the cells =", PREFIX, szGuardName
)
       
        while(
engfunc(EngFunc_FindEntityByString, -1, "classname", "func_door"
))
        {
           
dllfunc(DLLFunc_Use, -1, 0
)
        }
    }
    else if(
get_user_flags(id) & ADMIN_BAN
)
    {
        new
szGuardName[32
]
       
get_user_name(id, szGuardName, charsmax(szGuardName
))
       
       
set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -1.0, 0, 6.0, 12.0
)
       
show_hudmessage(0, "[%s]^n= Admin %s open the cells =", PREFIX, szGuardName
)
       
        while(
engfunc(EngFunc_FindEntityByString, -1, "classname", "func_door"
))
        {
           
dllfunc(DLLFunc_Use, -1, 0
)
        }
    }
}



Better code:
PHP Code:

#include <amxmodx>
#include <fakemeta> 

#define PREFIX "Jailbreak"

enum _:Teams{
    
FM_TEAM_UNASSIGNED,
    
FM_TEAM_T,
    
FM_TEAM_CT,
    
FM_TEAM_SPECTATOR
};

public 
plugin_init(){
    
register_plugin("Open Cells","0.0.1","Freestyle");
    
register_clcmd("say /open","open_cells");
}

public 
open_cells(id){
    if(
is_user_can(id))
    {
        new 
szGuardName[32];
        
get_user_name(id,szGuardName,charsmax(szGuardName));
        
        
set_hudmessage(random_num(0,255),random_num(0,255),random_num(0,255),-1.0,-1.0,0,6.0,12.0);
        
show_hudmessage(0,"[%s]^n= %s %s open the cells =",PREFIX,is_user_admin(id) ? "Admin":"Guard",szGuardName);
        
        while(
engfunc(EngFunc_FindEntityByString, -1"classname""func_door"))
            
dllfunc(DLLFunc_Use, -10);
    }


stock bool:is_user_can(index){
    if(
is_user_admin(index))
        return 
true;

    if(!
is_user_alive(index) || fm_get_user_team(index) != FM_TEAM_CT)
    {
        
client_print(index,print_chat,"[AMXX] You must be guard and alive!");
        return 
false;
    }

    return 
true;
}

stock bool:is_user_admin(index)
    return 
get_user_flags(index) & ADMIN_ADMIN true:false;

stock fm_get_user_team(index)
    return 
get_pdata_int(index,114); 


AngeIII 12-27-2012 11:33

Re: [HELP] Door Options
 
simanovich I don't agree that your code is better, you added three stocks, so when player using say /open
PHP Code:

call open_cells(id)
COMPARE+BRANCH
new szGuardName[32]
call get_user_name
call set_hudmessage
call show_hudmessage
call 
while
        { 
          
call dllfunc(DLLFunc_Use, -10)
        }
COMPARE+BRANCH
new szGuardName[32]
call get_user_name
call set_hudmessage
call  show_hudmessage
call 
while
        { 
          
call dllfunc(DLLFunc_Use, -10)
        }
end

2 compares in each 4 call, 1 loop, one variable, each teration call.

in your case:

PHP Code:

call open_cells(id)
call +compare+branch (is_user_can(id)
    
call+compare+branch is_user_admin
        call
+compare+branch get_user_flags
    call
+compare+branch is_user_alivefm_get_user_team
        call get_pdata_int
new szGuardName
call get_user_name
call set_hudmessage
call show_hudmessage
call 
while
    
call dllfunc 

more call, more compares..more efficient

fl0werD 12-27-2012 11:44

Re: [HELP] Door Options
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    
register_plugin("Open Cells""0.0.1""Freestyle")
    
register_clcmd("say /open""ClCmdOpenCells")
}

public 
ClCmdOpenCells(pPlayer)
{
    new 
iState;

    if(
get_pdata_int(pPlayer114) == 2)
        
iState 0;
    else if(
get_user_flags(pPlayer) & ADMIN_BAN)
        
iState 1;
    else
        return;

    new 
szName[32];
    
get_user_name(pPlayerszNamecharsmax(szName))

    
set_hudmessage(random_num(1255), random_num(1255), random_num(1255), -1.0, -1.006.012.0)
    
show_hudmessage(0"[Jailbreak]^n= %s %s open the cells ="iState == "Guard" "Admin"szName)

    while(
engfunc(EngFunc_FindEntityByString, -1"classname""func_door")) dllfunc(DLLFunc_Use, -10)


And so?

AngeIII 12-27-2012 11:58

Re: [HELP] Door Options
 
PHP Code:

public ClCmdOpenCells(pPlayer)
{
    if(
get_pdata_int(pPlayer114) == 2)
    {
        new 
szName[32];
        
get_user_name(pPlayerszNamecharsmax(szName))
        
set_hudmessage(random_num(1255), random_num(1255), random_num(1255), -1.0, -1.006.012.0)
        
show_hudmessage(0"[Jailbreak]^n= guard %s open the cells ="szName)
        while(
engfunc(EngFunc_FindEntityByString, -1"classname""func_door")) dllfunc(DLLFunc_Use, -10)
    }
    else if(
get_user_flags(pPlayer) & ADMIN_BAN)
    {
        new 
szName[32];
        
get_user_name(pPlayerszNamecharsmax(szName))
        
set_hudmessage(random_num(1255), random_num(1255), random_num(1255), -1.0, -1.006.012.0)
        
show_hudmessage(0"[Jailbreak]^n= admin %s open the cells ="szName)
        while(
engfunc(EngFunc_FindEntityByString, -1"classname""func_door")) dllfunc(DLLFunc_Use, -10)
    }


Only two compares, only one new variable.


All times are GMT -4. The time now is 13:44.

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