Jump to content
  • 0
apuadofrancisco

fix @gstorage permission

Question

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.842f1d39442880350687e5e92ff5a107.png

 

message.conf

Spoiler

//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

Spoiler

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

Spoiler

 * 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

Spoiler

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;
}

 

 

 

Edited by apuadofrancisco
update details

Share this post


Link to post
Share on other sites

13 answers to this question

Recommended Posts

  • 1

Oh nvm, i already figured it out..

I updated this in my atcommand.c
 

Spoiler

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;
}

 

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, rennison said:

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...
 

Quote

 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...

Quote

   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;
    }

 

Edited by apuadofrancisco

Share this post


Link to post
Share on other sites
  • 0
Quote


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

 

Quote

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

 

Quote

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

 

Quote

 * 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

Edited by rennison

Share this post


Link to post
Share on other sites
  • 0

your mmo.h. is missing something and try again

Quote

GPERM_STORAGE = 0x100,

also you have 2 
GPERM_ALL in your mmo.h

Edited by apuadofrancisco

Share this post


Link to post
Share on other sites
  • 0

error C2231: '.mode': left operand points to 'struct', use '->'

 

Quote

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

 

Edited by rennison

Share this post


Link to post
Share on other sites
  • 0

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.ffce7d6b0715023b7785cfe5170f43d1.png

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.