AngelaKiss Posted July 4, 2016 Posted July 4, 2016 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 Quote
0 _Okuz_ Posted July 8, 2016 Posted July 8, 2016 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! 1 Quote
0 _Okuz_ Posted July 4, 2016 Posted July 4, 2016 (edited) 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 July 4, 2016 by _Okuz_ 1 Quote
0 AngelaKiss Posted July 6, 2016 Author Posted July 6, 2016 thank it is working but it keeps spamming the skill and the messange even when the homun is rest Quote
0 _Okuz_ Posted July 6, 2016 Posted July 6, 2016 (edited) 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 July 6, 2016 by _Okuz_ 1 Quote
0 AngelaKiss Posted July 8, 2016 Author Posted July 8, 2016 Yey it works, also last thing would it be possible to get disable in towns? or restricted 7 Quote
0 spinzaku Posted July 8, 2016 Posted July 8, 2016 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 Quote
0 AngelaKiss Posted July 8, 2016 Author Posted July 8, 2016 It is just perfect now. I dont see any other way to get it better thank you for all. I really appreciate it Quote
Question
AngelaKiss
up plz
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.