im just wondering how to make it a 1 npc but all players can rent that npc.. its to waste of space if we duplicate the npc..
//Author Goddameit
//Version 2012/11/23
//Web http://bit.ly/MDuQ9F
- script DedicatedNPCMain -1,{
set .@type,atoi(strnpcinfo(2));
if( getd(".n_"+.@type+"_status") == 0 )
{
for(set .@i,1;.@i<=.amount;set .@i,.@i+1)
if( getd(".n_"+.@i+"_master") == getcharid(3) )
{
end;
}
mes "Hi, will you hire me?";
select("Yes");
set .@type,atoi(strnpcinfo(2));
setd ".n_"+.@type+"_status",1;
setd ".n_"+.@type+"_master",getcharid(3);
setd ".n_"+.@type+"_time",10;
setd ".n_"+.@type+"_name$",strcharinfo(0);
getmapxy(getd(".n_"+.@type+"_origin_map$"),getd(".n_"+.@type+"_origin_x"),getd(".n_"+.@type+"_origin_y"),1,strnpcinfo(0));
initnpctimer;
close;
}else
{
set .@type,atoi(strnpcinfo(2));
if( getd(".n_"+.@type+"_master") == getcharid(3) )
{
mes "Hi, any problem?";
switch(select("Storage","Repair all","Dismissal"))
{
case 1:
openstorage;
close;
case 2:
repairall;
close;
case 3:
callsub OnEndd;
close;
}
}else
{
end;
}
}
end;
OnPCLogoutevent:
callsub OnEndd;
end;
OnEndd:
set .@type,atoi(strnpcinfo(2));
if(getd(".n_"+.@type+"_origin_map$")!="")
unitwarp getd(".n_"+.@type+"_unit_id"),getd(".n_"+.@type+"_origin_map$"),getd(".n_"+.@type+"_origin_x"),getd(".n_"+.@type+"_origin_y");
if(isloggedin(getd(".n_"+.@type+"_master")))
message getd(".n_"+.@type+"_name$"),strnpcinfo(1)+" : See you!";
stopnpctimer;
setd ".n_"+.@type+"_status",0;
setd ".n_"+.@type+"_tmp_time",0;
setd ".n_"+.@type+"_master",0;
setd ".n_"+.@type+"_time",0;
setd ".n_"+.@type+"_name$","";
setd ".n_"+.@type+"_master_map$","";
setd ".n_"+.@type+"_master_x",0;
setd ".n_"+.@type+"_master_y",0;
setd ".n_"+.@type+"_npc_map$","";
setd ".n_"+.@type+"_npc_x",0;
setd ".n_"+.@type+"_npc_y",0;
return;
OnTimer1000:
{
set .@type,atoi(strnpcinfo(2));
for(;isloggedin(getd(".n_"+.@type+"_master"))
{
set .@type,atoi(strnpcinfo(2));
set .@aid,getd(".n_"+.@type+"_master");
if(attachrid(.@aid))
{
getmapxy(getd(".n_"+.@type+"_master_map$"),getd(".n_"+.@type+"_master_x"),getd(".n_"+.@type+"_master_y"),0);
getmapxy(getd(".n_"+.@type+"_npc_map$"),getd(".n_"+.@type+"_npc_x"),getd(".n_"+.@type+"_npc_y"),1,strnpcinfo(0));
if(maxhp/hp>=4)
{
percentheal 15,15;
specialeffect2 312;
}
if(getd(".n_"+.@type+"_tmp_time") == 0)
{
sc_start SC_BLESSING,60000,10;
specialeffect2 42;
sc_start SC_INCREASEAGI,60000,10;
specialeffect2 37;
sc_start SC_IMPOSITIO,60000,10;
specialeffect2 84;
sc_start SC_MAGNIFICAT,60000,10;
specialeffect2 76;
sc_start SC_GLORIA,60000,10;
specialeffect2 75;
sc_start SC_SUFFRAGIUM,60000,10;
specialeffect2 88;
sc_start SC_ASSUMPTIO,60000,10;
specialeffect2 375;
}
set .@tmp_time,getd(".n_"+.@type+"_tmp_time");
setd ".n_"+.@type+"_tmp_time",.@tmp_time+1;
if( .@tmp_time >= 59 )
setd ".n_"+.@type+"_tmp_time",0;
}
detachrid;
if(!isloggedin(.@aid))
{
callsub OnEndd;
break;
}
set .@map$,getd(".n_"+.@type+"_master_map$");
set .@x,getd(".n_"+.@type+"_master_x");
set .@y,getd(".n_"+.@type+"_master_y");
set .@uid,getd(".n_"+.@type+"_unit_id");
if(distance(getd(".n_"+.@type+"_npc_x"),getd(".n_"+.@type+"_npc_y"),.@x,.@y)>=8||.@map$!=getd(".n_"+.@type+"_npc_map$"))
unitwarp .@uid,.@map$,.@x,.@y;
else
unitwalk .@uid,.@x+rand(-3,3),.@y+rand(-3,3);
setd ".n_"+.@type+"_time",getd(".n_"+.@type+"_time")-1;
if( getd(".n_"+.@type+"_time") <= 0 )
{
callsub OnEndd;
break;
}
sleep2 1000;
}
}
callsub OnEndd;
end;
OnInit:
setd ".n_"+atoi(strnpcinfo(2))+"_unit_id",getnpcid(0);
set .amount,.amount+1;
end;
}
prontera,155,180,4 duplicate(DedicatedNPCMain) Dedicated Poring 1#1 1002
prontera,157,180,4 duplicate(DedicatedNPCMain) Dedicated Poring 2#2 1002
prontera,159,180,4 duplicate(DedicatedNPCMain) Dedicated Poring 3#3 1002