Database write interval and vehicle lock (2 issues)
#1

1. I want to write the data from the enumerators to the DB as often as possible without draining resources. What intervals do you all use for your servers.

2. I want to implement a vehicle lock system that can also be used outside the vehicle. I have seen an implementation that uses a LastVehicle[MAX_PLAYERS] array to store the last vehicle the player was in and perform the lock/unlock on that vehicle if they own it and are close enough. The problem with that system for me is the player can have multiple cars spawned at once so say I own a freeway and a clover. I drive my clover to pick up my freeway. I lock my clover with lock and the LastVehicle[playerid] is set as the clover. I walk over the my freeway and type /unlock and it unlocks the clover because that is the last vehicle I was in. How should I implement this (logic rather than code)

Thanks for looking!
Reply
#2

1) I'd advise saving every 2-5 minutes (and obviously when they disconnect) you don't really to save more often than that.

2) Store all the players vehicleids in an array, then loop through the array un/locking the vehicles when needed.
Reply
#3

Quote:
Originally Posted by iggy1
Посмотреть сообщение
1) I'd advise saving every 2-5 minutes (and obviously when they disconnect) you don't really to save more often than that.

2) Store all the players vehicleids in an array, then loop through the array un/locking the vehicles when needed.
All vehicles are already in an array but I don't want to loop through upto 200 vehicles everytime someone wants to lock /unlock a vehicle to see if it belongs to them. Is there any other way?

Thanks
Reply
#4

When storing your vehicles in an array, you should have a dimension in the array to specify a playerid so that you only have to loop through the player's vehicles.
Reply
#5

My array looks like this


playerVehicles[vehicleid][vModelId]
playerVehicles[vehicleid][vOwnerId] //internal DB autoindex key
playerVehicles[vehicleid][vTmpPlayerId] // The playerid of the charater given at login

So I only need to loop through vehicles that belong to vTmpPlayerId. But I can't search an array so I would have to loop all spawned vehicles to find if vTmpPlayerId == playerid. This seems very inefficient.
Reply
#6

Quote:
Originally Posted by liam1412
Посмотреть сообщение
My array looks like this


playerVehicles[vehicleid][vModelId]
playerVehicles[vehicleid][vOwnerId] //internal DB autoindex key
playerVehicles[vehicleid][vTmpPlayerId] // The playerid of the charater given at login

So I only need to loop through vehicles that belong to vTmpPlayerId. But I can't search an array so I would have to loop all spawned vehicles to find if vTmpPlayerId == playerid. This seems very inefficient.
Hate to bump but Im stumped on this one?
Reply
#7

I actually use a similar system to this right now in my RPG INC. how I acheived this was to store the owners name within the vehicleinfo array. when the payer connects my system scans the vehicles and locates the vehicle id's associated with that layer's name then assigns it to another array that holds the player's owned vehicle id's. The benefit is that the search only needs to be called everytime vehicle id's are moved around which is almost never OR when a player connects.

Check out my inc - look specifically in the tsys_vehicles.lib file and look for the stock process called:

SetPlayerOwnedVehicleIDs(playerid)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)