• 0
Sign in to follow this  
Jiji

Item giver for a specific range of account IDs

Question

Hello i wanted to request a custom npc that gives an item to a specific range of IDs.
Example:

Account IDs : 2000009 - 2000030

gets 20 apples upon logging in game and has a timer of 24 hours.

Thank you in advance. ☺️

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
-	script	Sample	FAKE_NPC,{
OnInit:
detachrid();
.cdtime = 24*60*60;
for (set .accid, 2000009; .accid<=2000030 ; .accid++)
end;
OnPCLoginEvent:
attachrid(.accid);
if (#gotone + .cdtime> gettimetick(2)) {
	dispbottom "Daily reward have been distributed";
	end;
}
else {
	dispbottom "An apple a day takes the doctor away.";
	getitem Apple,20;
	#gotone = gettimetick(2);
	end;
}
}

 

Share this post


Link to post
Share on other sites
  • 0
9 hours ago, Kuroe said:

 

-	script	Sample	FAKE_NPC,{
OnInit:
detachrid();
.cdtime = 24*60*60;
for (set .accid, 2000009; .accid<=2000030 ; .accid++)
end;
OnPCLoginEvent:
attachrid(.accid);
if (#gotone + .cdtime> gettimetick(2)) {
	dispbottom "Daily reward have been distributed";
	end;
}
else {
	dispbottom "An apple a day takes the doctor away.";
	getitem Apple,20;
	#gotone = gettimetick(2);
	end;
}
}

 

Thanks for trying to help the OP. However, this script isn’t written correctly.

The OnInit label inherently does not have an attached RID, using detachrid() is pointless.

You then use a for loop without any defined action: syntax for(index set; condition; increment) { action }
Note that you are missing the action portion of the for loop.

The OnPCLoginEvent label inherently DOES have an RID attached (namely, the player that just logged in). There is no need to use attachrid here.

If you were to fix all of the issues I listed above, your script would distribute the items to all accounts as you have not implemented any check to ensure the account ID is within the specified range described by the OP.

Edited by Luciar

Share this post


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

Loading...
Sign in to follow this