ID:145601
 
obj
cloak
name = "Cloak 10000"
var/power = 10000
icon = 'icon.dmi'
icon_state = "cloak"
verb
cloak()
set category = null
if(usr.invisibility == 0)
if(src.power >= 7499)
usr.invisibility = 1
src.power -= 7500
src.name = "Cloak [src.power]"
src.icon_state = "cloak on"
usr.see_invisible = 1
new/obj/View(usr.client)
else
usr.invisibility = 0
src.icon_state = "cloak"
usr.see_invisible = 0
for(var/obj/View/O in usr.client.screen)
del O


I need to find a way to make it so you cant see other people that are cloaked when you cloak. I would also like for it to constantly drain the power slowly and go off when the power is zero.

Well, see_invisible will not do what you want. If you still want to see yourself, you need either mob.sight|=SEE_SELF, or to use an /image.

Lummox JR
In response to Lummox JR
ty and how to make the power drain slowly?
In response to Turishi
obj/cloak
blbalbalbalbalaba
verb/cloak()
bblabalbal
src.drain()

obj/proc/drain()
if(src.power>=50)
src.power-=5
src.name=src.power
sleep(10)
src.drain


Of course, you could also use a while loop. But I think this is easier to understand.
In response to Mysame
Mysame wrote:
> obj/cloak
> blbalbalbalbalaba
> verb/cloak()
> bblabalbal
> src.drain()
>
> obj/proc/drain()
> if(src.power>=50)
> src.power-=5
> src.name=src.power
> sleep(10)
> src.drain

Of course, you could also use a while loop. But I think this is easier to understand.

It's also fantastically wrong. For one thing, you have a glaring syntax error on the last line; it should be drain(). For another, you're supposed to spawn() that, not just sleep(). A proc should not just call itself over and over and over without spawning; that's called recursion. If you just call it the normal way, the old version of the proc waits for the new one to finish and give it a result.

Of course, this also overlooks the fact that no check was ever done as to whether the cloak was removed, so it'll keep draining forever. Nor does it actually do anything when the power drains to a certain point.

Lummox JR
In response to Lummox JR
Because I have no idea how he ends his Cloak. Still thanks for the hints, didn't know that.
In response to Mysame
Mysame wrote:
Because I have no idea how he ends his Cloak. Still thanks for the hints, didn't know that.

Well the fact that you didn't know that is basically a strong indicator that you're not yet in a position to be offering code help for anybody. You've offered a lot of questionable or outright wrong advice here; you need to learn more yourself first.

Lummox JR