Jump to content
  • 0
JoyRo

Daily Reward IP check

Question

Hello,

 

Is there any one that can provide me a ip check for a daily reward or weekly..

Atm i have this script but seems not to work properly when i login 2 account they both can take the reward.

 

prontera,155,160,5	script	60 seconds Reward	4_F_FAIRYKID4,{
//=========================== Settings ================================================================
set .@rewname$,"[ Daily Reward ]";
set .rewardid,601;
set @rewardamount,1;
//======================= Settings End ================================================================
//*****************************************************************************************************
query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", @LastIp$);
if( (gettimetick(2) - lastTimeTalked > 60)&&(gettimetick(2) - getd(@LastIp$) > 60)) {
mes .@rewname$;
mes "Hello "+strcharinfo(0)+",I";
mes "am here to give you a daily";
mes "Reward. Do you want to have it?";
next;
switch(select("-Yes,sure!:-No,bye!:-Cancel")) {
case 1:
mes .@rewname$;
mes "Okay going to give you the item!";
next;
mes .@rewname$;
getitem .rewardid,@rewardamount;
mes "Okay have fun with it!";
set lastTimeTalked,gettimetick(2);
setd(@LastIp$,gettimetick(2));
close;
case 2:
mes .@rewname$;
mes "Okay goodbye!";
close;
case 3:
close;
}
}
mes .@rewname$;
mes "Sorry you can get the";
mes "Reward again after ";
mes "60 seconds are over!";
close;
}

 

Edited by JoyRo

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

@@JoyRo, sorry previously i'm just write it and test it on script checker with out in game test, i have done wrong on index part and the time left function it should be alright now, tested by me but I didn't know if it meet your need

 

prontera,155,160,5	script	60 seconds Reward	4_F_FAIRYKID4,{
	.@npc_name$ = "[Reward NPC]";
	for (.@i = 0; .@i < getarraysize($ip_reward$); .@i+=2) {
		if ($ip_reward$[.@i] != getcharip()) continue;
		.@delays = atoi($ip_reward$[.@i+1]) + .delay;
		if (.@delays > gettimetick(2)) {
			mes .@npc_name$;
			mes "This IP Addres has claimed the reward";
			mes "You have to wait for "+callfunc("Time2Str", .@delays);
			mes "To re-claim the reward for this IP Addres";
			close;
		}
		.@index = .@i+1;
		break;
	}
	mes .@npc_name$;
	mes "Hello "+strcharinfo(0)+",I";
	mes "am here to give you a daily";
	mes "Reward. Do you want to have it?";
	next;
	switch (select("-Yes,sure!:-No,bye!:-Cancel")) {
		case 1:
			mes .@npc_name$;
			for (.@j = 0; .@j < getarraysize(.reward); .@j+=2)
				getitem .reward[.@j], .reward[.@j+1];
			mes "Okay have fun with it!";
			if (.@index) $ip_reward$[.@index] = gettimetick(2);
			else {
				.@index = getarraysize($ip_reward$);
				$ip_reward$[.@index] = getcharip();
				$ip_reward$[.@index+1] = gettimetick(2);
			}
			close;
		default:
			mes .@npc_name$;
			mes "Okay goodbye!";
			close;
	}

OnInit:
	setarray .reward, 601, 1; // <item id>, <item amount>{, <item id>, <item amount>,...}
	.delay = 86400; // Delay time before reward can be re-claimed. time set in second, default 24 Hours = 86400 seconds
	end;
}

Share this post


Link to post
Share on other sites
  • 0

try this

prontera,155,160,5	script	60 seconds Reward	4_F_FAIRYKID4,{
	getcharip();
	.@npc_name$ = "[Reward NPC]";
	for (.@i = 0; .@i < getarraysize($ip_reward$); .@i+=2) {
		if ($ip_reward$[.@i] != getcharip()) continue;
		.@delays = atoi($ip_reward$[.@i+1]) + .delay;
		if ( .@delays > gettimetick(2)) {
			mes .@npc_name$;
			mes "Your IP addres have been claim the reward";
			mes "You have to wait for "+callfunc("Time2Str", .@delays - gettimetick(2));
			close;
		}
		.@index = .@i;
		break;
	}
	mes .@npc_name$;
	mes "Hello "+strcharinfo(0)+",I";
	mes "am here to give you a daily";
	mes "Reward. Do you want to have it?";
	next;
	switch (select("-Yes,sure!:-No,bye!:-Cancel")) {
		case 1:
			mes .@npc_name$;
			for (.@j = 0; .@j < getarraysize(.reward); .@j+=2)
				getitem .reward[.@j], .reward[.@j+1];
			mes "Okay have fun with it!";
			if (.@index) $ip_reward$[.@index+1] = gettimetick(2);
			else {
				.@index = getarraysize($ip_reward$);
				$ip_reward$[.@index] = getcharip();
				$ip_reward$[.@index+1] = gettimetick(2);
			}
			close;
		default:
			mes .@npc_name$;
			mes "Okay goodbye!";
			close;
	}

OnInit:
	setarray .reward, 601, 1; // <item id>, <item amount>{, <item id>, <item amount>,...}
	.delay = 86400; // Delay time before reward can be re-claimed. time set in second, default 24 Hours = 86400 seconds
	end;
}

Share this post


Link to post
Share on other sites
  • 0

it used to save ip and time when the reward taken, mmh in short it was the simple way other than to make new table on db

Share this post


Link to post
Share on other sites
  • 0

@Litro 

 

Thanx for the reply.
i logged both chars but it dident work i still claim rewards with both accounts.
 

Share this post


Link to post
Share on other sites
  • 0

@@Litro isn't the use of global variable server extensive? specially if you're running a large populated server.

AFAIK it just take a longer time to fire up a server, since you requested IP Based record I can't think better method except creating new table on DB

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

×
×
  • Create New...

Important Information

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