XuN   
		
			Sphere Developer 
			      
			
			 
			
	Posts: 852 
	Likes Given: 102
 
Likes Received: 156 in 119 posts 
	Joined: Jul 2013
	
 Reputation: 30
  
			
 ![]()  
		
	 | 
	
		
			
RE: ethy's 
			 
			
				You will need to store a tag on the eth item setting to it the serv time when created, transfer it to the mount when mounting and transfering it back to the item when dismounting. 
The tag would store the <serv.time>, which uses tenths of second to handle the time, hence you will have to convert them to seconds to use the timerf functions. 
Timerf gets destroyed when the item is deleted, and this happens each time you mount/dismount for both eth item and the mounted npc, so I would add a function and call it when the mount NPC is being dismounted:
 
Code: 
 [function f_eth_timeout] 
//argn raw timer 
if (<argn>==0) // no previous timer 
 tag.timeout = <eval 60*60*24*30> 
else 
 tag.timeout = <argn1> 
endif 
if (<tag.timeout> < <serv.time>) 
 remove 
 return 1 
endif 
timerf remove,<eval <tag.timeout>/10>
  
Then you must call the function on the newly created item or npc (after serv.newitem=xx or serv.newnpc=xx) with this line: new.f_eth_timeout <tag0.timeout>
			  
			
			
			
		 |  
	 
 | 
	| 05-28-2016 06:06 PM | 
	
		
	 | 
	
	
		   
		 
		
	 | 
	
		
		miltonvo   
		
			Apprentice 
			  
			
			 
			
	Posts: 9 
	Likes Given: 0
 
Likes Received: 0 in 0 posts 
	Joined: May 2016
	
 Reputation: 0
  
			
 ![]()  
		
	 | 
	
		
			
RE: ethy's 
			 
			
				 (05-28-2016 06:06 PM)XuN Wrote:  You will need to store a tag on the eth item setting to it the serv time when created, transfer it to the mount when mounting and transfering it back to the item when dismounting. 
 
The tag would store the <serv.time>, which uses tenths of second to handle the time, hence you will have to convert them to seconds to use the timerf functions. 
Timerf gets destroyed when the item is deleted, and this happens each time you mount/dismount for both eth item and the mounted npc, so I would add a function and call it when the mount NPC is being dismounted: 
 
Code: 
 [function f_eth_timeout] 
//argn raw timer 
if (<argn>==0) // no previous timer 
 tag.timeout = <eval 60*60*24*30> 
else 
 tag.timeout = <argn1> 
endif 
if (<tag.timeout> < <serv.time>) 
 remove 
 return 1 
endif 
timerf remove,<eval <tag.timeout>/10>
  
 
Then you must call the function on the newly created item or npc (after serv.newitem=xx or serv.newnpc=xx) with this line: new.f_eth_timeout <tag0.timeout> 
so the player can buy more than one eth, so how can i implement this? i ll paste part of script:
 
This is when a player bought the eth:
 
Code: 
 src.newitem i_et_bear 
    src.newitem  
    src.act.bounce
  
some eths that player can buy:
 
Code: 
 [ITEMDEF i_et_llama] 
ID=i_pet_llama 
NAME=Ethereal llama 
TYPE=t_eth 
tdata1=c_llama 
 
ON=@Create 
color=078ff 
ATTR=04 
 
[ITEMDEF i_et_bear] 
ID=i_pet_bear_polar 
NAME=Polar Bear 
TYPE=t_eth 
tdata1=c_bear_polar 
 
ON=@Create 
ATTR=04
  
This is the function of eth system:
 
Code: 
 [function bodyhex]    //this function returns the body in hex format to be able to read the mount's defnames in sphere_defs.scp (mount_0x444 in example) 
local.body=<hval <body> & 0ffff> 
local.len=<eval STRLEN(<local.body>)> 
return 0x<strsub 1 <dlocal.len> <local.body>> 
 
 
[typedef t_eth] 
//This typedef handles almost all of the Ethereal's behaviour 
on=@Dclick 
local.id=<qval <tdata1>?<tdata1>:<tag0.ethid>>    //check for the source, a normal ethereal or a mount cloner 
if <local.id>    //If a id is received then the code proceed 
    IF !((<SRC.Body>==c_man) || (<SRC.Body>==c_woman) || (<SRC.Body>==c_elf_male) || (<SRC.Body>==c_elf_female))    //Only humans and elfs can mount, if you have humanoids races add them here. 
        SRC.SysMessage=<defmsg.msg_mount_unable> 
        Return 1 
    Else 
        serv.newnpc=<local.id>    //When ridding it, a real NPC with this ID is created 
        new.tag.eth=<baseid> 
        new.color=<color> 
        if (<tag0.ethid>)        //If it's a cloner it have this tag, we transfer it to the npc to retrieve it back later. 
            new.tag.etglobal=<tag.ethid> 
        endif 
        new.tag.color=<color> 
        ref1=<new> 
        serv.newitem=i_memory    //A memory_ipet is given to the NPC, so the player can ride it. 
        new.color=memory_ipet 
        new.link=<src> 
        new.cont=<ref1> 
        ref1.mount=<src>        //this function does dismount you if needed, hence I didn't check it before. 
        src.events +e_ridding_eth    //This event handle the @Dismount, the rest of the script 
        remove 
    Endif 
else 
    serv.log Problems with <uid> (<name>) [t_eth] no tdata1 nor tag.ethid. 
    return 1 
ENDIF 
return 1 
 
on=@DropOn_Ground    //A simple quick fix to avoid players to drop their Ethereals by accident. 
cont=<src.findlayer.21> 
if (<tag0.ethid>) 
    dispid=<serv.chardef.<tag.ethid>.icon> 
    update 
endif 
return 1 
 
ON=@AfterClick        //A message when clicking the ethereal to avoid scam in trades 
local.clickmsghue=0480 
local.clickmsgtext=You see a real <name> 
 
[events e_ridding_eth] 
ON=@Dismount 
events -e_ridding_eth    //The event is removed in first place, to avoid possible problems later 
ref1=<argo> 
if (<ref1.tag0.eth>)    //However a double check is done to ensure that the mount is a Ethereal one 
    serv.newitem=<ref1.tag.eth> 
     
    new.color=<ref1.color> 
    if (<ref1.tag0.etglobal>) 
        new.tag.ethid=<ref1.tag.etglobal> 
        new.dispid=<ref1.icon> 
    endif 
    new.cont=<findlayer.21> 
    findlayer.25.remove 
    return 1 
endif 
 
[ITEMDEF i_et_global] 
ID=i_pet_horse_brown_dk 
NAME=Mount Cloner 
TYPE=t_eth 
 
ON=@Create 
color=078ff 
ATTR=04 
 
on=@DropOn_Char 
if (<def0.mount_<argo.bodyhex>>) 
 tag.ethid=<argo.baseid> 
 name=Mount Cloner (<argo.name>) 
 color=<argo.color> 
 dispid=<argo.icon> 
 update 
else 
 src.sysmessage That cannot be mounted. 
endif 
return 1
  
			 
			
			
			
		 |  
	 
 | 
	| 06-03-2016 06:01 AM | 
	
		
	 | 
	
	
		   
		 
		
	 |