Jump to content
  • 0
Sign in to follow this  
Fou-lu

Is this possible?

Question

8 answers to this question

Recommended Posts

  • 0

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 by Pedroooo

Share this post


Link to post
Share on other sites
  • 0

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;

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0
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 by Pedroooo

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites

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

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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