![]() |
Putnpc clientside
What are the methods to place an NPC where only one client can see it. Basically im trying to display an NPC for one person, but others can not see or interact with it.
|
What I did in the past was assigned an account to an attribute. Then on the clientside, just have a check to see if the player is equal to the attribute. For better reliability though, it may be helpful to use a timeout script in case you plan on changing the attribute to another player. Hope this helps.
PHP Code:
|
Okay thanks for the suggestion. I still dont think it will fit my needs though. In short i am trying to make a shop, only display items to certain players. What players get displayed the shop items are based off of variables in a sql database(per individual player). The trouble im having is, when i place the npcs (putnpc2) and connect it to my item class, i am not able to access the clientdata(sql). I cannot triggeraction clientside from serverside, nor triggerClientside from server side in a putnpc2. I think i might be going about this wrong, but i dont see any better way, besides possibly using showimg.
|
My suggestion should work. Here, I will prove it to you.
I would add the putNPC2 in a weapon of some sort. PHP Code:
PHP Code:
|
It could be possible to just add a normal shop npc and when you click/grab it then it's opening a GUI. You would just need normal triggerclient() for that.
|
Quote:
|
Quote:
|
Quote:
|
Tim's method would work, but it still isn't ideal. In fact, I'd go so far as to say it's downright bad. Putnpc2's tend not to destroy 100% responsibly, so you'd need to code in redundant garbage collecting for them. That's also a lot of unnecessary nonsense.
Stefan/fp4 are right on the money here. The way you would do it is as follows: (in weapon) (on serverside): onplayerenters -> recognize shop level -> get NPC list from SQL DB -> triggerclient that info to the weapon (on clientside): onactionclientside -> the item list is a param -> use that item list to set up what NPCs the shop should be selling in the GUI or for the "laid out" npcs (more on that later) You could optionally remove it as a weapon NPC entirely and just make it a level NPC or DB NPC as follows: (serverside): onplayerenters -> retrieve what NPCs that player should have from an SQL DB -> save the list of those npcs to the player (eg, player.client.npcs) (clientside, in same level npc): onplayerenters -> timeout until the player.client.npcs flag is set -> once set, take that list of NPCs as the list of NPCs the player can buy -> you can stop timeout'ing now. The timeout should only occur 0-2 times, just long enough for the info to reach you from the server. -> clear the client. flag now, otherwise the flag will conflict next time you enter the level. Note: While using client. flag is obviously insecure, that shouldn't matter because purchasing the NPC will send a trigger to serverside, which, for security purposes, needs to verify (again) that the player is authorized to purchase that NPC, anyway. You said you want to lay out the items in the level itself, rather than using a GUI. That's a bit harder but still not impossible. For example: 1. Have ~10 generic "shop item" NPCs that haven't had their this.item defined yet (and they're invisible) in the level. I say "10" but you can use whatever you feel is the "limit" for NPCs. If it's going to sell 30 different NPCs, you can put 30. It doesn't matter. 2. Use the methods I discussed before (either or) to get your "list" (ie, string array) of NPC names. You can optionally pass icons as well, or the icons can be included in the clientside ahead of time, corresponding with names of course. 3. Do something like: "for (temp.npc: npcs) { if (npc.isItem && npc.itemName == nil) {" -- that will find NPCs that are those "invisible items" I told you about (as long as they have this.isItem = true; in their script) and will only define them to be an NPC if they haven't already been defined (assuming definition of this.itemName). An even slightly more efficient way of doing that would be for the "item" NPCs to load themselves into a level. array on created (in clientside), and then the #3 step can loop among something like "for (temp.npc: level.items) {" rather than looping over ALL level NPCs. Any of those methods would be greatly superior to using putnpc2. |
All times are GMT +2. The time now is 03:09 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.