Fou-lu 7 Posted October 8, 2015 I would like to detect when a player leaves a map through the return when he dies. Quote Share this post Link to post Share on other sites
0 mleo1 36 Posted October 8, 2015 attach timer and dieevent? Quote Share this post Link to post Share on other sites
0 Fou-lu 7 Posted October 8, 2015 (edited) DieEvent no good 'cause the player can be revived and not exit the map, in my case I want to detect the moment he presses the button to go back to the last save. Edited October 8, 2015 by Pedroooo Quote Share this post Link to post Share on other sites
0 Emistry 145 Posted October 8, 2015 some random idea. OnPCDieEvent: .@map$ = strcharinfo(3); if ( .@map$ == "prontera" ) { while ( strcharinfo(3) == .@map$ ) sleep2 1000; announce strcharinfo(0)+" has died and back to Save Points.",bc_all; } end; can be done with various way .... like using this way too OnCheck: if ( strcharinfo(3) != "prontera" ) { announce strcharinfo(0)+" has died and back to Save Points.",bc_all; }OnPCLoadMapEvent: deltimer strnpcinfo(0)+"::OnCheck"; if ( strcharinfo(3) == "prontera" ) addtimer 5000,strnpcinfo(0)+"::OnCheck"; end; Quote Share this post Link to post Share on other sites
0 Winterfox 83 Posted October 8, 2015 @@Emistry The first won't work. Leaving the map would reset the script and the part after the loop would never get executed. The second should work, but it is pretty unrealistic since i guess he wants this function global. For OnPCLoadMapEvent you need to add it via Mapflag to all maps which would produce a high server load and some other changes would be required to make it possible at all. Quote Share this post Link to post Share on other sites
0 Fou-lu 7 Posted October 8, 2015 (edited) I had a different idea inspired by the first example. The Hp is to check if the player is still dead and attachrid is for the script to continue running even with the player moving map and OnPCLogoutEvent is to log out case. With this together and the mapflag of noreturn and nowarp think there's no way the player leave the map without being checked by the script. OnPCDieEvent: .@map$ = strcharinfo(3); .@char = getcharid(0); if ( .@map$ == "prontera" ) { while ( strcharinfo(3) == .@map$ && !Hp) { sleep 1000; if (isloggedin(.@char)) attachrid(.@char); else break; } if (isloggedin(.@char) && strcharinfo(3) != .@map$) announce strcharinfo(0)+" has died and back to Save Points.",bc_all; } end;OnPCLogoutEvent: if ( .@map$ == "prontera" ) { if (!Hp) announce strcharinfo(0)+" has died and Logout.",bc_all; else announce strcharinfo(0)+" has Logout.",bc_all; } end; Edited October 9, 2015 by Pedroooo Quote Share this post Link to post Share on other sites
0 Winterfox 83 Posted October 9, 2015 @@Pedroooo The problem isn't the that you loose the rid, the problem is that the script gets completly unloaded and loaded again. Quote Share this post Link to post Share on other sites
0 Emistry 145 Posted October 9, 2015 @@Emistry The first won't work. Leaving the map would reset the script and the part after the loop would never get executed. The second should work, but it is pretty unrealistic since i guess he wants this function global. For OnPCLoadMapEvent you need to add it via Mapflag to all maps which would produce a high server load and some other changes would be required to make it possible at all. it work fine in my Hercules test server. Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted October 27, 2015 if you just want to execute an npc when player press that respawn button (Return to last save point) then you have to do source modification plugin #include "common/hercules.h"#include <stdio.h>#include <string.h>#include <stdlib.h>#include "map/pc.h"#include "map/npc.h"#include "common/HPMDataCheck.h"HPExport struct hplugin_info pinfo = { "OnPCRespawnEvent", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated)};void pc_respawn_post( struct map_session_data* sd, clr_type clrtype ) { struct npc_data *nd = npc->name2id("OnPCRespawnEvent"); if ( !nd ) { ShowError( "OnPCRespawnEvent not found !" ); return; } script->run( nd->u.scr.script, 0, sd->bl.id, nd->bl.id ); return;}HPExport void plugin_init (void) { addHookPost( "pc->respawn", pc_respawn_post );}and write a script as it were executed like MOTD ...- script OnPCRespawnEvent FAKE_NPC,{ unittalk getcharid(3), "I'm ALIVE !!!"; end;OnPCDieEvent: unittalk getcharid(3), "I'm dead ..."; end;}.. however if you are actually writing an event script, such as instance script remember there are other checks to make sure the event run smoothly eg: warpping, log out ... etc etc Quote Share this post Link to post Share on other sites
I would like to detect when a player leaves a map through the return when he dies.
Share this post
Link to post
Share on other sites