Jump to content
  • 0

AFK Homunculus


AngelaKiss

Question


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.01
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

Hello guys, i cant make this script work. it suppost that if you are afk with the homun for 2 minutes it uses vaporize to avoid farm 
 
 
- script vaporize -1,{


OnPCLoginEvent:
addtimer 60000,strnpcinfo(0)+"::On1min";
end;


On1min:
dispbottom "Been a minute "+strcharinfo(0);
atcommand "@useskill 244 1 "+strcharinfo(0);
getmapxy(.@m,.@x,.@y,0);
if(.@x == x && .@y == y){
set afk, afk + 1;
if(gethominfo(2) != "null"){
if(afk >= $antiafk) {
atcommand "@useskill 244 1 "+strcharinfo(0);
dispbottom "You are not allowed to farm with Homun while AFK.";
addtimer 60000,strnpcinfo(0)+"::On1min";
end;
} else { 
set afk, 0; 
addtimer 60000,strnpcinfo(0)+"::On1min";
end;
}
addtimer 60000,strnpcinfo(0)+"::On1min";
end;
}
}
set x, .@x;
set y, .@y;
addtimer 60000,strnpcinfo(0)+"::On1min";
end;
OnInit:
set $antiafk, 2;// how many minutes to use vaporize
end;
}

up plz

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Hello again AngelaKiss! =]

Let's move to the next challenge: restrict in towns. We need an extra validation to check if the player's map have or not the mf_town mapflag, this mapflag tells to the -map-server that the flagged map is a town.

Change this:

if (checkhomcall() == 0 && (checkidle() / 60 >= .vaporize)) {

To this:

if (checkhomcall() == 0 && (checkidle() / 60 >= .vaporize) && !getmapflag(strcharinfo(3),mf_town)) {

The final script must be like this:
 

-	script	AFK_Vaporizer	-1,{

OnPCLoginEvent:
	initnpctimer getcharid(3);
	end;
 
OnTimer60000:
	if (checkhomcall() == 0 && (checkidle() / 60 >= .vaporize) && !getmapflag(strcharinfo(3),mf_town)) {
		atcommand "@useskill 244 1 "+strcharinfo(0);
		dispbottom "You are not allowed to farm with Homun while AFK.";
	}
	initnpctimer getcharid(3);	
	end;
 
OnInit:
	set .vaporize, 2; // How many minutes to use vaporize.
}

Thanks,
C ya!

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Hello AngelaKiss how are you? =]
 
I rewrote this whole script with a new logic and I tested it on haru.ws/scriptchecker/ to check for sintax errors and nothing was found, please tell me if it fits your needs.

-	script	AFK_Vaporizer	-1,{

OnPCLoginEvent:
	initnpctimer getcharid(3);
	end;

OnTimer60000:
	if (gethominfo(2) != "null" && (checkidle() / 60 >= .vaporize)) {
		atcommand "@useskill 244 1 "+strcharinfo(0);
		dispbottom "You are not allowed to farm with Homun while AFK.";
	}
	initnpctimer getcharid(3);	
	end;

OnInit:
	set .vaporize, 2; // How many minutes to use vaporize.
}

 

checkidle({"<Player Name>"})


Returns the time, in seconds, that the specified player has been idle.
Name is optional, and defaults to the attached player if omitted.

 

I hope it works, good luck.

Edited by _Okuz_
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.01
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

thank it is working but it keeps spamming the skill and the messange even when the homun is rest

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Hmmm that's because we're checking if the player is in idle state, not the homunculus. Honestly, I don't know what makes a player being in idle state and moreover how to revert that state. Now, the first script is intended to check player's position (x and y) every minute and if any player is in the same position for more than 2 minutes they are considered as AFK.

I think the solution is to change from gethominfo(2) != null to checkhomcall() == 0.
 

*checkhomcall()

 
This function checks if the attached player's Homunculus is active,
and will return the following values:
 -1: The player has no Homunculus.
  0: The player's Homunculus is active.
  1: The player's Homunculus is vaporized.
  2: The player's Homunculus is in morph state.
 
---------------------------------------
 
*gethominfo(<type>{,<char_id>})
 
This function will return Homunculus information for the Homunculus of the
invoking character, regardless of its vaporize state. It returns zero or
"null" if the player does not own a Homunculus.
 
Valid types are:
 0 - Homunculus ID
 1 - Homunculus Class
 2 - Homunculus Name
 3 - Homunculus friendly level (intimacy score). 100000 is full loyalty.
 4 - Homunculus hungry level. 100 is completely full.
 5 - Homunculus rename flag. 0 means this homunculus has not been named yet.
 6 - Homunculus level
 7 - Homunculus Game ID

 

So, the final script should be something like this:

-	script	AFK_Vaporizer	-1,{

OnPCLoginEvent:
	initnpctimer getcharid(3);
	end;

OnTimer60000:
	if (checkhomcall() == 0 && (checkidle() / 60 >= .vaporize)) {
		atcommand "@useskill 244 1 "+strcharinfo(0);
		dispbottom "You are not allowed to farm with Homun while AFK.";
	}
	initnpctimer getcharid(3);	
	end;

OnInit:
	set .vaporize, 2; // How many minutes to use vaporize.
}

Now only players with active homunculus (checkhomcall() == 0) will be checked by our code.

Let me know if it works, c ya!

Edited by _Okuz_
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.01
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

Yey it works, also last thing would it be possible to get disable in towns? or restricted 7

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  79
  • Reputation:   6
  • Joined:  04/20/16
  • Last Seen:  

Afk homun is legal in official servers. In private server just disable autoloot for homun... In official ders no autoloot. This is what made it unfair.. With autoloot off for homun. They cant go completely afk since cant loot

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.01
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

It is just perfect now. I dont see any other way to get it better :) thank you for all. I really appreciate it

Link to comment
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.   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.

×
×
  • Create New...