• 0
Peopleperson49

R>Help on creating a new log...

Question

Request help on how to make a new log table. For example the player talks to x npc and request 7 red potions. Then it will adds a log to that table that says, "PlayerDude asked for 7 red potions. I'm not sure how logs are done, but I know there are SQL tables for logs already. I want it to work with a custom log. Thanks.

 

Peopleperson49

Share this post


Link to post
Share on other sites

17 answers to this question

Recommended Posts

just use the logmes script command and he will log into the npclog db

Share this post


Link to post
Share on other sites

I understand the logmes command, but I'm wanting it to go to a custom table seperate from that. It is intended for a specific purpose, and I don't want to have to sort through a list of other messages. Also I want to add that log to my website to be viewed so other stuff cannot be there either. Thanks for the reply.

 

Peopleperson49

Share this post


Link to post
Share on other sites

first of all.. you want to have a custom sql table that save the record ?? and how your npc works ?? 

player click npc and gain item then save a record..

or..

player click "ask for item" then no item gained..but save a record ...

 

 

by default the server will have a record whenever player gained an item no matter how they get it...from loot..from trade..or npc through getitem ...( if you enabled log in your server )

 

using logmes is another way to allow you to save custom log with custom message yuo want.

Share this post


Link to post
Share on other sites

I guess I need to be more clear. Its a wishing well script. The player throws a certain amount of zeny in the well and then types in a wish. Below is what I already use. Periodically the GMs can look through the list and grant the wish if they choose. I'm trying to get it to save it in a seperate SQL log. There should be a way to save it in a table just like saving any other variable. Thanks.

 

Peopleperson49

 

 

logmes "Wishing Well: "+strcharinfo(0)+" has thrown "[email protected]+" zeny into the fountain wishing for "[email protected]$+".";
Edited by Peopleperson49

Share this post


Link to post
Share on other sites

Why not just use a normal sql db as Emistry suggested? This way, you can also, have it pull data-ingame, by sorting through everything and making a list via a SQL ladder. It's not too hard, and can be accessed via your website. Best way I can think of :/

Share this post


Link to post
Share on other sites

That sounds great except I'm not that good with SQL yet. Any volunteers, lol? That is basically what I was saying above about saving it in a table like any other variable. Thanks for your reply.

 

Peopleperson49

Share this post


Link to post
Share on other sites

Okay well, here is an example, of how I would have it stored, after that it's just a matter of retrieving the information for use later on.

prontera,180,150,4	script	Wishing Well	123,{
	mes "Throw zeny in and make a wish?";
	if(select("Throw Zeny:Wishes are for suckers")==2){close;}
	else { 
	mes "How much zeny would you like throw in?";
	input @zeny,0,zeny;
	if([email protected]){close;}
	mes "Tell me your wish...";
	input @wish$; //Think character limit is 255? Should be plenty.
	query_sql("INSERT INTO `wishing_well` (acct_id,name,zeny,wish,granted) VALUES ('"+ getcharid(3) +"','"+ strcharinfo(0) +"','"+ @zeny +"','"+ @wish$ +"','0')");
	set zeny,zeny - @zeny;
	mes "Your wish has been received.";
	close;
}

CREATE TABLE IF NOT EXISTS `wishing_well` (
`ID` bigint(20) unsigned NOT NULL auto_increment,
`acct_id` int(11) unsigned NOT NULL default '0',
`name` varchar(30) NOT NULL default '',
`zeny` int(11) unsigned NOT NULL default '0',
`wish` text,
`granted, tinyint(2) NOT NULL default '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM;

Share this post


Link to post
Share on other sites

I created this in SQL:

 

CREATE TABLE IF NOT EXISTS `wishlog` (
  `npc_id` mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
  `npc_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `account_id` int(11) unsigned NOT NULL DEFAULT '0',
  `char_id` int(11) unsigned NOT NULL DEFAULT '0',
  `char_name` varchar(25) NOT NULL DEFAULT '',
  `mes` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`npc_id`),
  KEY `account_id` (`account_id`),
  KEY `char_id` (`char_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

Share this post


Link to post
Share on other sites

Lol, Emistry and I had similar ideas, but you should use his script as it's cleaner, also, it stores a time-stamp so you know whether or not, it's old.

Share this post


Link to post
Share on other sites

Thanks both of you. I will take what I figured out on my own and use your correct version and learn from it. You basically did what I was going to do, lol, just I would of screwed it up a few time before I got it right. Again thanks.

 

Peopleperson49

 

Thanks guys I used this below and it works good. Now the next question is how the heck do I get it on my website to be viewed?

 

Peopleperson49

 

 

CREATE TABLE IF NOT EXISTS `wishlog` (
  `wish_id` mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
  `wish_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `account_id` int(11) unsigned NOT NULL DEFAULT '0',
  `char_id` int(11) unsigned NOT NULL DEFAULT '0',
  `char_name` varchar(25) NOT NULL DEFAULT '',
  `wish` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`npc_id`),
  KEY `account_id` (`account_id`),
  KEY `char_id` (`char_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

query_sql("INSERT INTO wishlog (wish_date,account_id,char_id,char_name,wish) VALUES ( '"+gettimestr("%Y-%m-%d %H:%M:%S",21)+"','"+getcharid(3)+"','"+getcharid(0)+"','"+strcharinfo(0)+"','The player "+strcharinfo(0)+" has thrown "[email protected]+" zeny into the fountain wishing for "[email protected]$+".')");
Edited by Peopleperson49

Share this post


Link to post
Share on other sites

go to your website page...write some code ( php perhaps ) to retrieve it from your database ... and display it at your website...

Share this post


Link to post
Share on other sites

Not sure how to port it to a website, not skilled in that code lol, BUT it is possible. Though there is one thing to note about your SQL Table, your storing their wish into a string with a 255char max string. This is fine, except that input's and the like in RO allow for 255 characters. Since your adding: ' Player A has thrown XXXXX zeny into the fountain wishing for "+ players really long wish should they choose to +". You MIGHT go over the 255 cap and it'll either error or cut some of the text out. You could have SQL store it as a TEXT where it won't have that 255 limit, but it's up to you.

Edited by Lionhardt

Share this post


Link to post
Share on other sites

Thats a good point, and hopefully I don't hit it. I added the other stuff because the website table is going to allow that entire string to be read. I don't want somebody having to "decipher" it by looking over multiple columns, lol. Thanks.

 

Peopleperson49

Share this post


Link to post
Share on other sites

Idea to source codes.

 

npclog <VALUE>

1 - getitem log;

2 - set ZENY,%amount% log;

3 - set cashpoints/etc %amount% log;

4 - all;

 

By default it's disabled, If it's enabled, admin can log each getitem scripts, set Zeny scripts, set cashpoints. It will help to find bugs in npc (like old coin bug) etc shit.

Share this post


Link to post
Share on other sites

I think i figured out give it a look and tell me what you think. Go to my site at www.ro-underground.com and click on the Wish List tab in the bottom center ranking.

 

Peopleperson49

Edited by Peopleperson49

Share this post


Link to post
Share on other sites

Oh? That looks pretty good. You should however, convert the number, into a string, so as to add, commas. Merely for looks only lol, but i guess doing that, would require additional scripting and changing the zeny column in the db to string instead of int. But aside from that, seems to work perfectly. Only downside I see is if, you all of a sudden get flooded with wishes lol... Might wanna put a wishing cap xD and a timelimit for when they will be auto-deleted if they havent been granted after X amount of seconds/minutes/hours/days/weeks/months O.o hell with it/ years lol

Edited by Lionhardt

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