Jump to content
  • 0
Synel

BG_JOIN script modification

Question

Edit: Missed a type. My fault. 

 

So, I tried to modify the BG_JOIN script to function without the map teleport. When I compile I get a undeclared identifier error for a variable that's still used in the original script which is literally right above the code I made. It's probably a noob question but yeah, please help. 

BUILDIN_FUNC(bg_join) {
    const char* map_name;
    struct map_session_data *sd;
    int x, y, mapindex, bg_id = script_getnum(st, 2);
    std::shared_ptr<s_battleground_data> bg = util::umap_find(bg_team_db, bg_id);

    if (!bg) {
        script_pushint(st, false);
        return SCRIPT_CMD_SUCCESS;
    }
    if (script_hasdata(st, 3)) {
        map_name = script_getstr(st, 3);
        if ((mapindex = mapindex_name2id(map_name)) == 0) {
            script_pushint(st, false);
            return SCRIPT_CMD_SUCCESS; // Invalid Map
        }
        x = script_getnum(st, 4);
        y = script_getnum(st, 5);
    } else {
        mapindex = bg->cemetery.map;
        x = bg->cemetery.x;
        y = bg->cemetery.y;
    }

    if (!script_charid2sd(6, sd)) {
        script_pushint(st, false);
        return SCRIPT_CMD_FAILURE;
    }

    if (bg_team_join(bg_id, sd, false) && pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) == SETPOS_OK)
    {
        script_pushint(st, true);
    }
    else
        script_pushint(st, false);

    return SCRIPT_CMD_SUCCESS;
}
//Synel, custom
BUILDIN_FUNC(bg_joinsimple) 
{
    struct map_session_data *sd;
    bg_id = script_getnum(st, 2);
    std::shared_ptr<s_battleground_data> bg = util::umap_find(bg_team_db, bg_id);

    if (!bg) {
        script_pushint(st, false);
        return SCRIPT_CMD_SUCCESS;
    }

    if (!script_charid2sd(3, sd)) {
        script_pushint(st, false);
        return SCRIPT_CMD_FAILURE;
    }

    if (bg_team_join(bg_id, sd, false))
    {
        script_pushint(st, true);
    }
    else
        script_pushint(st, false);

    return SCRIPT_CMD_SUCCESS;
}

 

Edited by Synel
Link to comment
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.   Paste as plain text instead

  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.



×
×
  • Create New...

Important Information

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