Jump to content
  • 0
Sign in to follow this  
cumbe11

Add @joinguild <idguild>

Question

Hello, I really wanted to add a command to my server, basically the player could use @joinguild <idguild> and he would join the guild without needing an invitation

I did something similar to this but it doesn't work.
 

script.ccp


/*==========================================
 * @joinguild <guild_id> 
 *------------------------------------------*/
ACMD_FUNC(joinguild)
{
    std::shared_ptr<MapGuild> g; // Usar std::shared_ptr<MapGuild>
    int guild_id;
    nullpo_retr(-1, sd);

    if (!message || !*message || sscanf(message, "%d", &guild_id) != 1) {
        clif_displaymessage(fd, "Error. (usage: @joinguild <guild_id>).");
        return -1;
    }

    // Procurar pela guilda usando o ID
    g = guild_search(guild_id); // Usar a função correta para procurar pela guilda
    if (!g) { // Verificar se a guilda foi encontrada
        clif_displaymessage(fd, "Guild not found.");
        return -1;
    }

    // Verificar se o jogador já está em uma guilda
    if (sd->status.guild_id > 0) {
        clif_displaymessage(fd, "You are already in a guild.");
        return -1;
    }

    // Adicionar o jogador à guilda usando o sistema de convite
    sd->guild_invite = guild_id;
    sd->guild_invite_account = sd->status.account_id; // Definindo o account_id do próprio jogador

    if (guild_reply_invite(sd, guild_id, 1) == 1) { // Verificar se a função foi bem-sucedida
        clif_displaymessage(fd, "You have successfully joined the guild.");
        return 0; // Sucesso
    } else {
        clif_displaymessage(fd, "Failed to join the guild.");
        return -1; // Falha
    }
}

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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