Jump to content
  • 0

Can Bind commands can have like delay use when hit?


Question

Posted

example i do have @mall bindcmd can this have like cant use when your being hit by monsters on in PK maps??

coz as far as i know the only commands can have this are the @go/warp/jump 

thnx for hel appreciate it

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

Here's one solution:

In script.inc. Add this function at the end of the file:

BUILDIN_FUNC(logout_tick)
{
	TBL_PC *sd;
	if (!script_rid2sd(sd)) {
		script_pushint(st, -1);
		return SCRIPT_CMD_FAILURE;
	}
	if (sd->canlog_tick == 0)
		script_pushint(st, 0);
	else
		script_pushint(st, DIFF_TICK(gettick(), sd->canlog_tick));
	return SCRIPT_CMD_SUCCESS;
}

in script_def.inc. Add this line at the end of the file:

BUILDIN_DEF(logout_tick, ""),

Then recompile your server.

This script command will check for the same timer used to check if a player can log out or not. Basically it returns how many milliseconds ago was the character in combat.

Example usage:

-	script	testscript	-1,{
OnInit:
	bindatcmd("testcmd", strnpcinfo(3)+"::OnAtCmd");
	end;

OnAtCmd:
	.@tick = logout_tick();
	dispbottom "You have been in combat "+.@tick/1000+" seconds ago.";
	if(.@tick >= 5000 || .@tick == 0)
		dispbottom "Command used successfully!";
	else 
		dispbottom "You cannot use this command if you have been in combat during the last 5 seconds.";
	end;
}

Result:

413241325.thumb.png.1db414ecc14ff936060e491d3a29147b.png

Edited by Mastagoon
  • Upvote 1
  • 0
Posted
10 hours ago, Mastagoon said:

Here's one solution:

In script.inc. Add this function at the end of the file:


BUILDIN_FUNC(logout_tick)
{
	TBL_PC *sd;
	if (!script_rid2sd(sd)) {
		script_pushint(st, -1);
		return SCRIPT_CMD_FAILURE;
	}
	if (sd->canlog_tick == 0)
		script_pushint(st, 0);
	else
		script_pushint(st, DIFF_TICK(gettick(), sd->canlog_tick));
	return SCRIPT_CMD_SUCCESS;
}

in script_def.inc. Add this line at the end of the file:


BUILDIN_DEF(logout_tick, ""),

Then recompile your server.

This script command will check for the same timer used to check if a player can log out or not. Basically it returns how many milliseconds ago was the character in combat.

Example usage:


-	script	testscript	-1,{
OnInit:
	bindatcmd("testcmd", strnpcinfo(3)+"::OnAtCmd");
	end;

OnAtCmd:
	.@tick = logout_tick();
	dispbottom "You have been in combat "+.@tick/1000+" seconds ago.";
	if(.@tick >= 5000 || .@tick == 0)
		dispbottom "Command used successfully!";
	else 
		dispbottom "You cannot use this command if you have been in combat during the last 5 seconds.";
	end;
}

Result:

413241325.thumb.png.1db414ecc14ff936060e491d3a29147b.png

thnx a lot man 

  • 0
Posted (edited)
On 5/12/2021 at 9:38 AM, Mastagoon said:

Here's one solution:

In script.inc. Add this function at the end of the file:


BUILDIN_FUNC(logout_tick)
{
	TBL_PC *sd;
	if (!script_rid2sd(sd)) {
		script_pushint(st, -1);
		return SCRIPT_CMD_FAILURE;
	}
	if (sd->canlog_tick == 0)
		script_pushint(st, 0);
	else
		script_pushint(st, DIFF_TICK(gettick(), sd->canlog_tick));
	return SCRIPT_CMD_SUCCESS;
}

in script_def.inc. Add this line at the end of the file:


BUILDIN_DEF(logout_tick, ""),

Then recompile your server.

This script command will check for the same timer used to check if a player can log out or not. Basically it returns how many milliseconds ago was the character in combat.

Example usage:


-	script	testscript	-1,{
OnInit:
	bindatcmd("testcmd", strnpcinfo(3)+"::OnAtCmd");
	end;

OnAtCmd:
	.@tick = logout_tick();
	dispbottom "You have been in combat "+.@tick/1000+" seconds ago.";
	if(.@tick >= 5000 || .@tick == 0)
		dispbottom "Command used successfully!";
	else 
		dispbottom "You cannot use this command if you have been in combat during the last 5 seconds.";
	end;
}

Result:

413241325.thumb.png.1db414ecc14ff936060e491d3a29147b.png

@Mastagoon sir this is the script that im going to use regarding the bindcommand

-	script	maintown	-1,{
OnInit:
	bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
if(gettimetick(2) < cooldowntime) {
        dispbottom "Please wait "+(cooldowntime - gettimetick(2))+" seconds.";
    	end;
    }

	atcommand "@warp alexandria 158 144";
    set cooldowntime, gettimetick(2) + 10;
	end;
}

where should i put the script?

heres what i made

-	script	maintown	-1,{
OnInit:
	bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
.@tick = logout_tick();
	dispbottom "You have been in combat "+.@tick/1000+" seconds ago.";
	if(.@tick >= 5000 || .@tick == 0)

		atcommand "@warp alexandria 158 144";	
	else 
		dispbottom "You cannot use this command if you have been in combat during the last 5 seconds.";
	
	end;
}

thanks again in advance

Edited by AinsLord
more info

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