Welcome to MaxCheaters.com

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

  • 0

Help dont allow player to summon more than 1 npc at time


Go to solution Solved by girogius,

Question

Hi, i have npc buffer which can be summoned with skill. problem is player can summon how many he wants at same time.

how can i fix it? if already summoned one buffer need to disable skill or something to prevent summon second buffer.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • Solution

I did not get answer here so I found little trick, maybe there is better ways I don't know.

 

I needed to know if player have already summoned one NPC or not, I needed 1 property from players creature data, I used summoner_id for it because I don't think server will use this property,

player don't have summoner right? so we can store summoned NPCs id temporary there. inside CREATED event i added this:

 

if(myself.sm.master.summoner_id != 0){
            SendScriptEventEx(GetCreatureFromID(myself.sm.master.summoner_id),0,0,-7);
            myself.sm.master.summoner_id = myself.sm.id;
            
        }
        else{
            myself.sm.master.summoner_id = myself.sm.id;
        }

 

 

checking if masters.summoner_id != 0 then it = that summoned NPC id which means player already have one NPC buffer summoned so I decided to unsummon old one and summon new,

 

I get creatureData of old NPC buffer and send script event  with -7, you can send whatever you want:

this part > SendScriptEventEx(GetCreatureFromID(myself.sm.master.summoner_id),0,0,-7);

 

and implemented SCRIPT_EVENT listener in buffer NPC ai

EventHandler SCRIPT_EVENT(script_event_arg1, script_event_arg2, script_event_arg3) {
		if (script_event_arg3 == -7) {
			Despawn();
		}
	}

 

if NPC will receive script event in my case with -7 it will despawn.

 

thats it when player will use skill that summons this NPC, if player already have one summoned old will dissapear and new will be summoned.

 

don't forget to set myself.sm.master.summoner_id = 0;

to 0 again when unsummoning NPC by yourself, to be able summon NPC again...

don't worry if player go offline when player restarts master.summoner_id will be 0 again.

 

 

Admin Lock it.

 

 

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.