SphereCommunity
How to remove key when redeed ship? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: How to remove key when redeed ship? (/Thread-How-to-remove-key-when-redeed-ship)



How to remove key when redeed ship? - WRWR - 05-08-2012 02:53 AM

How to remove key when redeed ship?
Code:
IF !(<src.gold> >= <eval <link.value>/10>) && !(<SRC.ISGM>)
src.sysmessage You don't have enough money.
ELSE
src.gold -= <eval <link.value>/10>
serv.newitem=i_deed_ship
new.more=<link.baseid>
new.name=<link.name> deed
new.bounce
link.remove
ENDIF



RE: How to remove key when redeed ship? - Shaklaban - 05-08-2012 03:22 AM

you can hold keys uids on a tag with ship under @create trigger of keys and remove them on dry dock like:

PHP Code:
[itemdef i_key_copper]
on=@create
timerf 1
,mark_ship

[function mark_ship]
ref1=<more1>
if !(<
ref1.type> = t_ship)
    return 
1
endif
for 
1 2
    
if (<ref1.tag0.key_<eval <local._for>>> = 0)
        
ref1.tag0.key_<eval <local._for>>=<uid>
        return 
1
    
endif
endfor    

[function 
deletekeys]
for 
1 2
    
if !(<tag0.key_<eval <local._for>>> = 0)
        
ref1=<tag0.key_<eval <local._for>>>
        if (<
ref1.type> = t_key)
            
ref1.remove
        
endif
    endif
endfor 



RE: How to remove key when redeed ship? - WRWR - 05-08-2012 03:26 AM

Keys is linked to REGION.UID and if i remove ship and save sphere my console says:
Code:
ERROR:'copper key' Bad Link to 040001de2
ERROR:UID=040001ddb, id=0100e 'copper key', Invalid code=2205 (Mislinked item)
how to fix it?


RE: How to remove key when redeed ship? - Shaklaban - 05-08-2012 04:57 PM

yeah they are linked and give an error on removal, it does not harm your server. but if you want to stop it you can look the example i gave you. i dont test it, its just an example. step by step its doing:

under @create trigger of copper key mark_ship function called with timerf 1. purpose of timerf is give sphere some time to assing key to ship.

mark_ship function stores uids of the keys on tag with ship.

on drydock, if you call deletekeys function on link reference (link.deletekeys), it will delete keys which uids stored on a tag with ship.

as i know there is no setting for this so you need to code it.


RE: How to remove key when redeed ship? - WRWR - 05-08-2012 09:47 PM

Thanks. its work and best way for me now


RE: How to remove key when redeed ship? - WRWR - 05-09-2012 09:36 PM

key from bank is not removing 0_o


RE: How to remove key when redeed ship? - Gyros - 05-09-2012 09:46 PM

Code:
[FUNCTION f_remove_keys]
forinstances i_key_copper
    if (<link>)
        if strmatch(*t_multi*,<link.type>)
            if (<link.more1> == <src>)
                link = -1
                remove
            endif
        endif
    endif
endfor

Code:
[FUNCTION shipkey_remove]
forinstances i_key_copper
    if (<more1>)
        if (<more1> == <args>)
            remove
        endif
    endif
endfor



RE: How to remove key when redeed ship? - WRWR - 05-10-2012 12:21 AM

error in if (<more1> == <args>)
how to use your script?
for example if i redeed my ship via dialog button?