Need some advice (Mysql)
#1

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.
Reply
#2

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.
Reply
#3

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 ?
Reply
#4

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.
Reply
#5

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.
Reply
#6

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.
Reply
#7

Can someone give me the code ?
Reply
#8

Please help me ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)