Item giver for a specific range of account IDs

Jiji

New member
Messages
1
Points
0
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. ☺️

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

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

 
Last edited by a moderator:
- 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;
}
}

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

 
how about random account id's?

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


Code:
getitem Apple, 20, rand(2000009, 2000030);
 
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!

 
Back
Top