Jump to content
  • 0

problem with script.cpp


xSoul

Question


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.01
  • Content Count:  36
  • Reputation:   1
  • Joined:  07/07/17
  • Last Seen:  

 

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

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  141
  • Reputation:   45
  • Joined:  08/14/12
  • Last Seen:  

     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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   2
  • Joined:  08/30/18
  • Last Seen:  

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 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  351
  • Reputation:   263
  • Joined:  09/08/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   2
  • Joined:  08/30/18
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  351
  • Reputation:   263
  • Joined:  09/08/13
  • Last Seen:  

@Steinhart

It is script command.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   2
  • Joined:  08/30/18
  • Last Seen:  

22 minutes ago, Functor said:

@Steinhart

It is script command.

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

image.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

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 ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   2
  • Joined:  08/30/18
  • Last Seen:  

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!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  140
  • Topics Per Day:  0.03
  • Content Count:  562
  • Reputation:   107
  • Joined:  10/05/12
  • Last Seen:  

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

Link to comment
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.   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...