Jump to content

Question

Posted

Hi, I wanted to know if you can, take the ID of the monsters from the query: sql, and plug it into an array, and from there take one at random.
it is possible, I stopped here !!!!

prontera,140,140,4	script	mobkk	73,{

.@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ",.@ids,.@iname$ );
for( .@i = 0; .@i < .@sql; .@i++ )
	 mes "ID : "+.@ids[.@i]+" & Name : "+.@iname$[.@i];
		
	
	
}

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

thank you Capuche,but I know that I'm doing a little bit of confusion.I tried but I can not, here is the script I tried to write

prontera,143,143,4	script	mobk	73,{

.@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ORDER BY RANDOM id LIMIT 2",.@id,.@name$ );
for( .@i = 0; .@i < .@sql; .@i++ )
	
		 mes "ID : "+.@id[.@i]+" & Name : "+.@name$[.@i];

}

here is the error picture

 

1377fc5.png

Edited by Valcars
  • 0
Posted (edited)

Hello,

Thanks @capuche,

but I go out with another problem, in practice I need to store the monster in a variable, and every 24 hours changes monster, if you kill monsters you get a Coin. I do not know if I was clear, I can not go on. if you can help me, even cone of ideas. Thanks again.
That's what I did until now.

prontera,160,160,4	script	mob	857,{
	
	mes .@nameNpc$;
	mes "Hello "+ strcharinfo(0)+".";
	mes "I can give Poring Coin";
	mes "in return you have to kill all the monsters that tell you";
	next;
	.@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ORDER BY RAND(ID) LIMIT 500",.@id,.@name$ );
	
	for( .@i = 0; .@i < .@sql; .@i++ ){
		
		copyarray .@mobID[0],.@id[.@i],500;
		copyarray .@mobName$[0],.@name$,500;
		setarray .@mobKill[0],100,200,300;
		set .@ranmob,rand(0,500);
		set .@rankill,rand(0,2);
		
		mes .@nameNpc$;
		mes "Today you need kill :"+.@mobName$[.@ranmob]+" x "+.@mobkill[.@rankill];
		close;
	}
	
	
//-----------------------------------------------------------------------//
//OnNPCKIllEvent Label
//-----------------------------------------------------------------------//		
	OnNPCKillEvent:
		if(killedrid == .@mobID[.@ranmob]){
			mes "You have kill "+.@mobName$[.@ranmob];
			close;
		}
		end;	
		
//-----------------------------------------------------------------------//
//OnInit Label
//-----------------------------------------------------------------------//
		OnInit:
		waitingroom "Kill Mob for Coin",0;
		set .@nameNpc$,"[Mob Kills]";
		
			
}
		
			
	

Edited by Valcars
  • 0
Posted
prontera,160,160,4	script	mob	857,{
	
	mes .@nameNpc$;// unset (see oninit)
	mes "Hello "+ strcharinfo(0)+".";
	mes "I can give Poring Coin";
	mes "in return you have to kill all the monsters that tell you";
	next;
	.@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ORDER BY RAND(ID) LIMIT 500",.@id,.@name$ );// it should be rand()
	
	for( .@i = 0; .@i < .@sql; .@i++ ){// unused the loop stop after the close
		
		copyarray .@mobID[0],.@id[.@i],500;// you can take 1 random monster with sql (rand() limit 1)
		copyarray .@mobName$[0],.@name$,500;
		setarray .@mobKill[0],100,200,300;
		set .@ranmob,rand(0,500);
		set .@rankill,rand(0,2);
		
		mes .@nameNpc$;
		mes "Today you need kill :"+.@mobName$[.@ranmob]+" x "+.@mobkill[.@rankill];
		close;
	}
	
	
//-----------------------------------------------------------------------//
//OnNPCKIllEvent Label
//-----------------------------------------------------------------------//		
	OnNPCKillEvent:
		if(killedrid == .@mobID[.@ranmob]){
			mes "You have kill "+.@mobName$[.@ranmob];
			close;
		}
		end;	
		
//-----------------------------------------------------------------------//
//OnInit Label
//-----------------------------------------------------------------------//
		OnInit:
		waitingroom "Kill Mob for Coin",0;
		set .@nameNpc$,"[Mob Kills]";// everytime the script end the .@variables are cleared
		
			
}
	

I didn't test :

prontera,160,160,4	script	mob	857,{
	.@nameNpc$ = "[Mob Kills]";

	mes .@nameNpc$;
	mes "Hello "+ strcharinfo(0) +".";
	mes "I can give Poring Coin";
	mes "in return you have to kill all the monsters that tell you.";
	next;
	if (date_event != gettime(8)) {
		mob_count_event = 0;			// clear the previous count kill
		date_event = gettime(8);		// save the date
		rankill_event = rand(1,3) *100;	// save the number to kill
		query_sql( "select `ID` from mob_db where `EXP` > 0 and (`Drop1id` > 0 or `Drop2id` > 0 or `Drop3id` > 0 or `Drop4id` > 0 or `Drop5id` > 0 or `Drop6id` > 0 or `Drop7id` > 0 or `Drop8id` > 0 or "+
			"`Drop9id` > 0 or DropCardid > 0 ) ORDER BY RAND() LIMIT 1", mob_id_event );// not an event mob

		mes .@nameNpc$;
		mes "Today you need kill: "+ getmonsterinfo( mob_id_event,MOB_NAME ) +" x"+ rankill_event;
	}
	else if (mob_count_event < rankill_event)
		mes "You have killed "+ mob_count_event +"/"+ rankill_event +" "+ getmonsterinfo( mob_id_event,MOB_NAME );
	else {
		mes "Congrat you killed all the monsters.";
		getitem 501,1;
	}
	close;
	
OnNPCKillEvent:
	if (killedrid == mob_id_event && mob_count_event < rankill_event) {
		mob_count_event++;
		message strcharinfo(0), "You have killed "+ mob_count_event +"/"+ rankill_event +" "+ getmonsterinfo( mob_id_event,MOB_NAME );
	}
	end;

OnInit:
	waitingroom "Kill Mob for Coin",0;
	end;
}
	

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