Jump to content
  • 0
Sign in to follow this  
almarket23

Script help

Question

Hi everyone. Does anyone know how to fix this script?

 

Here are the things that I need for this script..

 

1st: I want this script pick a card from the system and in every 2 hours it will change to another card. picking a card should be random and all the cards in the system should be available.

 

2nd: While the time is not up yet the picked card can be seen from the NPC and it will just change to another card when 2 hours is up. 

 

prontera,150,150,5	script	Sample	89,{mes "No available cards at the moment.";close; OnClock0000:OnClock0200: OnClock0400:OnClock0600:OnClock0800:OnClock1000:OnClock1200:OnClock1400:OnClock1600:OnClock1800:OnClock2000:OnClock2200:OnStart:.number = rand(1,494); // this are the number of cards available in the system.@cards = query_sql("SELECT `card_id`,`card_names`,`cedi_points`,`id` FROM `cards` WHERE `id` = "+.number+"",@ccards,@cnames,@cpoints,@cid) ;for (.@i = 0; .@i < .@cards; .@i++ ) if( .number == @cid[.@i] ) {mes "I'm missing a " +@cnames[.@i]+ ". I can offer " +@cpoints[.@i]+ " premium points in return.";close;}}

 

 

 

I hope that anyone understand what I mean. Please help me. Thanks...

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I understand the 1st part but I don't quite get the 2nd part.

 

Or if I do understand it correctly, I don't think there's a way to floor an item longer than the duration in the conf files.

Share this post


Link to post
Share on other sites
  • 0

Please fix this script. The only thing that I want to this script is to make the selected card from the query with corresponding points to stay in the NPC for about 5 minutes and after that the NPC will change the card to a different card...

 

The script that I have is making it pick a random cards every time that I click the NPC which is not what I want.

 

Here is the new script..

 

prontera,150,150,5	script	Sample	89,{.number = rand(1,494);.@cards = query_sql("SELECT `cards`,`card_name`,`points`,`id` FROM `cards` WHERE `id` = "+.number+"",.@ccards,.@cnames$,.@cpoints,.@cid) ;if( .number == .@cid ) {Talk: npctalk "I'm missing a " +.@cnames$+ ". I can offer " +.@cpoints+ " premium points in return. # "+.number+" ";}}

 

 

Please help me with this.

Share this post


Link to post
Share on other sites
  • 0

Here is how i would do it, but be aware i didn't test it. So possibly have to fix slight mistakes. But you should be able to abstract what you need from it.

prontera,150,150,5	script	Sample	89,{	// if the random card id was never set or the timer exceeds 5 minutes, create a new random card id and reinit the timer.	if(.randCID == 0 || ((getnpctimer(0) / 1000) / 60) >= 5) {		.randCID = rand(1,494);		initnpctimer;	} 	npctalk "I'm missing a "  + .allCNames$[.randCID] +  ". I can offer "  + .allCPoints[.randCID] +  " premium points in return.";		end;		// Setup a internal database of all the cards.	OnInit:		.@[member=start] = 0;		.@end = 128;				// Fetch all cards from the database with workaround for the 128 entry limit.		for(.@i = 1; .@i <= 4; .@i++)	{			if(.@i > 1) {				.@[member=start] = (.@i - 1) * 128;				.@end = .@i * 128; 			}						.@cardQuery = query_sql("SELECT `cards`,`card_name`,`points`,`id` FROM `cards`",.@ccards,.@cnames$,.@cpoints,.@cids) + " LIMIT " +  .@[member=start] +  "," + .@end);			for(.@y = 0; .@y < getarraysize(.@ccards); .@y++) {				.allCards[.@cids[.@y]] = .@ccards[.@y];				.allCNames$[.@cids[.@y]] = .@cnames$[.@y];				.allCPoints[.@cids[.@y]] = .@cpoints[.@y];			}		}		end;}
Edited by Winterfox

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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