Jump to content
  • 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

5 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
  • 0
On 4/30/2019 at 2:46 PM, 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; } }


-	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;
}
}

 

how about random account id's?

and if its possible it is also a random item to the random players that will be rewarded.

Share this post


Link to post
Share on other sites
  • 0
On 2/20/2020 at 3:32 PM, skymia said:

how about random account id's?

and if its possible it is also a random item to the random players that will be rewarded.

 

getitem Apple, 20, rand(2000009, 2000030);

 

Share this post


Link to post
Share on other sites
  • 0
On 5/1/2019 at 12:10 AM, Luciar said:

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.

Thanks for this Sir, Can u share the correct one? The one that will work. Newbie here. Thanks for the help in advance!

 

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

  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  

×
×
  • Create New...

Important Information

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