Jump to content
  • 0

Free Items NPC (Optimization)


Eidolon

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   2
  • Joined:  02/07/13
  • Last Seen:  

http://pastebin.com/WtGQru87

Let's see, this script is just a NPC giving free items,

Could you guys help me by checking it and pointing out things on the script that I can optimize to make the script neater?

I mean neater but the options given by the npc are not changed.

Thank you. It will be a really great help if you can.

Edited by Eidolon
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


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

Line 12 and 16: what if you had a custom item in your database that was actually named "null" :P

Instead, you should check if getiteminfo returns -1, meaning the item does not exist.

Line 22: instead of manually doing the math with MaxWeight, try the checkweight function

Line 40: (personal preference) use if or switch instead of menu which creates "goto" labels.

other suggestions:

- line up your indents so the opening and closing braces { } are lined up

- only indent 1 tab for each level of indentation (ex: line 10 has 2 tabs)

This will save horizontal space when your script has deeper levels of indentation

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

But I prefer to use a menu rather than a switch.

  • Upvote 1
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...