ID:271410
 
obj
Pokeballs
Pokeball
icon = 'Objects.dmi'
icon_state = "Pokeball"
value = 100
verb
Get()
set src in oview(1)
usr.contents+=new/obj/Pokeballs/Pokeball
usr << "<b><font size = 1>You picked up [src]"
del(src)
verb
Drop()
src.Move(usr.loc)
verb
Throw_pokeball(var/mob/M)
set src in usr.contents
if(istype(usr,/mob/player/Trainer/))
if(istype(M,/mob/player/Pokemon))
if(!M.owner)
src.target = M
Move(usr.loc)
src.density = 1
walk_towards(src,M,6)
spawn(20)
if(prob(80))
src.icon_state = "Pokeball3"
sleep(10)
src.icon_state = "Pokeball2"
world << "[usr] has caught [M]!"
M.owner = "[usr]"
M.Caught = 1
M.nickname = input(usr,"What would you like to name the newly captured [M]","nickname",M.nickname)
usr.verbs += new/Pokeball/verb/Return_Pokemon
M.verbs += new/mob/Caught/Pokemon/verb/Abandon_Trainer()
if(M.nickname == "")
M.nickname = "[M.name]([M.owner])"
M.name = "[M.nickname]([M.owner])"
del(src)
else
view() << "[usr] fails to catch [M]"
del(src)
else
usr << "[M] is already caught"


I need help making a return code so that only the owner of the pokemon can return them back to thier pokeball,can someone please make a return code I already made one but it says that thats not my pokemon,when I check that pokemons owner through edit it says my name.Here is the return code I have right now(doesnt work,I thought it would be easy to code a return code but I guess not..)

mob
verb

/Pokeball/verb/
Return_Pokemon(mob/player/Pokemon/M in view())
if(M.owner == usr)
view() << "Return [M]"
M.loc=locate(3,3,3)
else
usr << "[M] is not your pokemon"
return
Element Hero creator wrote:
>           if(M.owner == usr)



instead of doing M.owner == usr

try it with usr == M.owner

This may work may not just a suggestion

In response to Black Wolf Production
no,didnt work..but thanks anyways
In response to Black Wolf Production
No, in fact, that may NOT work, and WILL never work, because the == operator is COMMUTATIVE. B == A if and only if A == B.

Now, as for the ACTUAL problem: You are setting owner to "[usr]", while checking if owner == usr. One is a text string, the other is a reference to a mob. Change "[usr]" to just usr.

On another note: be very careful when you have reference variables. If you save them, then it will ALSO save the mob they're referring to. This can cause savefiles to be lost when one saved version of a player overwrites another. This CAN be avoided by using "[usr]" in both cases, but that will ONLY work if you make absolutely sure that nobody can share names.
In response to Black Wolf Production
THANKS Garthor Ive had this problem for over a week,Thank you s much ^^.=)
In response to Element Hero creator
Would this problem be attempting to help people fix problems you yourself admit you are not able to fix?