Jump to content

Additional Script Command for Math Function: abs(x);


JayPee

Recommended Posts


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

This is just a additional script command for Math Function. Since I dont know yet on how to make a .diff file we will just do it manually.

Function: abs(<numbe);

1.) Edit src/map/script.c

2.) Find BUILDIN_FUNC(distance) then add this below

//JayPee Additional Math Function: absolute

BUILDIN_FUNC(abs)
{
int a;
int x;
x = script_getnum(st,2);
a = abs(x);
script_pushint(st,a);
return 0;
}

3.) Now find BUILDIN_DEF(set,"rv"), then add this below.

BUILDIN_DEF(abs,"i"), //JayPee

4.) Recompile your server.

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   8
  • Joined:  03/10/12
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

And in case anyone needs it NOW before recompiling and restarting, you could use a script function:

function	script	abs	{
.@i = atoi(getarg(0));
return ( (.@i < 0) ? -.@i : .@i );
}

thanks to the r15982: Script Engine Update !

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   8
  • Joined:  03/10/12
  • Last Seen:  

Hihihi.. You guys are awesomeness! :)

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
Reply to this topic...

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