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.