+/** + * setvisibility <value>{, <"npc">} + * @param <value> the value to set it and checkf or + * @param <"npc"> if another NPC should be targetted +**/ +BUILDIN_FUNC(setvisibility) { + struct npc_data *nd = NULL; + + if (script_hasdata(st, 3)) { + nd = npc_name2id(script_getstr(st, 3)); + ShowWarning("buildin_setvisibility: NPC '%s' not found. Using active NPC.\n", script_getstr(st, 3)); + } + if (nd == NULL) + nd = map_id2nd(st->oid); + + nd->visibility = script_getnum(st, 2); + return 0; +} + +/** + * getvisibility {<"npc>"} + * @param <"npc"> if another NPC should be targetted +**/ +BUILDIN_FUNC(getvisibility) { + struct npc_data *nd = NULL; + + if (script_hasdata(st, 2)) { + nd = npc_name2id(script_getstr(st, 2)); + ShowWarning("buildin_getvisibility: NPC '%s' not found. Using active NPC.\n", script_getstr(st, 2)); + } + if (nd == NULL) + nd = map_id2nd(st->oid); + + script_pushint(st, nd->visibility); + return 0; +} + #include "../custom/script.inc"
// declarations that were supposed to be exported from npc_chat.c @@ -18648,6 +18685,8 @@ struct script_function buildin_func[] = { BUILDIN_DEF(vip_time,"i?"), #endif BUILDIN_DEF(bonus_script,"si???"), + BUILDIN_DEF(setvisibility, "i?"), + BUILDIN_DEF(getvisibility, "?"),
#include "../custom/script_def.inc"
* setvisibility <value>{, <"npc">}
* @param <value> the value to set it and checkf or
* @param <"npc"> if another NPC should be targetted
You set the value of the NPC to a value not 0. Only players with the character variable "npcvisibility" set to this exact value can now see the NPC. It should also not effect NPCs which have no visibility set, since it ignores the value zero. You have to put this into the OnInit event, since I didn't add a saving mechanism so it will be deleted once you reload. Thus the OnInit.
* getvisibility {<"npc>"}
* @param <"npc"> if another NPC should be targetted
**/
An example:
// Some NPC here OnInit: SetVisibility(1); End;
Only a player with the variable "npcvisibility" set to 1 can see the npc now.
Question
Hirasu
hey i need some help with a code from @Jonne
Only a player with the variable "npcvisibility" set to 1 can see the npc now.
my Script:
But i can see the npc with npcvisibility 0 or 1
(No Complie error || No server errors)
Can someone help me please?
Link to comment
Share on other sites
4 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.