AFK Homunculus

Angela

New member
Messages
30
Points
0
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;
}
 
 
by the way here in hercules we have the "checkidle" script command that would be as useful as checking with getmapxy

 
Can't test it right now, but this should do the job

- script vaporize -1,{

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

On1min:
if(gethominfo(2) != "null"){
if(getidle() >= $antiafk) {
atcommand "@useskill 244 1 "+strcharinfo(0);
dispbottom "You are not allowed to farm with Homun while AFK.";
addtimer 60000,strnpcinfo(0)+"::On1min";
}
}
addtimer 60000,strnpcinfo(0)+"::On1min";
end;

OnInit:
set $antiafk, 120;// how many seconds to use vaporize
end;
}



 

 
Can't test it right now, but this should do the job

- script vaporize -1,{

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

On1min:
if(gethominfo(2) != "null"){
if(getidle() >= $antiafk) {
atcommand "@useskill 244 1 "+strcharinfo(0);
dispbottom "You are not allowed to farm with Homun while AFK.";
addtimer 60000,strnpcinfo(0)+"::On1min";
}
}
addtimer 60000,strnpcinfo(0)+"::On1min";
end;

OnInit:
set $antiafk, 120;// how many seconds to use vaporize
end;
}



 
Need this script,too.

But your script give this error:

Code:
[ERROR]: npc_parsesrcfile: Unknown syntax in file 'antiafk.txt', line '1'. Stopping...
* w1=- script vaporize -1,{
* w2=
* w3=
* w4=
 
Generally, this error is due to space used instead of tabs.

Type "-<tab>script<tab>vaporize<tab>-1,{"

 
Generally, this error is due to space used instead of tabs.

Type "-<tab>script<tab>vaporize<tab>-1,{"
OK. Now it says

Code:
scirpt error in file 'afk.txt' line 9 column 13 parse_simpleexpr: unmatched ')'
...
...
9: if(getidle() >=$antiakf) {
...
...
...
 
Here's an updated version without global variables and a simplified flow:

Code:
-	script	vaporize	-1,{
	 
	OnPCLoginEvent:
		// Set AFK check on login
		addtimer 60000, strnpcinfo(0) + "::On1min";
		end;
	 
	On1min:
		// Check if player has Homunculus and if AFK longer than allowed
		if(gethominfo(2) != "null" && checkidle() >= .vaporize) {
			atcommand "@useskill 244 1 " + strcharinfo(0);
			dispbottom "You are not allowed to farm with Homunculus while AFK.";
		}
		
		// Reset AFK check
		addtimer 60000, strnpcinfo(0) + "::On1min";
		end;
		
	OnInit:
		// Time (in seconds) before vaporizing
		.vaporize = 120;
		end;
}
 
Last edited by a moderator:
Back
Top