Доступ к плагину по флагу l

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
162
Реакции
4
Помог
3 раз(а)
Добрый день! Нужно сделать чтобы доступ к плагину был только по флагу l.На сколько я понял , в строках 91,140,141 был как раз указаны флаги доступа be.Я заменил на le , но доступ к плагину по прежнему есть у всех админов. В чём ошибка?


Код:
/******************************************************************************************************************
*  AMX Mod script.
*
*  Ghost Mode Script
*  Version 1.4
*  by Kiosk3
*  email: [email protected]
*
*  Changes In 1.4
*
*  -Changed how invisibility works, thanks to jedi's plugin, im using transparency instead of normal.
*
*  Changes In 1.3
*
*  -Added On/Off CSAY Messages
*
*  Changes In 1.2
*
*  -Fixed the speed glitch where if you have it on yourself everyone gets it
*
*  Changes In 1.1
* 
*  -Changed on from ghost to amx_ghost
*  -Changed off from unghost to amx_unghost
*  -Fixed godmode, you will not lose godmode untill you hit amx_unghost
*  -Fixed speed, you will not lose speed while switching weapons
*
*  Description:
*
*  This plugin turns your admins into a ghost.
*  What it does is this, records users speed, changes it to 1000,
*  turns on godmode, and makes the person invisible.
*  When you turn it off it reverts to your old speed, ungods and makes you visible.
*  Only admins can use it, and only can use it on themselves.
*  This is great if you want to run around with a knife scaring people, or to watch for hackers
* 
*  Console Commands:
*
*  amx_ghost - This turns it on. (Turns on invisibility, godmode, and speed.)
*  amx_unghost - This turns it off. (Turns off invisibility, godmode, and speed.)
*
*  Future Plans:
* 
*  Keep the amx_ghost | amx_unghost for yourself but add amx_ghost <name> | amx_unghost <name>.
******************************************************************************************************************/


#include <amxmodx>
#include <amxmisc>
#include <fun>

#define BPID 341219
#define MAX_TEXT_LENGTH 512
#define MAX_NAME_LENGTH 32

new Float:oldspeed[33]
new ccolor[33]
new IsGhost[33]
new sName[MAX_NAME_LENGTH]

public changecolor(ids[]) {
new toghost = ids[0]
switch(ccolor[toghost]) {
case 0: {
set_user_rendering(toghost,kRenderFxNone,0,0,0, kRenderTransTexture,0)
ccolor[toghost] = 1
}
case 1: {
set_user_rendering(toghost,kRenderFxNone,0,0,0, kRenderTransTexture,0)
ccolor[toghost] = 2
}
case 2: {
set_user_rendering(toghost,kRenderFxNone,0,0,0, kRenderTransTexture,0)
ccolor[toghost] = 0
}
}
}

public admin_ghost(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new params[3]
params[0] = id
IsGhost[id] = 1
get_user_name(id, sName, 32)
oldspeed[id] = get_user_maxspeed(id)
set_user_maxspeed(id,1000.0)
set_user_godmode(id,1)
set_task(0.2, "changecolor", BPID + id, params, 2, "l")
return PLUGIN_HANDLED
}

public admin_unghost(id, level, cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
IsGhost[id] = 0
get_user_name(id, sName, 32)
set_user_maxspeed(id,oldspeed[id])
set_user_godmode(id,0)
set_user_rendering(id,kRenderFxNone,255,255,255, kRenderNormal,16)
remove_task(BPID + id)
return PLUGIN_HANDLED
}

public switchweapon(id)
{
if(IsGhost[id]) set_user_maxspeed(id,1000.0)
return PLUGIN_CONTINUE
}

public round_start(id)
{
if(IsGhost[id]) set_user_godmode(id,1)
return PLUGIN_CONTINUE
}

public client_connect(id){
IsGhost[id] = 0
return PLUGIN_CONTINUE
}

public client_disconnected(id){
IsGhost[id] = 0
return PLUGIN_CONTINUE
}

public display_msg(msg[],r,g,b)
{
set_hudmessage(r,g,b,-1.0,0.30,0,6.0,6.0,0.5,0.15,1)
show_hudmessage(0,msg)
}

public plugin_init() {
register_plugin("Ghost Mode","1.4","Kiosk3")
register_concmd("amx_ghost","admin_ghost")
register_concmd("amx_unghost","admin_unghost")
register_event("CurWeapon","switchweapon","le")
register_event("ResetHUD", "round_start", "le")
return PLUGIN_CONTINUE
}
 

d3m37r4

111111
Сообщения
1,451
Реакции
1,177
Помог
10 раз(а)
Dmitriy Korolev, где у тебя тут флаги доступа заданы?
 
Сообщения
162
Реакции
4
Помог
3 раз(а)
d3m37r4, Заменить

Код:
register_concmd("amx_ghost","admin_ghost")
register_concmd("amx_unghost","admin_unghost")
на
Код:
register_concmd("amx_ghost","admin_ghost",ADMIN_RCON)
register_concmd("amx_unghost","admin_unghost",ADMIN_RCON)
и всё?
23 Авг 2019
Тоже самое нужно сделать с этим плагином.Заменил ADMIN_FLAG_C на ADMIN_RCON , а плагин всё равно открывается у обычных админов.

Код:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <fakemeta>
#include <cellarray>

#define MAXENTS 1365
#define SAVEPATH "addons/amxmodx/data/entsaves"

new Array:entvars [MAXENTS]
new weaponmode [33]

public plugin_init(){
    register_plugin("Ent Moving","1.7","Ingram")
    
    register_clcmd("+moveent","startmoving",ADMIN_RCON," - Begin moving an ent")
    register_clcmd("+moveentaim","startmoving",ADMIN_RCON," - Begin moving an ent by aiming")
    register_clcmd("+copyent","startmoving",ADMIN_RCON," - Copy an ent and begin moving")
    register_clcmd("+copyentaim","startmoving",ADMIN_RCON," - Copy an ent and begin moving by aiming")
    register_clcmd("-moveent","stopmoving")
    register_clcmd("-moveentaim","stopmoving")
    register_clcmd("-copyent","stopmoving")
    register_clcmd("-copyentaim","stopmoving")
    
    register_clcmd("amx_ent_move","startmoving",ADMIN_RCON," [classname/ent] - For moving mutliple ents or moving by number")
    register_clcmd("amx_ent_moveaim","startmoving",ADMIN_RCON," [classname/ent] - For moving mutliple ents or moving by number by aiming")
    register_clcmd("amx_ent_copy","startmoving",ADMIN_RCON," [classname/ent] - For copying mutliple ents or copying by number")
    register_clcmd("amx_ent_copyaim","startmoving",ADMIN_RCON," [classname/ent] - For copying mutliple ents or copying by number by aiming")
    register_clcmd("amx_ent_stop","stopmoving",ADMIN_RCON," - Stop moving all ents")
    
    register_concmd("amx_ent_remove","removeent",ADMIN_RCON," [classname/ent] - Deletes an ent")
    register_concmd("amx_ent_rotate","rotate",ADMIN_RCON," <x> <y> <z> [classname/ent] - Rotates an ent")
    register_concmd("amx_ent_stack","stack",ADMIN_RCON," <number> <x offset> <y offset> <z offset> [classname/ent]- Make a pile of ents")
    register_concmd("amx_ent_use","forceuse",ADMIN_RCON," [classname/ent] [player] - Forces an ent to be used with you or a player")
    register_concmd("amx_ent_droptofloor","droptofloor",ADMIN_RCON," [classname/ent] - Drops an ent to the floor (has to be near floor)")
    register_concmd("amx_ent_originallocation","originallocation",ADMIN_RCON," [classname/ent] - Returns an ent to its original location")
    register_concmd("amx_ent_render","setrendering",ADMIN_RCON," <mode> <r> <g> <b> <amt> <fx> [classname/ent] - For rendering an ent (-1 to ignore)")
    
    register_clcmd("amx_ent_weaponmode","weapon",ADMIN_RCON," - toggles weapon moving mode on yourself")
    
    register_concmd("amx_ent_createplayer","create",ADMIN_RCON," <name> <classname> - Create an ent on someone")
    register_concmd("amx_ent_createorigin","create",ADMIN_RCON," <y> <z> <x> <classname> - Create an ent at a location")
    register_concmd("amx_ent_createworld","createworld",ADMIN_RCON," <speed> <x> <y> <z> - Create a rotating world")
    register_concmd("amx_ent_removeworld","deleteworlds",ADMIN_RCON," - Removes all rotating worlds")
    
    register_concmd("amx_ent_info","info",ADMIN_RCON," [classname/ent] - Dump entity keys to your console")
    register_concmd("amx_ent_setkey","setvar",ADMIN_RCON," [classname/ent] <key> ^"<value>^" - Set entity variable (Use Quotes)")
    
    register_clcmd("amx_ent_load","loadfile",ADMIN_RCON," <savename> - Loads a saved file")
    register_clcmd("amx_ent_save","savefile",ADMIN_RCON," <savename> - Saves selected ents in file")
    register_clcmd("amx_ent_saveent","saveent",ADMIN_RCON," [classname/ent] - Selects an ent to save")
    
    register_clcmd("amx_ent_noclip","noclip",ADMIN_RCON," - toggles noclip on yourself")
    register_clcmd("amx_ent_godmode","godmode",ADMIN_RCON," - toggles godmode on yourself")
    register_clcmd("amx_ent_solid","solid",ADMIN_RCON," - toggles solid mode on yourself")
    register_clcmd("amx_ent_teleport","teleport",ADMIN_RCON," <x> <y> <z> - teleport yourself to coordinates")
    
    register_forward(FM_UpdateClientData, "UpdateClientData", 1)
}

public pfn_keyvalue(ent){
    new class [1], key [32], value [32], keyvalue [64]
    copy_keyvalue(class,0,key,32,value,32)   
    if (!entvars [ent])
        entvars [ent] = ArrayCreate(64,1)
    format (keyvalue, 64, "%s*%s", key, value)
    ArrayPushString(entvars [ent], keyvalue)
    return PLUGIN_CONTINUE
}

public setKeyValue (ent, key[], value[]){
    new item, keyvalue [64]
    DispatchKeyValue(ent,key,value)
    if (!entvars [ent])
        entvars [ent] = ArrayCreate(64,1)
    format (keyvalue, 64, "%s*%s", key, value)
    if ((item = arrayfindkey (ent, key)) == -1)
        ArrayPushString(entvars [ent], keyvalue)
    else
        ArraySetString(entvars [ent], item, keyvalue)
}

public setKeyValueInt (ent, key[], arg){
    new value [32]
    num_to_str (arg, value, 32)
    setKeyValue (ent, key, value)
}

public setKeyValueFloat (ent, key[], Float:arg){
    new value [32]
    float_to_str (arg, value, 32)
    setKeyValue (ent, key, value)
}

public setKeyValueVector (ent, key[], Float:arg[3]){
    new value [32]
    format (value, 32, "%f %f %f", arg[0], arg[1], arg[2])
    setKeyValue (ent, key, value)
}

public arrayfindkey (ent, tofind []){
    if (!entvars[ent])
        return -1;
    new keyvalue [64], key [32], value [32]
    for (new i=0;i<ArraySize(entvars [ent]);i++){
        ArrayGetString(entvars[ent], i, keyvalue, 64)
        strtok(keyvalue, key, 32, value, 32, '*')
        if (equal(key, tofind))
            return i;
    }
    return -1;
}

public getactualorigin (ent, origin [3]){
    if (ent <= get_maxplayers())
        get_user_origin (ent, origin)
    else{
        new Float:orig [3], Float:mins [3], Float:maxs[3]
        entity_get_vector(ent, EV_VEC_origin, orig)
        entity_get_vector(ent, EV_VEC_mins, mins)
        entity_get_vector(ent, EV_VEC_maxs, maxs)
        for(new i = 0; i < 3; i++)
            origin [i] = floatround((mins[i] + maxs[i]) / 2 + orig [i])
    }
}

public getorigin (ent, origin [3]){
    if (ent <= get_maxplayers())
        get_user_origin (ent, origin)
    else{
        new Float:orig [3]
        entity_get_vector(ent, EV_VEC_origin, orig)
        FVecIVec(orig, origin)
    }
}

public setorigin (ent, origin [3]){
    if (ent <= get_maxplayers())
        set_user_origin (ent, origin)
    else{
        new Float:orig [3]
        IVecFVec(origin, orig)
        entity_set_origin (ent, orig)
    }
}

public getent (id, arg){
    new ent
    if (arg && read_argc() > arg){
        new entarg [64]
        read_argv(arg,entarg,63)
        if (isdigit(entarg [0])){
            ent=str_to_num (entarg)
        }else{
            new ents[1]
            find_sphere_class(id, entarg, 300.0, ents, 1)
            if (!ents[0]){
                console_print (id, "[AMXx] Ent Not Found")
                return 0
              }
            ent=ents[0]
        }
    }
    if (!is_valid_ent(ent)){
        if (!id)
            return 0
        new bodypart
        get_user_aiming (id,ent,bodypart)
        if (!is_valid_ent(ent))
            return 0
    }
    return ent
}

public client_PreThink(id) {
    if (weaponmode [id]){
        new buttons = entity_get_int(id, EV_INT_button)
        if (buttons & IN_ATTACK){
            if (weaponmode [id] == 1)
                client_cmd (id, "amx_ent_moveaim")
            weaponmode [id] = 2
            buttons -= IN_ATTACK
        }else if (weaponmode [id] == 2){
            client_cmd (id, "amx_ent_stop")
            weaponmode [id] = 1
        }
        if (buttons & IN_RELOAD){
            if (weaponmode [id] == 1)
                client_cmd (id, "amx_ent_copyaim")
            weaponmode [id] = 3
            buttons -= IN_RELOAD
        }else if (weaponmode [id] == 3){
            client_cmd (id, "amx_ent_stop")
            weaponmode [id] = 1
        }
        if (buttons & IN_ATTACK2){
            if (weaponmode [id] == 1)
                client_cmd (id, "amx_ent_remove")
            buttons -= IN_ATTACK2
            weaponmode [id] = 4
        }else if (weaponmode [id] == 4){
            weaponmode [id] = 1
        }
        entity_set_int(id, EV_INT_button, buttons)
    }
}

public UpdateClientData(id, weapons, cd_handle){
    if (weaponmode [id])
        set_cd(cd_handle, CD_ID, 0)
    return FMRES_HANDLED
}

public weapon (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
        
    if (weaponmode [id])
        weaponmode [id] = 0
    else
        weaponmode [id] = 1
        
    console_print (id, "[AMXx] Weapon Mode Toggled")
        
    return PLUGIN_HANDLED
}

public create (id,level,cid){
    new cmd [32]
    read_argv(0,cmd,31)
    if (!cmd_access(id,level,cid,(containi (cmd,"origin")==-1)? 3:5))
              return PLUGIN_HANDLED
              
    new arg [32], classname [32], origin[3], ent, player

    if (containi (cmd,"origin")==-1){
        read_argv(1,arg, 32)
        player=cmd_target(id,arg,7)
        if (!player)
            return PLUGIN_HANDLED
        getorigin (player,origin)
        read_argv(2,classname,32)
    }else{
        for (new i=0;i<3;i++){
            read_argv(i+1,arg,32)
            origin[i]=str_to_num (arg)
        }
        read_argv(4,classname,32)
    }
    if (entity_count()>=MAXENTS-15*get_maxplayers()-100){
        client_print (id, print_chat, "[AMXx] Maximum number of ents reached!")
        return PLUGIN_HANDLED
    }

    ent = create_entity(classname)
    setKeyValue (ent, "classname", classname)
    setKeyValueInt (ent, "spawnflags", 1 << 30)
    setorigin(ent, origin)
    DispatchSpawn(ent)
    
    if (containi(cmd,"origin")==-1)
        fake_touch(player, ent)
    
    console_print (id,"[AMXx] Created Ent Number: %i",ent)
    return PLUGIN_HANDLED
}

public startmoving (id,level,cid){
    if (!cmd_access(id,level,cid,1))
              return PLUGIN_HANDLED
            
    new ent=getent (id,1)
    if (!ent)
        return PLUGIN_HANDLED
    
    new cmd[32], dontcolour
    read_argv(0,cmd,31)
    if (containi(cmd,"copy")!=-1 && ent > get_maxplayers()){
        if (arrayfindkey (ent, "entmoving_mover") != -1 || arrayfindkey (ent, "entmoving_saver") != -1)
            dontcolour=1
        ent=copyent (ent,id)
    }
        
    if (ent <= get_maxplayers() && get_user_flags(ent)&ADMIN_IMMUNITY){
        client_print (id, print_chat, "[AMXx] You cannot move a user with immunity.")
        return PLUGIN_HANDLED
    }
    
    if (arrayfindkey (ent, "entmoving_mover") != -1 || arrayfindkey (ent, "entmoving_saving") != -1){
        client_print (id, print_chat, "[AMXx] You cannot move an ent that is already being moved or saved.")
        return PLUGIN_HANDLED
    }

    new keyvalue [64]
    format (keyvalue, 64, "%s*%d", "entmoving_mover", id)
    if (!entvars[ent])
        entvars [ent] = ArrayCreate(64,1)
    ArrayPushString(entvars [ent], keyvalue)
    if (!dontcolour)
        colourent (ent, Float:{255.0, 0.0, 0.0})
    
    new information [5], userorigin [3], entorigin [3]
    information[0]=id
    information[1]=ent
    getorigin (id,userorigin)
    
    if (contain (cmd,"aim")==-1){
        getorigin (ent,entorigin)
        for (new i=0;i<3;i++)
            information [i+2]=entorigin[i]-userorigin [i]
        set_task(0.1,"moveoriginal",435+id,information,5,"b")
    }else{
        getactualorigin (ent,entorigin)
        information[2]=get_distance(userorigin, entorigin)
        set_task (0.1,"moveaim",435+id,information,3,"b")
    }
    return PLUGIN_HANDLED
}

public copyent (ent,id){
    if (entity_count()>=MAXENTS-15*get_maxplayers()-100){
        client_print (id, print_chat, "[AMXx] Maximum number of ents reached!")
        return PLUGIN_HANDLED
    }
    new newent, keyvalue [64], key [32], value [32]
    
    entity_get_string(ent, EV_SZ_classname, value, 32)
    newent = create_entity(value)
    if (!newent)
        return PLUGIN_HANDLED
    
    for (new i=0;i<ArraySize(entvars [ent]);i++){
        ArrayGetString(entvars[ent], i, keyvalue, 64)
        strtok(keyvalue, key, 32, value, 32, '*')
        if (!equal (key, "entmoving_mover") && !equal (key, "entmoving_saver"))
            setKeyValue(newent,key,value)
    }
    DispatchSpawn(newent)
    
    new origin [3]
    getorigin(ent, origin)
    setorigin(newent, origin)

    return newent
}

public moveoriginal (information[5]){
    new origin[3]
    
    if (!is_user_connected(information[0]) || ((information[1] <= get_maxplayers())? !is_user_connected(information[1]):!is_valid_ent(information[1]))){
        stopmoving (information[0])
        return PLUGIN_HANDLED
    }
    
    getorigin(information[0], origin)
    for (new i=0;i<3;i++)
        origin[i]+=information[i+2]
    setorigin(information[1], origin)
    
    return PLUGIN_CONTINUE
}

public moveaim (information [3]){
    new Float:aiming [3], origin[3]
    
    if (!is_user_connected(information[0]) || ((information[1] <= get_maxplayers())? !is_user_connected(information[1]):!is_valid_ent(information[1]))){
        stopmoving (information[0])
        return PLUGIN_HANDLED
    }
    
    get_user_origin(information[0], origin, 3)
    IVecFVec(origin, aiming)
    getorigin (information[0], origin)
    
    for (new i=0;i<3;i++)
        aiming [i] -= float(origin [i])
    for (new i=0;i<3;i++)
        origin [i] += floatround (aiming [i] * (float(information [2])/vector_length(aiming)))
    
    if (information[1]>get_maxplayers()){
        new Float:mins [3], Float:maxs[3]
        entity_get_vector(information[1], EV_VEC_mins, mins)
        entity_get_vector(information[1], EV_VEC_maxs, maxs)
        for(new i = 0; i < 3; i++)
            origin [i] -= floatround ((mins[i] + maxs[i]) / 2)
    }
    setorigin (information[1],origin)
    
    return PLUGIN_CONTINUE
}

public stopmoving (id){
    if (task_exists (435+id))
        remove_task (435+id)
        
    new item, keyvalue [64], key [32], value [32]
    for (new i=0;i<MAXENTS;i++){
        if ((item = arrayfindkey (i, "entmoving_mover")) != -1){
            ArrayGetString(entvars[i], item, keyvalue, 64)
            strtok(keyvalue, key, 32, value, 32, '*')
            if (equal(key, "entmoving_mover") && id == str_to_num(value)) {
                colourent (i, Float:{0.0, 0.0, 0.0})
                ArrayDeleteItem(entvars [i], item)
            }
        }
    }
    return PLUGIN_HANDLED
}

public colourentcopykey (ent, tocopy [32]){
    new item, keyvalue [64], key [32], value [32]
    if ((item = arrayfindkey (ent, tocopy)) != -1){
        ArrayGetString(entvars[ent], item, keyvalue, 64)
        strtok(keyvalue, key, 32, value, 32, '*')
        format (keyvalue, 64, "entmoving_%s*%s", tocopy, value)
        ArrayPushString(entvars [ent], keyvalue)
    }else{
        if (equal (tocopy, "renderamt"))
            format (keyvalue, 64, "entmoving_%s*255", tocopy)
        else if (equal (tocopy, "rendercolor"))
            format (keyvalue, 64, "entmoving_%s*0 0 0", tocopy)
        else
            format (keyvalue, 64, "entmoving_%s*0", tocopy)
        ArrayPushString(entvars [ent], keyvalue)
    }
}

public colourentreverse (ent, reverse [32]){
    new item, keyvalue [64], key [32], value [32]
    format (key, 32, "entmoving_%s", reverse)
    if ((item = arrayfindkey (ent, key)) != -1){
        ArrayGetString(entvars[ent], item, keyvalue, 64)
        strtok(keyvalue, key, 32, value, 32, '*')
        setKeyValue(ent, reverse, value)
        ArrayDeleteItem(entvars [ent], item)
    }
}

public colourent (ent, Float:colours [3]){
    if (colours [0] == 0.0 && colours [1] == 0.0 && colours [2] == 0.0){
        colourentreverse (ent, "rendermode")
        colourentreverse (ent, "renderamt")
        colourentreverse (ent, "rendercolor")
    }else{
        colourentcopykey (ent, "rendermode")
        colourentcopykey (ent, "renderamt")
        colourentcopykey (ent, "rendercolor")
        setKeyValue(ent, "rendermode", "1")
        setKeyValue(ent, "renderamt", "100")
        setKeyValueVector(ent, "rendercolor", colours)
    }
}

public stack(id,level,cid){
    if (!cmd_access(id,level,cid,5))
        return PLUGIN_HANDLED

    new arg[64], ent=getent (id,5)
    if (!ent || ent <= get_maxplayers())
        return PLUGIN_HANDLED

    read_argv(1,arg,63)
    new amount = str_to_num(arg)

    new entorigin [3]
    getorigin(ent, entorigin)
    for(new i=0;i<amount;i++){
        ent=copyent (ent,id)
        for (new j=0;j<3;j++){
            read_argv(j+2,arg,63)
            entorigin[j] += str_to_num(arg)
        }
        setorigin(ent, entorigin)
    }
    return PLUGIN_HANDLED
}


public rotate (id,level,cid){
    if (!cmd_access(id,level,cid,4))
        return PLUGIN_HANDLED

    new arg [32], Float:angles [3], entorigin [3], ent = getent (id, 4)
    if (!ent)
        return PLUGIN_HANDLED
    
    entity_get_vector(ent, EV_VEC_angles, angles)
    for (new i=0;i<3;i++){
        read_argv(i+1,arg,31)
        angles [i] += floatstr (arg)
    }
    
    getorigin(ent, entorigin)
    entity_set_vector(ent, EV_VEC_v_angle, angles)
    entity_set_vector(ent, EV_VEC_angles, angles)
    setorigin(ent, entorigin)
    
    return PLUGIN_HANDLED
}

public originallocation (id,level,cid){
    if (!cmd_access(id,level,cid,1))
              return PLUGIN_HANDLED
          
    new ent = getent (id, 1)
    if (!ent || ent <= get_maxplayers())
        return PLUGIN_HANDLED

    new dimensions [3] = {0, 0, 0}
    setorigin(ent, dimensions)
    
    return PLUGIN_HANDLED
}

public forceuse (id,level,cid){
    if (!cmd_access(id,level,cid,1))
              return PLUGIN_HANDLED

    new ent = getent (id, 1)
    if (!ent)
        return PLUGIN_HANDLED
    
    if (read_argc()>2){
        new arg [32], player
        read_argv(2,arg,31)
        player=cmd_target(id,arg,3)
        if (player)
            force_use(player,ent)
    }else{
        force_use(id,ent)
    }
    
    return PLUGIN_HANDLED
}

public removeent (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
          
    new ent = getent (id, 1)
    if (!ent || ent <= get_maxplayers())
        return PLUGIN_HANDLED
    
    if (entvars [ent])
        ArrayDestroy (entvars [ent])
    remove_entity(ent)
        
    return PLUGIN_HANDLED
}

public droptofloor (id,level,cid){
    if (!cmd_access(id,level,cid,1))
              return PLUGIN_HANDLED
          
    new ent = getent (id, 1)
    if (!ent || ent <= get_maxplayers())
        return PLUGIN_HANDLED
    
    drop_to_floor(ent)
    
    return PLUGIN_HANDLED
}

public setrendering (id,level,cid){
    if (!cmd_access(id,level,cid,7))
        return PLUGIN_HANDLED
        
    new ent = getent (id,7)
    if(!ent)
        return PLUGIN_HANDLED
              
    new arg[32], mode, Float:colours [3], Float:amt, fx
    read_argv(1,arg,32)
    mode = str_to_num(arg)

    for (new i=0;i<3;i++){
        read_argv(i+2,arg,32)
        colours[i] = floatstr(arg)
    }

    read_argv(5,arg,32)
    amt = floatstr(arg)

    read_argv(6,arg,31)
    fx = str_to_num(arg)
    
    if (mode != -1)   
        setKeyValueInt(ent, "rendermode", mode)
    if (colours [0] != -1 && colours [1] != -1 && colours [2] != -1)
        setKeyValueVector(ent, "rendercolor", colours)
    if (amt != -1)
        setKeyValueFloat(ent, "renderamt", amt)
    if (fx != -1)
        setKeyValueInt(ent, "renderfx", fx)

    return PLUGIN_HANDLED
}

public createworld (id,level,cid){
    if (!cmd_access(id,level,cid,4))
              return PLUGIN_HANDLED
          
    new rotatingworld = create_entity("func_rotating")
          
    new arg [64]
    get_mapname(arg,64)
    format (arg, 64, "maps/%s.bsp",arg)
    setKeyValue (rotatingworld, "model", arg)
    read_argv(1,arg,64)
    setKeyValue (rotatingworld, "speed", arg)
    read_args(arg,64)
    copy(arg,64,arg [contain (arg, " ")])
    setKeyValue (rotatingworld, "angles", arg)
          
    setKeyValue (rotatingworld, "spawnflags", "65")
          
    DispatchSpawn(rotatingworld)
          
    return PLUGIN_HANDLED
}

public deleteworlds (id,level,cid){
    if (!cmd_access(id,level,cid,1))
              return PLUGIN_HANDLED

    new ent = -1, model [64]
    get_mapname(model,64)
    format (model, 64, "maps/%s.bsp",model)
    while ((ent = find_ent_by_model(-1, "func_rotating", model)))
        remove_entity(ent)
          
          return PLUGIN_HANDLED
}

public saveent (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
          
    new ent=getent (id,1)
    if (!ent || ent <= get_maxplayers())
        return PLUGIN_HANDLED   
    
    if (arrayfindkey (ent, "entmoving_mover") != -1 || arrayfindkey (ent, "entmoving_saver") != -1){
        client_print (id, print_chat, "[AMXx] You cannot save an ent that is already being moved or saved.")
        return PLUGIN_HANDLED
    }

    new keyvalue [64]
    format (keyvalue, 64, "%s*%d", "entmoving_saver", id)
    if (!entvars[ent])
        entvars [ent] = ArrayCreate(64,1)
    ArrayPushString(entvars [ent], keyvalue)
    colourent (ent, Float:{0.0, 255.0, 0.0})
    
    return PLUGIN_HANDLED
}

public loadfile (id,level,cid){
    if (!cmd_access(id,level,cid,2))
        return PLUGIN_HANDLED
        
    new arg [32], file [128]
    read_argv(1,arg,32)
    get_mapname(file, 32)
    format(file,128,"%s/%s-%s.txt", SAVEPATH, file, arg)
    if (!file_exists(file)){
        console_print (id, "[AMXx] That savename does not exist.")
        return PLUGIN_HANDLED
    }
    
    new txtlen, text [64], line
    while ((line=read_file(file,line,text,64,txtlen)))
        if (equal (text, "-----"))
            loadents (file, line, id)
    
    return PLUGIN_HANDLED
}

public savefile (id,level,cid){
    if (!cmd_access(id,level,cid,2))
          return PLUGIN_HANDLED
        
    if (!dir_exists(SAVEPATH))
        mkdir(SAVEPATH)
        
    new arg [32], file [128]
    read_argv(1,arg,32)
    get_mapname(file, 32)
    format(file,128,"%s/%s-%s.txt", SAVEPATH, file, arg)
    if (file_exists(file)){
        console_print (id, "[AMXx] That savename already exists.")
        return PLUGIN_HANDLED
    }
    
    new item, keyvalue [64], key [32], value [32]
    for (new i=0;i<MAXENTS;i++){
        if ((item = arrayfindkey (i, "entmoving_saver")) != -1){
            ArrayGetString(entvars[i], item, keyvalue, 64)
            strtok(keyvalue, key, 32, value, 32, '*')
            if (equal(key, "entmoving_saver") && id == str_to_num(value)) {
                colourent (i, Float:{0.0, 0.0, 0.0})
                ArrayDeleteItem(entvars [i], item)
                saveents (i, file)
            }
        }
    }
    
    return PLUGIN_HANDLED
}

public saveents (ent, file [128]){
    write_file(file,"-----")
    new keyvalue [64]
    entity_get_string(ent, EV_SZ_classname, keyvalue, 64)
    format (keyvalue, 64, "classname*%s", keyvalue)
    for (new i=0;i<ArraySize(entvars [ent]);i++){
        ArrayGetString(entvars[ent], i, keyvalue, 64)
        write_file(file,keyvalue)
    }
    new origin [3]
    getorigin(ent, origin)
    format(keyvalue, 64, "origin*%d %d %d", origin [0], origin [1], origin [2])
    write_file(file,keyvalue)
}

public loadents (file [128],line, id){
    new keyvalue [64], txtlen, ent, key [32], value [32]
    while ((line=read_file(file,line,keyvalue,64,txtlen))){
        if (equal (keyvalue, "-----"))
            break
        if (entity_count()>=MAXENTS-15*get_maxplayers()-100){
            client_print (id, print_chat, "[AMXx] Maximum number of ents reached!")
            return PLUGIN_HANDLED
        }
        strtok(keyvalue, key, 32, value, 32, '*')
        console_print (id, "key: %s, value:%s",key,value)
        if (equal (key, "classname")){
            ent = create_entity(value)
            if (!ent)
                return PLUGIN_HANDLED
            console_print (id, "classname")
        }
        setKeyValue(ent,key,value)
    }
    DispatchSpawn(ent)
    line--
    return PLUGIN_CONTINUE
}

public client_disconnected (id){
    new item, keyvalue [64], key [32], value [32]
    for (new i=0;i<MAXENTS;i++){
        if ((item = arrayfindkey (i, "entmoving_saver")) != -1){
            ArrayGetString(entvars[i], item, keyvalue, 64)
            strtok(keyvalue, key, 32, value, 32, '*')
            if (equal(key, "entmoving_saver") && id == str_to_num(value)) {
                colourent (i, Float:{0.0, 0.0, 0.0})
                ArrayDeleteItem(entvars [i], item)
            }
        }
    }
}

public info (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED

    new ent = getent (id, 1)
    if (!ent || ent <= get_maxplayers())
        return PLUGIN_HANDLED

    new key [32], value [32], keyvalue [64]

    console_print (id, "*** Entity Keys for Ent #%i ***",ent)
    
    for (new i=0;i<ArraySize(entvars [ent]);i++){
        ArrayGetString(entvars[ent], i, keyvalue, 64)
        strtok(keyvalue, key, 32, value, 32, '*')
        if (!equal (key, "entmoving_", 10))
            console_print (id, "%s: ^"%s^"",key,value)
    }
        
    new origin [3]
    getactualorigin (ent, origin)
    console_print (id, "origin: ^"%d %d %d^"",origin[0],origin[1],origin[2])
    
    return PLUGIN_HANDLED
}

public setvar (id,level,cid){
    if (!cmd_access(id,level,cid,3))
        return PLUGIN_HANDLED
          
    new ent, arg [32], key [32], argsadd
    if (read_argc() == 4){
        ent = getent (id, 1)
        argsadd++
    }else
        ent = getent (id, 0)
    
    if (!ent)
        return PLUGIN_HANDLED
        
    read_argv(1+argsadd,key,31)
    read_argv(2+argsadd,arg,31)
    setKeyValue (ent,key,arg)
    
    console_print (id, "[AMXx] Key Set")
          
    return PLUGIN_HANDLED
}

public noclip (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
        
    if (get_user_noclip(id))
        set_user_noclip(id)
    else
        set_user_noclip(id, 1)
    
    new name[32], authid[32]
    get_user_name(id,name,31)
    get_user_authid(id, authid, 31)
    log_amx("[Noclip] ^"%s<%s>^" has toggled noclip",name,authid)
    console_print(id,"[AMXx] Noclip Toggled")
    
    return PLUGIN_HANDLED
}

public godmode (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
        
    if (get_user_godmode(id))
        set_user_godmode(id)
    else
        set_user_godmode(id, 1)
    
    new name[32], authid[32]
    get_user_name(id,name,31)
    get_user_authid(id, authid, 31)
    log_amx("[Godmode] ^"%s<%s>^" has toggled godmode",name,authid)
    console_print(id,"[AMXx] Godmode Toggled")
    
    return PLUGIN_HANDLED
}

public solid (id,level,cid){
    if (!cmd_access(id,level,cid,1))
        return PLUGIN_HANDLED
    
    if (!entity_get_int(id, EV_INT_solid))
        setKeyValue(id,"solid","3")
    else
        setKeyValue(id,"solid","0")
        
    new name[32], authid[32]
    get_user_name(id,name,31)
    get_user_authid(id, authid, 31)
    log_amx("[Solid] ^"%s<%s>^" has toggled solid",name,authid)
    console_print(id,"[AMXx] Solid Toggled")
    
    return PLUGIN_HANDLED
}

public teleport (id,level,cid){
    if (!cmd_access(id,level,cid,4))
        return PLUGIN_HANDLED
    
    new arg [32], coordinates [3]
    for (new i=0;i<3;i++){
        read_argv(i+1,arg,32)
        coordinates [i] = str_to_num (arg)
    }
    set_user_origin (id, coordinates)
    
    new name[32], authid[32]
    get_user_name(id,name,31)
    get_user_authid(id, authid, 31)
    log_amx("[Teleport] ^"%s<%s>^" has teleport to ^"%i %i %i^"",name,authid,coordinates [0], coordinates [1], coordinates [2])
    console_print(id,"[AMXx] Teleported")
    
    return PLUGIN_HANDLED
}
 

d3m37r4

111111
Сообщения
1,451
Реакции
1,177
Помог
10 раз(а)
Dmitriy Korolev, используй get_user_flags за место стока cmd_access. Примеров проверки флага на открытие меню/использование команды можно подсмотреть в любой випке.
 
Сообщения
333
Реакции
290
Помог
9 раз(а)
Заменил ADMIN_FLAG_C на ADMIN_RCON , а плагин всё равно открывается у обычных админов.
Команды, зарегистрированные с параметром "flags" прописываются в файле cmdaccess.ini. В дальнейшем, при использовании стока "cmd_access" используется флаг из этого файла. Замена флага в исходнике в функции регистрации команды ничего не даст, пока не удалите строку из файла, созданную ранее.
 

d3m37r4

111111
Сообщения
1,451
Реакции
1,177
Помог
10 раз(а)
Dmitriy Korolev,
Код:
#include <amxmodx>

const ACCESS_FLAG = ADMIN_BAN;

public plugin_init() {
    register_clcmd("amx_cmd", "CmdMenu", ACCESS_FLAG);
}

public CmdMenu(id, flags) {
    if(~get_user_flags(id) & flags) {
        console_print(id, "* Недостаточно прав для использования данной команды!");
        return PLUGIN_HANDLED;
    }

    // other code

    return PLUGIN_HANDLED;
}
 
Сообщения
162
Реакции
4
Помог
3 раз(а)
d3m37r4, рано или поздно у вас будет проблема , которую Вы будете не в силе решить. И когда Вас пошлют разбираться с незнакомыми Вам словами , я бы посмотрел на Ваше выражение лица :)
 
Сообщения
2,143
Реакции
1,225
Помог
44 раз(а)
Dmitriy Korolev, ты тогда сюда зачем пришел? Чтобы разбираться? Так дерзай. Предоставили кучу информации в кратком виде, которую, как оказывается (да ладно?!), можно найти через поисковик в полном объеме. За тебя делать никто не станет. Так что, "лет го" разбираться с предоставленной информацией по-полной.
 

d3m37r4

111111
Сообщения
1,451
Реакции
1,177
Помог
10 раз(а)
d3m37r4, рано или поздно у вас будет проблема , которую Вы будете не в силе решить. И когда Вас пошлют разбираться с незнакомыми Вам словами , я бы посмотрел на Ваше выражение лица :)
Ежедневно возникают такие ситуации, не в сфере павноскриптинга, так в другой. Наше с тобой отличие в том, что я не жду, когда за меня сделают, и тем более не высказываю недовольства после того, как оказали помощь, какой бы она ни была.
К тому же, по твоему вопросу, как уже было сказано выше, примеров тьма тьмущая, в каждом втором плагине, нужно было лишь пару лишних кликов мышкой сделать на том же форуме.
 
Сообщения
162
Реакции
4
Помог
3 раз(а)
d3m37r4, я не спорю и тем более не высказываю никаких недовольств. Информации о том как лечить ту или иную болезнь тоже полно в интернете , однако , я думаю Вы пользуетесь услугами врача. Я думаю моя логика теперь понятна.
25 Авг 2019
d3m37r4, я не спорю и тем более не высказываю никаких недовольств. Информации о том как лечить ту или иную болезнь тоже полно в интернете , однако , я думаю Вы пользуетесь услугами врача. Я думаю моя логика теперь понятна.
з.ы Не с тобой , а с вами ;)
 

d3m37r4

111111
Сообщения
1,451
Реакции
1,177
Помог
10 раз(а)
Dmitriy Korolev, сравнивать вещи разных значимостей - такое себе. Сомневаюсь, что от проверки флагов, зависит чья то жизнь.:scratch_one-s_head:
 
Сообщения
162
Реакции
4
Помог
3 раз(а)
Dmitriy Korolev, сравнивать вещи разных значимостей - такое себе. Сомневаюсь, что от проверки флагов, зависит чья то жизнь.:scratch_one-s_head:
Я так понимаю , что смысла пояснять просто нет. Удачи!
25 Авг 2019
Dmitriy Korolev, ты тогда сюда зачем пришел? Чтобы разбираться? Так дерзай. Предоставили кучу информации в кратком виде, которую, как оказывается (да ладно?!), можно найти через поисковик в полном объеме. За тебя делать никто не станет. Так что, "лет го" разбираться с предоставленной информацией по-полной.
Я пришел за помощью , а не за разборками. Если бы я хотел разобраться , то назвал тему по другому .
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу