Jump to content
  • 0

problem with script.cpp


Question

Posted

 

Hello everyone again! Today I bring a little problem that has been bothering me ... It happens that I have been implementing this code, but when compiling I miss the error C2664 that consists of this 'bool script_rid2sd_(script_state *,map_session_data **,const char *)': argument 2 can not be converted from 'script_state **' to 'map_session_data **'

I will attach the code here, thank you very much for all your help

BUILDIN_FUNC(flooritem)
{
    struct map_session_data *sd = script_rid2sd(st);
    struct item_data *item_data;
    int nameid, amount;

    if( sd == NULL ) return 0;

    nameid = script_getnum(st,2);
    if( (item_data = itemdb_search(nameid)) == NULL )
        return 0;

    amount = script_getnum(st,3);
    if( amount <= 0 )
        return 0;

    map_addflooritem_area(&sd->bl, 0, 0, 0, nameid, amount);
    return 0;
}

9 answers to this question

Recommended Posts

  • 0
Posted (edited)
     struct map_session_data *sd = script_rid2sd(st); 

should be this

     struct map_session_data *sd;
     script_rid2sd(sd);

Generally you can't just copy and paste code from other emulators, it won't work.

Edited by nitrous
  • Like 1
  • 0
Posted
On 6/22/2018 at 9:15 AM, xSoul said:

BUILDIN_FUNC(flooritem)
{
    struct map_session_data *sd = script_rid2sd(st);
    struct item_data *item_data;
    int nameid, amount;

    if( sd == NULL ) return 0;

    nameid = script_getnum(st,2);
    if( (item_data = itemdb_search(nameid)) == NULL )
        return 0;

    amount = script_getnum(st,3);
    if( amount <= 0 )
        return 0;

    map_addflooritem_area(&sd->bl, 0, 0, 0, nameid, amount);
    return 0;
}

where should i put this? i am using 2018 

  • 0
Posted (edited)
BUILDIN_FUNC(flooritem)
{
	short mx, my;
	struct item item_tmp;
	int nameid, amount, i;
	struct map_session_data *sd;
	struct item_data *item_data;

	if (script_rid2sd(sd) == NULL)
		return SCRIPT_CMD_SUCCESS;

	nameid = script_getnum(st, 2);

	if ((item_data = itemdb_search(nameid)) == NULL)
		return SCRIPT_CMD_SUCCESS;

	amount = script_getnum(st, 3);

	if (amount <= 0)
		return SCRIPT_CMD_SUCCESS;

	memset(&item_tmp, 0, sizeof(item_tmp));
	item_tmp.nameid = nameid;
	item_tmp.identify = 1;

	for (i = 0; i < amount; i++)
	{
		map_search_freecell(&sd->bl, 0, &mx, &my, -1, -1, 0);
		map_addflooritem(&item_tmp, 1, sd->bl.m, mx, my, 0, 0, 0, 0, 0);
	}

	return SCRIPT_CMD_SUCCESS;
}

 

Edited by Functor
  • 0
Posted
On 9/9/2018 at 4:46 AM, Functor said:

BUILDIN_FUNC(flooritem) { short mx, my; struct item item_tmp; int nameid, amount, i; struct map_session_data *sd; struct item_data *item_data; if (script_rid2sd(sd) == NULL) return SCRIPT_CMD_SUCCESS; nameid = script_getnum(st, 2); if ((item_data = itemdb_search(nameid)) == NULL) return SCRIPT_CMD_SUCCESS; amount = script_getnum(st, 3); if (amount <= 0) return SCRIPT_CMD_SUCCESS; memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = nameid; item_tmp.identify = 1; for (i = 0; i < amount; i++) { map_search_freecell(&sd->bl, 0, &mx, &my, -1, -1, 0); map_addflooritem(&item_tmp, 1, sd->bl.m, mx, my, 0, 0, 0, 0, 0); } return SCRIPT_CMD_SUCCESS;

after i put this on script.cpp, how do i enable the @command in game?

help please newbie here  @Functor

  • 0
Posted
1 hour ago, Steinhart said:

recompiling with your script.ccp no errors but when i tried using it @flooritem it says failed please help thanks! 

image.png

like was functor said is script command not costume command GM, i think u missunderstand ?

  • 0
Posted
14 hours ago, melv0 said:

like was functor said is script command not costume command GM, i think u missunderstand ?

I thought it was the command i was looking for, so how do i add that custom commad @flooritem tia!

  • 0
Posted

Hello, sorry for the late posting here, I am having a similar issue with this one:
could you help me please with this code to make it work in rAthena?

 

BUILDIN_FUNC(flooritem2xy)
{
    struct item_data *item_data;
    int nameid, amount, m, x, y;
    const char *mapname;

    mapname = script_getstr(st,2);
    if( (m = map_mapname2mapid(mapname)) < 0 )
        return 0;

    x = script_getnum(st,3);
    y = script_getnum(st,4);
    nameid = script_getnum(st,5);
    if( (item_data = itemdb_search(nameid)) == NULL )
        return 0;

    amount = script_getnum(st,6);
    if( amount < 1 )
        return 0;

    map_addflooritem_area(NULL, m, x, y, nameid, amount);
    return 0;
}

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...