fix @gstorage permission

apuadofrancisco

New member
Messages
67
Points
0
Location
Philippines
Github
apuadofrancisco
Emulator
Hi Guys,

I added the code in red text. everything is working well.

Updated. currently working on mine. please give a try and tell me if somethings wrong.

Database:

you need to change your datatype of mode to smallint in in your guild_position table
image.png

message.conf

//1202 FREE - You do not have permission to use the guild storage.
1202: You do not have permission to use the guild storage.
mmo.h

enum guild_permission { // Guild permissions
    GPERM_INVITE = 0x01,
    GPERM_EXPEL = 0x10,
    GPERM_STORAGE = 0x100,
    GPERM_ALL = GPERM_INVITE | GPERM_EXPEL | GPERM_STORAGE,
    GPERM_MASK = GPERM_ALL,
};


storage.h

 * Acceptable values for map_session_data.state.storage_flag
 */
enum storage_flag {
    STORAGE_FLAG_CLOSED = 0, // Closed
    STORAGE_FLAG_NORMAL = 1, // Normal Storage open
    STORAGE_FLAG_GUILD  = 2, // Guild Storage open
    STORAGE_FLAG_NOPERMISSION = 3, //Gstorage no permission
atcommand.c

ACMD(guildstorage)
{

    int i;

    struct guild* g;
    g = sd->guild;


    if (!sd->status.guild_id) {
        clif->message(fd, msg_fd(fd,252)); // You are not in a guild.
        return false;
    }

    if (sd->npc_id || sd->state.vending || sd->state.prevend || sd->state.buyingstore || sd->state.trading)
        return false;

    if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
        clif->message(fd, msg_fd(fd,250)); // You have already opened your storage. Close it first.
        return false;
    }

    if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
        clif->message(fd, msg_fd(fd,251)); // You have already opened your guild storage. Close it first.
        return false;
    }

    if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 1)) { // mapflag nogstorage already defined? can't open :c
        clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage. (there is no other messages...)
        return false;
    }

  if ((i = guild->getposition(g, sd)) < 0 || !(g->position.mode & GPERM_STORAGE)) {
        clif->message(fd, msg_fd(fd, 1202)); // You do not have permission to use the guild storage.
        return false;
    }


    if( gstorage->open(sd) ) {
        clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
        return false;
    }

  
    clif->message(fd, msg_fd(fd,920)); // Guild storage opened.
    return true;
}
 

 

 

 
Last edited by a moderator:
Oh nvm, i already figured it out..

I updated this in my atcommand.c
 

ACMD(guildstorage)
{
    if (!sd->status.guild_id) {
        clif->message(fd, msg_fd(fd,252)); // You are not in a guild.
        return false;
    }

    if (sd->npc_id || sd->state.vending || sd->state.prevend || sd->state.buyingstore || sd->state.trading)
        return false;

    if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
        clif->message(fd, msg_fd(fd,250)); // You have already opened your storage. Close it first.
        return false;
    }

    if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
        clif->message(fd, msg_fd(fd,251)); // You have already opened your guild storage. Close it first.
        return false;
    }

    if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 1)) { // mapflag nogstorage already defined? can't open :c
        clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage. (there is no other messages...)
        return false;
    }

    if( gstorage->open(sd)) {
        if(sd->state.storage_flag != STORAGE_FLAG_NOPERMISSION)
            clif->message(fd, msg_fd(fd, 1202)); // You do not have permission to use the guild storage.
        else
            clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
        return false;
    }


    clif->message(fd, msg_fd(fd,920)); // Guild storage opened.
    return true;
}

 
Good night, could you help me with Gstorage? Your guild's storage has already been opened by another member
what happen? just do everything on my first commend but use atcommand.c to my 2nd comment. be sure to change this lines...
 

 if( gstorage->open(sd) ) {
        clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
        return false;
    }

    if (sd->state.storage_flag == STORAGE_FLAG_NOPERMISSION) {
        clif->message(fd, msg_fd(fd, 1202)); // You do not have permission to use the guild storage.
        return false;
    }
to this one...

   if( gstorage->open(sd)) {
        if(sd->state.storage_flag != STORAGE_FLAG_NOPERMISSION)
            clif->message(fd, msg_fd(fd, 1202)); // You do not have permission to use the guild storage.
        else
            clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
        return false;
    }

 
Last edited by a moderator:
enum guild_permission { // Guild permissions
    GPERM_INVITE = 0x01,
    GPERM_EXPEL = 0x10,
    GPERM_ALL = GPERM_INVITE | GPERM_EXPEL | GPERM_STORAGE,
    GPERM_ALL = GPERM_INVITE|GPERM_EXPEL,
    GPERM_MASK = GPERM_ALL,
};
mmo.h

if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 1)) { // mapflag nogstorage already defined? can't open :c
        clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage. (there is no other messages...)
        return false;
    }
    
    if( gstorage->open(sd)) {
        if(sd->state.storage_flag != STORAGE_FLAG_NOPERMISSION)
            clif->message(fd, msg_fd(fd, 1202)); // You do not have permission to use the guild storage.
        else
            clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
        return false;
    }

    clif->message(fd, msg_fd(fd,920)); // Guild storage opened.
    return true;
}
atcommand.c

struct guild_storage *gstor;
    int i;
    struct guild* g;
    g = sd->guild;

    nullpo_ret(sd);

    if(sd->status.guild_id <= 0)
        return 2;

    if (sd->state.storage_flag != STORAGE_FLAG_CLOSED)
        return 1; //Can't open both storages at a time.
    
    if ((i = guild->getposition(g, sd)) < 0 || !(g->position.mode & GPERM_STORAGE))
        return 3; //Guild member doesn't have permission
storage.c

storage.c when will compile the error position.mode, set "->" use in mode

 * Acceptable values for map_session_data.state.storage_flag
 */
enum storage_flag {
    STORAGE_FLAG_CLOSED = 0, // Closed
    STORAGE_FLAG_NORMAL = 1, // Normal Storage open
    STORAGE_FLAG_GUILD  = 2, // Guild Storage open
    STORAGE_FLAG_NOPERMISSION = 3, //Gstorage no permission
storage.h

 
Last edited by a moderator:
error C2231: '.mode': left operand points to 'struct', use '->'

struct guild_storage *gstor;
    int i;
    struct guild* g;
    g = sd->guild;

    nullpo_ret(sd);

    if(sd->status.guild_id <= 0)
        return 2;

    if (sd->state.storage_flag != STORAGE_FLAG_CLOSED)
        return 1; //Can't open both storages at a time.
    
    if ((i = guild->getposition(g, sd)) < 0 || !(g->position.mode & GPERM_STORAGE))
        return 3; //Guild member doesn't have permission

 
Last edited by a moderator:
im not sure about the patch but i just edit my current copy.  just follow my very first commment/post and its good to go. also you need to change your datatype to smallint in in your guild_position table
image.png

 
Back
Top