Jump to content
  • 0

Mob ID Sql


Valcars

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  60
  • Reputation:   0
  • Joined:  01/03/16
  • Last Seen:  

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

6 answers to this question

Recommended Posts

  • 0

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  60
  • Reputation:   0
  • Joined:  01/03/16
  • Last Seen:  

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

  • 0

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

Here is what you write

 

ORDER BY RANDOM id LIMIT

 

Here is what the doc say

ORDER BY RAND() LIMIT
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  60
  • Reputation:   0
  • Joined:  01/03/16
  • Last Seen:  

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

  • 0

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

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

  • 0

  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  60
  • Reputation:   0
  • Joined:  01/03/16
  • Last Seen:  

capuche thanks, you're a big xD.

 

 

 

 

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