Jump to content
  • 0

Script help


Reborn

Question


  • Group:  Members
  • Topic Count:  104
  • Topics Per Day:  0.03
  • Content Count:  290
  • Reputation:   3
  • Joined:  09/29/13
  • Last Seen:  

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


Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  


prontera,150,150,5 script Sample 89,{

if ( gettimetick(2) > .timer ) {

query_sql "SELECT `cards`,`card_name`,`points`,`id` FROM `cards` WHERE `id` = "+ rand(1,494) +" limit 1", .ccards, .cnames$, .cpoints, .card_index;

.timer = gettimetick(2) + 5 *60;

}

mes "I'm missing a " + .cnames$ + ". I can offer " + .cpoints + " premium points in return. # "+ .card_index;

close;

}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

I don't understand what you want to do, just select a random card form the query or ?

What is the meaning of `cedi_points` and `id`

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

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;


}

this one here is useless since you'll only have 1 card returned from your query_sql

You can't use player variables on this script because no player will be attached on it on the label triggering

Also you can't use 'mes' if no player is attached.

Do this instead:

.@cards = query_sql("SELECT `card_id`,`card_names`,`cedi_points`,`id` FROM `cards` WHERE `id` = "+.number+"",.@ccards,.@cnames,.@cpoints,.@cid) ;

 npctalk "I'm missing a " +.@cnames+ ". I can offer " +.@cpoints+ " premium points in return.";

note that if '.@cnames' is an array .@cnames is the same as .@cnames[0]

 

For the rest I also didn't understand ^^

Edited by Kurofly
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  104
  • Topics Per Day:  0.03
  • Content Count:  290
  • Reputation:   3
  • Joined:  09/29/13
  • Last Seen:  

all cards are in the query with a corresponding points.

 

let say OnClock0200: the npc will pick a card randomly in the query along with the corresponding points. The picked card will stay in the NPC for about 5 minutes then after 5 minutes is up the NPC will pick another card from the query along with the corresponding points again. the card will change on every 5 minutes.

 

card_id = this will be the card id number

card_names = this is the name of the card

cedi_points =  this will the point corresponds to the card

id = this will be the ID in which the ( .number = rand(1,494) )


How about this.. Is there a way to keep the selected card on the NPC for about 5 minutes and change it after 5 minutes automatically?


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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

I would not recommend you to do this since the NPC will only change card if a player talks to it.

prontera,150,150,5	script	Sample	89,{
	.@name$ = "          ^993300[NPC's name]^000000";
	mes .@name$;
	mes "Hi there.";
	mes "I'm missing a " +.cnames$+ ". I can offer " +.cpoints+ " premium points in return. # "+.number+" ";
	next;
	if (select("Exchange:Leave") == 2) end;
	mes .@name$;
	if (!countitem(.ccards)) { mes "You don't have any "+.cnames$+"!" ; close; }
	delitem .ccards,1;
	//add the line to give points to player here V V
	//
	//add the line to give points to player here /\ /\ 
	mes "Thank you! Here are your "+.cpoints+" points!";
	close;

OnInit:
OnTimer300000:

.number = rand(1,494);

query_sql("SELECT `cards`,`card_name`,`points`,`id` FROM `cards` WHERE `id` = "+.number+"",.ccards,.cnames$,.cpoints,.cid) ;

 npctalk "I'm missing a " +.cnames$+ ". I can offer " +.cpoints+ " premium points in return. # "+.number+" ";

 initnpctimer;
} 

 The npc will change card every 5 minutes and players can trade those cards for points.

 

Don't forget to change these lines :

//add the line to give points to player here V V
//
//add the line to give points to player here /\ /\ 

I don't know what kind of points you want to give to players so I couldn't fill this part.

 

Tell me if that's not what you wanted, I'll try to understand next time ^^

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

It depends on what he wants to do.

There is no point to change the card if he doesn't make an announce and he didn't ask about that.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Yeah sure I still don't really get it but now he has two options ^^

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  104
  • Topics Per Day:  0.03
  • Content Count:  290
  • Reputation:   3
  • Joined:  09/29/13
  • Last Seen:  

@Capuche

This is exactly what I am looking for.. Thank you so much for your help... 

 

@Kurofly

Thanks for the help as well.

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