Jump to content
  • 0

Script event when clone kills another clone


Question

Posted

Hi rA!

I'm using the *clone script to generate clone for X users in map, they have a ::OnCloneDead event attached so my Question is:

There is a way to know what clone kills another clone?

Like: The [Player 1] clone kill [Player 2] clone.

Thanks in advance!

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

the clone command return the monster gid

so you can just save the gid and check for it

like 

.PlayerOneClone = clone("prontera",155,155,"NpcName::OnEvent",1);
.PlayerTwoClone = clone("prontera",145,145,"NpcName::OnEvent",2);
end;
OnEventOne:
	if(!unitexists(.PlayerOneClone)){
		//player one clone is dead
	}
	if(!unitexists(.PlayerTwoClone)){
		//player two clone is dead
	}
end;

 

also the event name, you can just use different event name for each clone

like

clone("prontera",155,155,"NpcName::OnEventOne",1);
clone("prontera",145,145,"NpcName::OnEventTwo",2);
end;
OnEventOne:
	//player one clone is dead
end;
OnEventTwo:
	//player two clone is dead
end;

 

 

here a long example :

let's clone everyone in prontera , than we check every time one of the mobs are dead we output a debugmes for the char id of the player

(i didn't test it , i just wrote it as an example , i don't know even if it will work but technically it should work)

	getmapunits(BL_NPC,"prontera",.@AID);
	for(.@i=0;.@i<getarraysize(.@AID);.@i++){
		.@s = getarraysize(.charList);
		.charList[.@s] = convertpcinfo(.@AID[.@i],CPC_CHAR);
		.mobList[.@s] = clone("prontera",155,155,"NpcName::OnEvent",.charList[.@s]);
	}
end;
OnEvent:
	for(.@i=0;.@i<getarraysize(.mobList);.@i++){
		if(.mobList[.@i] && !unitexists(.mobList[.@i])){
			//the monster has been found.
			
			//we save it.
			.@charID = .charList[.@i];
			.@mobID = .mobList[.@i];
			
			//we delete it from the array.
			deletearray .charList[.@i],1;
			deletearray .mobList[.@i],1;
			
			//we break out.
			break;
		}
	}
	
	//now we have the here .@charID = the player id , .@mobID = the monster gid
	debugmes "" + .@charID;
	debugmes "" + .@mobID;
	

 

Edited by sader1992
  • Upvote 1

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