• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.
Resource icon

[TFS 1.4.2] Item Rental System! 2024-05-31

No permission to download

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,446
Solutions
76
Reaction score
822
Location
ლ(ಠ益ಠლ)
Mateus Robeerto submitted a new resource:

[TFS 1.4.2] Item Rental System! - [TFS 1.4.2] Item Rental System!

A gentleman asked me to create an item rental system. For instance, the owner rented a 'magic sword' to a player for 10 minutes and paid accordingly. Money and items should be placed in the 'ammo' slot to use the '!rent Matheus xxx' command, where 'xxx' is the desired value. If the value is 10,000 coins or more, or any currency ID, a currency bag must be placed in the 'ammo' slot to negotiate with the owner and rent the item for a specific time. Upon expiry, the item returns to the owner. If...

Read more about this resource...
 
What happens if the person who rented the item just logs out and never back in?
I forgot to include this part: if the client player never logs in again, I will look into it later and update the script. Thank you for reminding me. I haven't tested it with the client player yet, only with the rented owner. Thank you.
 
I forgot to include this part: if the client player never logs in again, I will look into it later and update the script. Thank you for reminding me. I haven't tested it with the client player yet, only with the rented owner. Thank you.
may set nologout until the item let be back.
 
may set nologout until the item let be back.
That probably wont work, imagine if the player just goes and dies 😅
I suggest using an onLogout script and just move the item back to the owner if the player tries to logout (includes death aswell)
You clearly have no good intentions logging out while having a rented item, so it's a little punishment 😜
 
That probably wont work, imagine if the player just goes and dies 😅
I suggest using an onLogout script and just move the item back to the owner if the player tries to logout (includes death aswell)
You clearly have no good intentions logging out while having a rented item, so it's a little punishment 😜
onlogout and onpreparedeath is a good idea.
 
I would also do a position check for renting, doesnt make sense to conduct a rental from half way across the map. I would also prevent a rental from happening if either player has pz lock.
 
That probably wont work, imagine if the player just goes and dies 😅
I suggest using an onLogout script and just move the item back to the owner if the player tries to logout (includes death aswell)
You clearly have no good intentions logging out while having a rented item, so it's a little punishment 😜
What about lost connection cases?
 
What about lost connection cases?
You're correct that's a problem, but in this case I'd rather let them suffer for their connection loss, if we take this by percentage the abusers will outweight connection loss by far atleast in my opinion.
You could probably consider removing it at logout and having it in a "pending state" where it's not relocated back to the original owner if the timer hasn't passed and if the current owner logs back in before the timer runs out you just give it back to him for the time remaining and if the timer passed before he logs back in you just relocate it back to the original owner
 
You're correct that's a problem, but in this case I'd rather let them suffer for their connection loss, if we take this by percentage the abusers will outweight connection loss by far atleast in my opinion.
You could probably consider removing it at logout and having it in a "pending state" where it's not relocated back to the original owner if the timer hasn't passed and if the current owner logs back in before the timer runs out you just give it back to him for the time remaining and if the timer passed before he logs back in you just relocate it back to the original owner
Perhaps a database table for rental items is best (if Mateus Robeerto is willing to implement). This way all rentals can also be logged and a history maintained. You could then handle things on startup case of a crash or other unforeseen issues.

Especially for cases where rental durations are days instead of hours, or where rentals span across a server save(restart) and therefore an addEvent needs to be reapplied etc.

@Mateus Robeerto Cool system though! Hopefully you are able to iron out all the issues.
 
Last edited:
You could probably consider removing it at logout and having it in a "pending state" where it's not relocated back to the original owner if the timer hasn't passed and if the current owner logs back in before the timer runs out you just give it back to him for the time remaining and if the timer passed before he logs back in you just relocate it back to the original owner
I thought exactly the same. I would personally create a static Player (instance, guid) just to have easy access to a depot where we can store/move the items ('pending states' or for whatever reason) and then by using scheduled tasks we could handle the rental time properly.

Honestly there is quite things to consider, such as 'crashes' as Fjorda mention but still, the 'rental' thing overall is kind a cool idea
 
Guys, just to update you on the bugs you mentioned, the issue has already been resolved. I will update the post as soon as I get home. Thanks to your discussion about what happens if a player doesn't log in anymore and other things, we managed to solve the problem yesterday, but I didn't have time to update the topic here
what hapen if i throw that rented magic sword on the ground or to trashbin or sell it on market or trade it and shit liek that?
Did you not read the topic? I created a system to prevent the movement of items to the ground or to be discarded, as well as to trade with other players. Items can only be moved within the backpack, but I found a bug where players can move them directly to the depot. I will fix this today and update the post. I also added a system where players can rent items starting from level 100.
 
This is so easy to exploit. Just put that item into a bag and throw that bag instead.
There is a reason why Store Inbox was introduced by Cipsoft.
 
This is so easy to exploit. Just put that item into a bag and throw that bag instead.
There is a reason why Store Inbox was introduced by Cipsoft.
That can be solved too

 
That can be solved too

I'm aware that this can be solved. But hot damn, going through all backpacks just to find 1 item, yikes.
 
I'm aware that this can be solved. But hot damn, going through all backpacks just to find 1 item, yikes.
I agree, however, if this system were to go down the route of recursive search, it could be more efficient by limiting the moveItem event callback to only those who have rented (by checking for an event registered to the player)

Still not an efficient solution i know, but at least it will prevent unwanted recursive checks on 99% of players.
 
Last edited:
Note that I have implemented a block so that if an item has a custom 'owner' attribute, it cannot be moved to the ground or the trash. Items inside a backpack with the custom 'owner' attribute also cannot be moved along with the backpack. If the backpack contains normal items without the custom 'ownerGuid' attribute, it can be moved normally. Additionally, I have added a check to prevent these items from being moved to the depot. This should resolve all the issues.

teste.gif
See another quick GIF: one item was rented and is using the custom attribute 'ownerGuid', and another item is normal and not using the custom attribute 'ownerGuid'.

tess.gif
Check when the client player logs out and stays offline for some time. The item should be able to return to the owner
melhor.gif

When both the player client and the owner are offline, the system should be able to verify and return the original item to the owner's depot. This is working correctly

gm.gif


I've already updated the file there. Just download and review the script. If someone can look at it and correct any optimizations needed, let me know, and I'll try to fix it. I would appreciate any help as I'm still learning TFS 1.x. xD.

I tested with the player client dying multiple times, and the item returned to the owner normally. I also set up the database to store the rental item and handle real-time expiration, removing the item directly from the database both offline and online normally.
 
Back
Top