ID:147478
 
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...^_^
AdhesiveMAN wrote:
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...^_^

Do you have a code? If not, this belongs in Newbie Central.

In response to SSJ4_Gohan_Majin
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.
In response to Masterdan
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

In response to Masterdan
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
Write(savefile/F)
..()
F["icon"]<<null
Read(savefile/F)
..()
src.icon=new(initial(src.icon))
proc
Death(mob/Killer)
var
health=100
maxhealth=100
ko=0
pets
var
tmp
mob
player
Owner
proc
Attack(mob/Attacked)
if(Attacked)
Attacked.health=min(max(Attacked.health-src.strength,0),Attacked.maxhealth)
puppy
Attack(mob/Attacked)
..()
Attacked<<"<b>[src.name] attacks you!</b>"
if(!src.health)
spawn(1)
if(Attacked)
Attacked.Death(src)
Death(mob/Killer)
if(!src.ko)
if(src.health<=0)
if(src.Owner)
if(Killer)
src.Owner<<"<b>[Killer.name] killed your pet!</b>"
del(src)
player
var
pets
Pet
Login()
..()
if(src.Pet)
src.Pet.Owner=src
Move()
if(src.Pet)
step_to(src.Pet,src,0)
return ..()
proc
Attack(mob/Attacked)
if(src.Pet)
while(src.Pet&&Attacked&&(Attacked in oview(1,src.Pet))
if(Attacked&&src.Pet&&(Attacked in oview(1,src.Pet)))
sleep(src.Pet.Attack(Attacked))
In response to Goku72
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.