// TMW2 Script
//
// @rentitem <item> <time>
// Rents an <item> for <time> seconds
// 1 hour: 3600s
// 1 day: 86400s
// 1 month: 2592000s
- script @rentitem 32767,{
end;
OnCall:
//.@request$ = "";
//.@request$ += implode(.@atcmd_parameters$, " ");
.@item=atoi(.@atcmd_parameters$[0]);
.@time=atoi(.@atcmd_parameters$[1]);
if (!.@item || !.@time) {
dispbottom l("@rentitem <item numeric id> <time in seconds>");
end;
}
// Limiting to 365 days max
.@time=limit(15, .@time, 31536000);
rentitem(.@item, .@time);
end;
OnCraftBypass:
if (getarraysize(.@atcmd_parameters$) < 8) {
dispbottom l("Usage: @craft item opt1 val1 opt2 val2 opt3 val3 opt4 val4");
end;
}
.@item=atoi(.@atcmd_parameters$[0]);
.@opt1=atoi(.@atcmd_parameters$[1]);
.@val1=atoi(.@atcmd_parameters$[2]);
.@opt2=atoi(.@atcmd_parameters$[3]);
.@val2=atoi(.@atcmd_parameters$[4]);
.@opt3=atoi(.@atcmd_parameters$[5]);
.@val3=atoi(.@atcmd_parameters$[6]);
.@opt4=atoi(.@atcmd_parameters$[7]);
.@val4=atoi(.@atcmd_parameters$[8]);
CsysNpcCraft(.@item, .@opt1, .@val1, .@opt2, .@val2,
.@opt3, .@val3, .@opt4, .@val4);
end;
OnCraftSuper:
if (getarraysize(.@atcmd_parameters$) < 8) {
dispbottom l("Usage: @craft2 item refine opt1 val1 opt2 val2 opt3 val3 opt4 val4 opt5 val5");
end;
}
.@item=atoi(.@atcmd_parameters$[0]);
.@refi=atoi(.@atcmd_parameters$[1]);
.@crd1=atoi(.@atcmd_parameters$[2]);
.@crd2=atoi(.@atcmd_parameters$[3]);
.@crd3=atoi(.@atcmd_parameters$[4]);
.@crd4=atoi(.@atcmd_parameters$[5]);
.@opt1=atoi(.@atcmd_parameters$[6]);
.@val1=atoi(.@atcmd_parameters$[7]);
.@opt2=atoi(.@atcmd_parameters$[8]);
.@val2=atoi(.@atcmd_parameters$[9]);
.@opt3=atoi(.@atcmd_parameters$[10]);
.@val3=atoi(.@atcmd_parameters$[11]);
.@opt4=atoi(.@atcmd_parameters$[12]);
.@val4=atoi(.@atcmd_parameters$[13]);
.@opt5=atoi(.@atcmd_parameters$[14]);
.@val5=atoi(.@atcmd_parameters$[15]);
getitem(.@item, 1, 1, .@refi, 0, .@crd1, .@crd2, .@crd3, .@crd4);
delinventorylist(); // Needed, because we'll rely on rfind()
getinventorylist();
.@index=array_rfind(@inventorylist_id, .@item);
// Apply the bonuses if needed
if (.@opt1)
setitemoptionbyindex(.@index, 0, .@opt1, .@val1);
if (.@opt2)
setitemoptionbyindex(.@index, 1, .@opt2, .@val2);
if (.@opt3)
setitemoptionbyindex(.@index, 2, .@opt3, .@val3);
if (.@opt4)
setitemoptionbyindex(.@index, 3, .@opt4, .@val4);
if (.@opt5)
setitemoptionbyindex(.@index, 4, .@opt5, .@val5);
end;
OnInit:
bindatcmd "rentitem", "@rentitem::OnCall", 80, 99, 1;
bindatcmd "craft", "@rentitem::OnCraftBypass", 99, 99, 1;
bindatcmd "craft2", "@rentitem::OnCraftSuper", 99, 99, 1;
end;
}