Jump to content
  • 0

Want to make script Comeback is real npc


dikapramantya

Question


  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  216
  • Reputation:   9
  • Joined:  07/12/12
  • Last Seen:  

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?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  141
  • Reputation:   45
  • Joined:  08/14/12
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  45
  • Reputation:   3
  • Joined:  06/29/15
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  55
  • Topics Per Day:  0.01
  • Content Count:  216
  • Reputation:   9
  • Joined:  07/12/12
  • Last Seen:  

AH , i'm forget it >.<

 

atoi(gettimestr("%Y%m%d,21)); << what this is mean?

so its impossible make a comeback npc ? :o

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  141
  • Reputation:   45
  • Joined:  08/14/12
  • Last Seen:  

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;
	}
}
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  111
  • Reputation:   2
  • Joined:  05/09/13
  • Last Seen:  

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

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  193
  • Reputation:   41
  • Joined:  07/21/16
  • Last Seen:  

You could create another table for that and trigger it using OnPCLogin or something.

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  5
  • Reputation:   0
  • Joined:  07/27/15
  • Last Seen:  

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$

Link to comment
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.   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.

×
×
  • Create New...