ID:147478
![]() May 7 2004, 4:00 pm
|
|
I am working on a game that will have extensive pet controls, in fact the game is all based around controling and taking care of your pet, with much to do and interact with other player pets. But I keep pondering this question. When I put the game online I have a bad feeling that every user will have control over other peoples pets. I do no want this obviously, so how would I define each pet to each user. I have an idea of how it should be done, but how do I code it. All help is appreciated...^_^
|
wow, yeah thats probably newbie central material, but all you do is have a variable that the pet holds, that contains your key, then when the commands are executed on the pet, have it check to make sure your its owner.
|
Sorry, you know what, i didnt even relize that, didnt know there was a newby section. And Masterdan, that is exactly what i thought, but wasnt sure if it would work, thank you. Feel free to move this post wherever, or close it since it was answered, that was fast...sweet!
|
simple enough...
just make sure every time you try to do something with the pet it checks to see if (src.owner==M.owner) (assuming M is the pet and src is you) and when you create the pet, and the new player, make sure to have owner=src.ckey |
Masterdan wrote:
wow, yeah thats probably newbie central material, but all you do is have a variable that the pet holds, that contains your key, then when the commands are executed on the pet, have it check to make sure your its owner. That's an awful way of doing things. Because, that means you have to use a loop to make it do any actions. Use references instead. mob |
I am a little confused by the code you posted Goku72. If you wouldn't mind explaining it to me, or putting comments in, that would be great. I understand the idea, you are putting in if statements as checks to make sure the user giving the commands has control over the pet. Correct? Sorry, but I am a n00b at DM, and I am still getting used to it. But I am glad you people are taking the time to help me, I greatly appreciate it. ^_^
|
Well, the way I would do it is have a var on the pet named owner. Now owner will equal the name of the owner, like src.name, or whatever *. the owner is. When you give it a command, do a check like if(M.name==src.owner). Why do it like this? I dont know, it is just a simple way to do it.
|
Do you have a code? If not, this belongs in Newbie Central.