Posts: 182
Threads: 53
Joined: Nov 2010
Reputation:
0
I need some advice, I have MYSQL based vehicle system, it saves vehicle ID, coords etc.
Now, I want to make vehicle renting system, how can I do that ? Should I make some IsRented field in database ?
And how can i detect if it's rented, not.
Help please.
Posts: 6,129
Threads: 36
Joined: Jan 2009
If you're creating a renting system, the best thing to do is to create a field that includes a Unix Timestamp (research them for more info, also note that the PAWN time() function without any given parameters omits a Unix Timestamp).
Set the field to 0 if they aren't renting the vehicle and a Unix Timestamp + the amount of seconds the player should own the vehicle for, run a timer every few seconds including an if statement to check variables and if they equal the current time then the car disappears or whatever action you want to occur. Store your MySQL data in temp variables and save (and load) them from/to the database when you need to (login/logoff).
I could have been a little more newb-friendly with this... guide (for lack of a better term) but I assume once you get scripting you might understand what I've tried to say.
Posts: 182
Threads: 53
Joined: Nov 2010
Reputation:
0
But, If I rent a car, and then other players coming, how server detects that who's the owner if there is only timestamp.
Can you give me an example how I could do this all ?
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by NewbBeginner
But, If I rent a car, and then other players coming, how server detects that who's the owner if there is only timestamp.
Can you give me an example how I could do this all ?
|
I assume you already created a player name variable for the vehicles, store a player name in a variable and MySQL field/row and compare it to the person entering the vehicle by keeping the cars to IDs properly.
Posts: 182
Threads: 53
Joined: Nov 2010
Reputation:
0
well yea, I have fileds: Id, Owner, coords.
Now, I created a IsRented field with int, it's set to 0.
Now, I if player does /rentcar, what this command should do, I need code.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by NewbBeginner
well yea, I have fileds: Id, Owner, coords.
Now, I created a IsRented field with int, it's set to 0.
Now, I if player does /rentcar, what this command should do, I need code.
|
I'm giving you advice, not code, mainly because I can't be bothered.
Posts: 182
Threads: 53
Joined: Nov 2010
Reputation:
0
Can someone give me the code ?