Jump to content
  • 0

Want to make script Comeback is real npc


Question

Posted

Hey rathena.

i want to make some script like this illustration :

 

Player a last login is 1 june 2016

player a can claim special reward from comeback is real npc because lastlogin player a is 1 june 2016

 

so i want to make some npc can read sql at table 'login' column lastlogin , who was a last login is 1 june 2016 or less (31 may 2016 , and previous) can claim special reward from comeback is real npc.

 

anyone have suggestion?

8 answers to this question

Recommended Posts

  • 0
Posted

I'm 99% sure that by the time you've selected your char and logging into the map server, the database has already updated the lastlogin column.

  • 0
Posted (edited)

I'm 99% sure that by the time you've selected your char and logging into the map server, the database has already updated the lastlogin column.

Yep, login table is update when you login. The script needs account variables and use OnPCLogin/OnPcLogout events.

Like:

OnPCLoginEvent:

##LAST_LOGIN = atoi(gettimestr("%Y%m%d,21));

end;

and also a switch to check days difference or months..

also maybe need a SQL protecction for this a player could create accounts that only log one time for farm the price.

I dont check function is a Euphy original work but edited by me.

function    script    Check_IP    {
    // Get list of accounts with attached character's IP address.
    set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);
if(.@size <2) return;
for(.@i=0;.@i<.@size;.@i++){
 attachrid(.@aid[i]);
set ##LAST_LOGIN = atoi(gettimestr("%Y%m%d,21));
}
return;
}
Edited by vomaito
  • 0
Posted
function    script    Check_IP    {
    // Get list of accounts with attached character's IP address.
    set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);
if(.@size <2) return;
for(.@i=0;.@i<.@size;.@i++){
 attachrid(.@aid[i]);
set ##LAST_LOGIN = atoi(gettimestr("%Y%m%d,21));
}
return;
}

This wont work either because you can't use 'set' if the player is online.

Instead, try something like this.

-	script	S_ComebackNPC	-1,{
OnInit:
	.@c = query_sql("SELECT account_id FROM login WHERE lastlogin < '2016-06-02'", .@aid);
	for (.@i = 0; .@i < .@c; .@i++) {
		if (query_sql("SELECT value FROM acc_reg_num WHERE account_id = "+.@aid[.@i]+" AND key = '#comebackreward'", .@v) == 0)
			query_sql("INSERT INTO acc_reg_num(account_id, key, index, value) VALUE ("+.@aid[.@i]+", '#comebackreward', 0, 1)");
	}
	end;
OnPCLoginEvent:
	if (#comebackreward) {
		#comebackreward = 0;
		getitem 501, 1;
	}
}
  • 0
Posted
On 11/6/2018 at 1:05 AM, Emistry said:

shutdown server and execute this query


ALTER TABLE `login` ADD `last_login_date` DATETIME;
UPDATE `login` SET `last_login_date` = `last_login` WHERE `last_login_date` IS NULL

then load this npc.

https://pastebin.com/hduVVqPB

this doesnt work anymore , i have it all correctly installed , but it doesnt give the reward, nor does it error

fixed it myself , pretty easy to, wonder why no one ever made this known ?

-.@daycount

  • -1
Posted

Pretty Simple. I'll share some techniques. :)

 

You can't use the lastlogin. You can add string variables attached to your account #LoginDateTime$ and #LogoutDateTime$.

 

You can make use of the sql function DATEDIFF().

 

OnPCLoginEvent

- Retrieve the login and logout information of the account

- After retrieving, you use the sql function.

- Get the result value if > 30 days or so.

- Then give the rewards. 

- Set the #LoginDateTime$

 

OnPCLogoutEvent

- Set the #LogoutDateTime$

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...