Jump to content
  • 0
Sign in to follow this  
Takumirai

@spawn on whisper

Question

- can anyone help me

 

 

- script spawn -1,{
OnWhisperGlobal:
if (getgroupid() < 2) end;
if (@whispervar0$ == "mvp") {
mes "Select one:";
next;
set .@m, select(.smenu$) - 1;
} else {
  close2;
  atcommand "@spawn " + .mobid[.@m] + " " + .mobam[.@m];
  end;
}
OnInit:
// Spawn ID
setarray .mobid[0],1511,1647,1785,1630,1039,1874,1272,1719,1046,1389,1112,1115,1418,1871,1252,1768,1086,1885,1649,1651,1832,1492,1734,1251,1779,1688,1646,1373,1147,1059,1150,1087,1190,1038,1157,1159,1623,1650,1583,1708,1312,1751,1648,1658;
// Spawn amount
setarray .mobam[0],1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;
set .smenu$,"";
for(set .@s,0; .@s < getarraysize(.mobid); set .@s,.@s + 1) {
  // Skips an Monster if it does not exist in the db
  if (getmonsterinfo(.mobid[.@s],0) == "" || getmonsterinfo(.mobid[.@s],0) == "null") {
   debugmes .n$ + ": Mob ID " + .mobid[.@s] + " is not a valid ID.";
   deletearray .mobid[.@s],1;
   deletearray .mobam[.@s],1;
   deletearray .mobze[.@s],1;
   continue;
  }
  // else adding it to the menu
  set .smenu$,.smenu$ + "- "+getmonsterinfo(.mobid[.@s],0) + ( (.mobid[.@s+1] == 0)?"":":");
}
end;
}

 

- the script dont state what's the error in the script

- when i pm mvp nothing happens

 

- thanks in advance

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
    if (@whispervar0$ == "mvp") {    mes "Select one:";    next;    set .@m, select(.smenu$) - 1;    } else {      close2;      atcommand "@spawn " + .mobid[.@m] + " " + .mobam[.@m];      end;}

You're telling the script to check if you typed mvp. If you did, it's going to make you choose a menu option. After that, because you have the " else " statement, it's going to skip that and go straight to OnInit: label and and do everything else all over again.

 

Just change the bit of code I copied from there, and change to this:

if (@whispervar0$ == "mvp") {    mes "Select one:";    next;    .@m = select(.smenu$) - 1;    close2;    atcommand "@spawn "+ .mobid[.@m] +" "+ .mobam[.@m];}end;

Share this post


Link to post
Share on other sites
  • 0

Still can't whisper .. can you make it if I whisper spawn: "mvp" I can spawn mvp in the list and group 3 and above can only whisper it

Edited by Takumirai

Share this post


Link to post
Share on other sites
  • 0

Well, you can try this:

-	script	spawn	-1,{OnWhisperGlobal:    if (getgroupid() < 2) end;	if (@whispervar0$ == "mvp") {		mes "Select one:";		next;		.@m = select(.smenu$) - 1;		close2;		atcommand "@spawn "+ .mobid[.@m] +" "+ .mobam[.@m];	}end;OnInit:// Spawn IDsetarray .mobid[0],1511,1647,1785,1630,1039,1874,1272,1719,1046,1389,1112,1115,1418,1871,1252,1768,1086,1885,1649,1651,1832,1492,1734,1251,1779,1688,1646,1373,1147,1059,1150,1087,1190,1038,1157,1159,1623,1650,1583,1708,1312,1751,1648,1658;// Spawn amountsetarray .mobam[0],1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;set .smenu$,"";for(set .@s,0; .@s < getarraysize(.mobid); set .@s,.@s + 1) {  // Skips an Monster if it does not exist in the db  if (getmonsterinfo(.mobid[.@s],0) == "" || getmonsterinfo(.mobid[.@s],0) == "null") {   debugmes .n$ + ": Mob ID " + .mobid[.@s] + " is not a valid ID.";   deletearray .mobid[.@s],1;   deletearray .mobam[.@s],1;   deletearray .mobze[.@s],1;   continue;  }  // else adding it to the menu  set .smenu$,.smenu$ + "- "+getmonsterinfo(.mobid[.@s],0) + ( (.mobid[.@s+1] == 0)?"":":");}end;}

But honestly, I don't think Hercules has that anymore.

Share this post


Link to post
Share on other sites
  • 0

You could use bindatcmd to do this: bindatcmd "command","<NPC object name>::<event label>"{,<group level>,<group level char>,<log>};

 

Here's a version that does what you want for the original @spawn command. It limits it's use for GMs who's groupid() is 3 -> 98. However, if you're GM lvl 99, then you can use @spawn freely like normal. Additionally, if you're groupid() 0->2, then you can't use it at all.

 

-	script	spawn	-1,{OnInit:// Spawn IDssetarray .mobid[0],1511,1647,1785,1630,1039,1874,1272,1719,1046,1389,1112,1115,	           1418,1871,1252,1768,1086,1885,1649,1651,1832,1492,1734,1251,		   1779,1688,1646,1373,1147,1059,1150,1087,1190,1038,1157,1159,		   1623,1650,1583,1708,1312,1751,1648,1658;for (.@i = 0; .@i < getarraysize(.mobid); .@s++) {	if (getmonsterinfo(.mobid[.@i],0) == "" || getmonsterinfo(.mobid[.@i],0) == "null") {		debugmes strnpcinfo(3) +": Mob ID ["+ .mobid[.@i] +"] is not a valid ID.";		deletearray .mobid[.@i],1;	} else {		.spawn_menu$ = .spawn_menu$ +"- "+ getmonsterinfo(.mobid[.@i],0) + ((.mobid[.@i+1] == 0)?"":":");	}}bindatcmd "spawn", strnpcinfo(3)+"::OnSpawn";end;OnSpawn:if (getgroupid() < 2) { end; }if (getgroupid() >= 3 && getgroupid() < 99) {	mes "Select one monster to spawn.";	next;	.@select = select(.spawn_menu$) - 1;	close2;	atcommand "@spawn "+ .mobid[.@select] +" 1";} else {	atcommand "@spawn "+ .@atcmd_parameters$[0] +" "+ .@atcmd_parameters$[1];}end;

 

Since, you were making them only able to spawn 1 of those monsters, I got rid of that array, and just made it spawn 1 through the command itself.

Edited by GmOcean

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

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