Jump to content
  • 0

Question

10 answers to this question

Recommended Posts

  • 1

I don't know either if there's already such script (but it probably is on the other forums), but I just wrote a basic script.

Since I'm not at home I'm unable to test if it actually works.

What the script does:

- checks if the player is less then 5 cells away (checkdistance(...)<5)

- check if player has required item (countitem(607), Ygg Berry in this case)

- 60% chance (rand(0,100) < 60) to get the materials (getitem 501,1;)

- basic protection to prevent massive farming (the npc will be disable for 30-60 seconds)

map,x,y,0	script	Name::identifier	111,{
getmapxy([email protected]$, [email protected], [email protected], 0);			// get Player coordinates
getmapxy([email protected]$, [email protected], [email protected], 1, strnpcinfo(3));	// get NPC coordinates

// Check if player is near enough (distance < 5)
if (distance([email protected], [email protected], [email protected], [email protected]) < 5) {

	// Check if user has required item [in this case: Ygg Berry#607]
	if (countitem(607)) {
		progressbar "0x00ff00", 2000;
		// 60% chance to obtain item
		if (rand(0,100) < 60) {
			getitem 501,1;	// Red Potion#501
			specialeffect2 154;
			donpcevent strnpcinfo(3)+"::OnDisable";
			end;
		}
		specialeffect2 155;
		dispbottom "You didn't get anything this time.";
		end;
	}
	dispbottom "You don't have the necessary tools..";
	end;
}
dispbottom "You're too far away.";
end;

OnDisable:
disablenpc strnpcinfo(3);
initnpctimer
end;

// 10% chance to reactivate after 30, 40 or 50 seconds. otherwise reactive after 60 seconds
OnTimer30000:
OnTimer40000:
OnTimer50000:
if (rand(0,100) < 90)
	end;
OnTimer60000:
OnEnable:
stopnpctimer;
enablenpc strnpcinfo(3);
end;
}

Edited by Toshiro
Link to comment
Share on other sites

  • 0


Thanks for the Fast Reply, well..seems i got 'ERROR' line '10'?
http://i42.tinypic.com/awyng8.png
- Keenan

Oh sorry, should have been "countitem" instead of "checkitem". Updated the script in the first post.


Removed Edited by Kaze
Link to comment
Share on other sites

  • 0

@Keenan: You need to learn to start debugging scripts instead of relying on everyone to post up the fixes. It was a simple typo:

if (distance([email protected], [email protected], [email protected], [email protected]) < 5) {

Should be:

if (distance([email protected], [email protected], [email protected], [email protected]) < 5) {

Link to comment
Share on other sites

  • 0

@Epoque or the person giving it to him should've tested it... You can't blame someone "requesting" a script, (meaning they can't obviously script it themselves) to debug a script...

Link to comment
Share on other sites

  • 0

@Epoque or the person giving it to him should've tested it... You can't blame someone "requesting" a script, (meaning they can't obviously script it themselves) to debug a script...

As I already wrote when posting the script, I have not been at home, so I was unable to test it.

Also if I still would have been online when Keenan posted that it was still not working, I'd checked it again and would have fixed it anyways.

Edited by Toshiro
Link to comment
Share on other sites

  • 0

@Toshiro I understand that you weren't @ home, it's just, he quickly attacked the OP, when it was obvious he didn't really know how to script something like this in the first place...

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

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.