View Single Post
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 02-20-2020 , 07:22   Re: Super Admin slash replace "/" to "/c"
Reply With Quote #5

not tested

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define VERBOSE
#define MAX_NAME_LENGTH 32
#define MAX_TEXT_LENGTH 80
#define MAX_PLAYERS 32
new PLUGIN[] = "Super Admin Slash"

new sMessage[MAX_TEXT_LENGTH], Array:repeatStorage, Array:repeatIDsrepeaters[MAX_PLAYERS+1]

enum {
    
GET_TEAM_TARGET_ISNOBODY,
    
GET_TEAM_TARGET_ISALL,
    
GET_TEAM_TARGET_ISTEAMCT,
    
GET_TEAM_TARGET_ISTERRORIST
}

enum {
    
GET_TEAM_TARGET_SKIPNOBODY,
    
GET_TEAM_TARGET_SKIPBOTS,
    
GET_TEAM_TARGET_SKIPDEADPEOPLE
}

stock tokenlen(string[]){
    for(new 
istrlen(string)+1i++){
        if(
string[i] < 33) return i
    
}
    return 
0
}

stock get_team_target(arg[],players[32],&pnum,skipMode=GET_TEAM_TARGET_SKIPNOBODY){
    
//Modular Tea    m Targeting code by Sid 6.7
    
new whoTeam
    
new cmdflags[4]
    switch(
skipMode){
        case 
GET_TEAM_TARGET_SKIPBOTScmdflags "ce"
        
case GET_TEAM_TARGET_SKIPNOBODYcmdflags "e"
        
case GET_TEAM_TARGET_SKIPDEADPEOPLEcmdflags "ae"
    
}
    if(
equali(arg[1],"ALL",tokenlen(arg[1])))     {
        switch(
skipMode){
            case 
GET_TEAM_TARGET_SKIPBOTScmdflags "c"
            
case GET_TEAM_TARGET_SKIPNOBODYcmdflags ""
            
case GET_TEAM_TARGET_SKIPDEADPEOPLEcmdflags "a"
        
}
        
whoTeam GET_TEAM_TARGET_ISALL
        get_players
(players,pnum,cmdflags)
    }
        
    if(
equali(arg[1],"TERRORIST",tokenlen(arg[1]))) {
        
whoTeam GET_TEAM_TARGET_ISTERRORIST
        get_players
(players,pnum,cmdflags,"TERRORIST")
    }
    if(
equali(arg[1],"CT",2)    || equali(arg[1],"C",1)) {
        
whoTeam GET_TEAM_TARGET_ISTEAMCT
        get_players
(players,pnum,cmdflags,"CT")
    }
    return 
whoTeam
}

public 
admin_slash(id){
    if(!
is_user_admin(id)) return PLUGIN_CONTINUE
    
new sArg[MAX_NAME_LENGTH]    
    
read_argv(1,sArg,charsmax(sArg))
    
    
// Check for '/' char
    
if ( sArg[0] == '/' && sArg[1] == 'c'){
        
read_args(sMessage,charsmax(sMessage))
        
remove_quotes(sMessage)
        
replace(sMessage,charsmax(sMessage),"/c","")
        
process(id,sMessage)        
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

process(id,line[sizeof sMessage]){
    if(
equal(line,"")){
        new 
menu menu_create("Wipe Repeaters","imh")
        
menu_additem(menu,"Wipe All","wipe0")
        new 
pnump[32], n[24], c[32]
        
get_players(p,pnum,"c")
        for(new 
ipnumi++){
            
get_user_name(p[i],n,charsmax(n))
            
formatex(c,charsmax(c),"[%d] %s",repeaters[p[i]],n)
            
formatex(n,6,"wipe%d",p[i])
            
menu_additem(menu,c,n)
        }
        
menu_display(id,menu)
        return
    }
    new 
contain(line,"@")
    if(
!= -&& !isalnum(line[a+1])) intellimenu(id,line)
    else {
        
//check for @Xall @XT @XCT, these are manual controls for commands not supporting @ symbol
        
new line2[sizeof line]
        
copy(line2,charsmax(line2),line)
        if(
line[0] == 'R') {
            
replace(line2,charsmax(line2),"R","")
            
addrepeater(id,line2)
            
client_print(id,print_chat,"[%s] Command set for repeat on new rounds",PLUGIN)
            return
        }
        
contain(line,"@X")
        if(
== -1client_cmd(id,"amx_%s",line)
        else {
            new 
teammates[32], pnum
            
//start cycling thru targets
            
client_print(id,print_chat,"[%s] Emulation called for @%s",PLUGIN,line[a+2])
            
replace(line2,charsmax(line2),"@X","@")
            if(
get_team_target(line2[a],teammates,pnum) == GET_TEAM_TARGET_ISNOBODY)
                
client_print(id,print_chat,"[%s] No clients on team",PLUGIN)
            else {
                new 
r[16], j[2]
                
strtok(line2[a],r,charsmax(r),j,1)
                
replace(line2,charsmax(line2),r,"#%d")
                
#if defined VERBOSE
                
server_print(line2,12345)
                
#endif
            
}
            new 
line3[sizeof line]
            for(new 
ipnumi++){
                
formatex(line3,charsmax(line3),line2,get_user_userid(teammates[i]))
                
#if defined VERBOSE
                
server_print(line3)
                
#endif
                
client_cmd(id,"amx_%s",line3)
            }
        }
    }
}

intellimenu(id,const line[sizeof sMessage]){
    new 
players[32], pnumcommandlabel[48], gumstick[sizeof line], userid[8]
    
get_players(players,pnum)
    new 
menu menu_create("AMXX Super Slash Users Menu","imh")
    new 
targets[][] = {"@ALL","@CT","@T"}
    if(
cstrike_running()){
        if(
line[0] == 'R'){
            
copy(gumstick,charsmax(gumstick),line[1])
            
commandlabel "Repeat\R\yON"
        
} else {
            
formatex(gumstick,charsmax(gumstick),"R%s",line)
            
commandlabel "Repeat\R\dOFF"
        
}
        
menu_additem(menu,commandlabel,gumstick)
        for(new 
isizeof targetsi++){
            
copy(gumstick,charsmax(gumstick),line)
            
replace(gumstick,charsmax(gumstick),"@",targets[i])
            
menu_additem(menu,targets[i],gumstick)
        }
    }
    
menu_addblank(menu,0)
    for(new 
ipnumi++){
        
copy(gumstick,charsmax(gumstick),line)
        
formatex(userid,charsmax(userid),"#%d",get_user_userid(players[i]))
        
replace(gumstick,charsmax(gumstick),"@",userid)
        
get_user_name(players[i],commandlabel,charsmax(commandlabel))
        if(
cstrike_running()) 
            if(
get_user_flags(players[i]) & ADMIN_IMMUNITYstrcat(commandlabel,"\R\yIMMUNITY",charsmax(commandlabel))
        
menu_additem(menu,commandlabel,gumstick)
    }
    
menu_addblank(menu,0)
    new 
Xtargets[][] = {"@XALL","@XCT","@XT"}
    for(new 
icstrike_running() ? sizeof Xtargets 1i++){
        
copy(gumstick,charsmax(gumstick),line)
        
replace(gumstick,charsmax(gumstick),"@",Xtargets[i])
        
menu_additem(menu,Xtargets[i],gumstick)
    }
    
menu_display(id,menu)            
}

public 
imh(idmenuitem){
    if(
item <= MENU_EXIT) {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
abubblegum[MAX_TEXT_LENGTH], name[32]
    
menu_item_getinfo(menuitemabubblegumcharsmax(bubblegum),name,sizeof(name)-1a)
    
menu_destroy(menu)
    if(
equal(bubblegum,"wipe",4)) wiperepeaters(str_to_num(bubblegum[4]))
    else 
process(id,bubblegum)
    return 
PLUGIN_HANDLED
}

public 
plugin_init(){
    
register_plugin(PLUGIN,"2008","mike_cao & Sid 6.7")
    
register_clcmd("say","admin_slash",0,"say /command < params >")
    if(
cstrike_running()) register_logevent("logevent_round_start"2"1=Round_Start")
    
repeatStorage ArrayCreate(MAX_TEXT_LENGTH)
    
repeatIDs ArrayCreate()
}

public 
logevent_round_start(){
    for(new 
iArraySize(repeatIDs); i++){
        
ArrayGetString(repeatStorage,i,sMessage,charsmax(sMessage))
        
process(ArrayGetCell(repeatIDs,i),sMessage)
    }
}

addrepeater(idr[]){
    
ArrayPushCell(repeatIDs,id)
    
ArrayPushString(repeatStorage,r)
    
repeaters[id]++
}

//id 0 = all
wiperepeaters(id){
    for(new 
iArraySize(repeatIDs); i++){
        if(!
id || ArrayGetCell(repeatIDs,i) == id){
            
repeaters[ArrayGetCell(repeatIDs,i)]--
            
ArrayDeleteItem(repeatIDs,i)
            
ArrayDeleteItem(repeatStorage,i)
            
i--
        }
    }
}

public 
client_disconnect(id){
    
wiperepeaters(id)

__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh