Jump to content
  • 0

Callfunc npc script in src code?


Hyroshima

Question


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  159
  • Reputation:   58
  • Joined:  07/11/14
  • Last Seen:  

hlw, would anyone tell me how to execute a

callfunc "func", param1,param2;

in src (função de npc script existente!)   ?

one skill will call callfunc "func", 1, skill_id;

I need to pass param1 = 1, param2 = skil_level

Edited by Hyroshima
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

Heya,

You can't do that (not without major changes anyway). I presume the goal here is to run a script in the source (which is a bad idea), but the easy solution here would simply be to set your variables as temporary global variables and then run an event label:

In the source, you would use something like:

#include "mapreg.h"
#include "npc.h"

[...]

mapreg_setreg(reference_uid(add_str("$@param1"), 0), MG_SAFETYWALL);
mapreg_setreg(reference_uid(add_str("$@param2"), 0), skill_id);
mapreg_setregstr(reference_uid(add_str("$@param3$"), 0), "a string");

npc_event_do_id("MyScript::OnCalled", sd->bl.id);

 

And in the script:

function	script	myfunction	{
	announce "arg1: " + getarg(0) + ", arg2: " + getarg(1) + ", arg3: " + getarg(2);
	return;
}

-	script	MyScript	-1,{
	end;
OnCalled:
	callfunc("myfunction", $@param1, $@param2, $@param3$);
	end;
}

 

It would be much easier to do the code in the source directly instead though.

  • Love 1
  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.01
  • Content Count:  416
  • Reputation:   73
  • Joined:  05/16/19
  • Last Seen:  

try using the code it was written with

 

DUHHHHHHHHHHHH

 

check your script.c

 

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