Daily Reward IP check

JoyRo

New member
Messages
120
Points
0
Location
Netherlands
Emulator
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.

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

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

 
@Litro 

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

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

Code:
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;
}
 
Hi can i ask if, i want it to be by account base and not ip address? how can i script it? i tried changing getcharip() to getcharid(3) but i am not able to click on the npc in game

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

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

 
Back
Top