Jump to content

SQL questions


BennyBunny

Recommended Posts

I have done a nice race script for my server with a race timer.

So i wanna save now the best 3 Times with the player name.

For that i have crate that table you can see it in my script.

I have add a clean too for that is "cleandrift"

But the problem is now i cant read the db for the first test idk why :/

So that the player when he finish the race he can see the best 3 times.

That is my first stap :)

function createNewUDatabankForDrift () 
  
    executeSQLCreateTable ( "drifttoptimes", "driftonetimedb INTEGER, winneronedriftdb TEXT, drifttwotimedb INTEGER, winnertwodriftdb TEXT, driftthreetimedb INTEGER, winnerthreetimedb TEXT, findtextdb INTEGER" ) 
  
end 
  
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createNewUDatabankForDrift ) 
  
  
  
function driftcleartoplist ( playerSource ) 
  
    if hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) then 
  
        outputChatBox ( "The Drift to 3 have set to 0", 0, 255, 0, source ) 
  
        executeSQLInsert ( "drifttoptimes", "'0', 'No Name', '0', 'No Name', '0', 'No Name', '1'" ) 
  
    end 
  
end 
  
addCommandHandler ( "cleandrift", driftcleartoplist ) 
  
     
function drivtsavetop () 
  
        outputChatBox ( "Player have finish the race and start now the timer controll save", 0, 255, 0, source ) 
  
        winnertimeone = executeSQLQuery ( "drifttoptimes", "driftonetimedb", "findtextdb = '1'" ) 
  
        outputChatBox ( "Best Time from drift race is" ..winnertimeone[1].driftonetimedb, 0, 255, 0, source ) 
  
end 
  
addEvent( "driftsendtoclient", true ) 
addEventHandler( "driftsendtoclient", getRootElement(), drivtsavetop ) 

Link to comment

@ drivtsavetop : you used executeSQLQuery when you should have used executeSQLSelect.

function createNewUDatabankForDrift () 
  
    executeSQLCreateTable ( "drifttoptimes", "driftonetimedb INTEGER, winneronedriftdb TEXT, drifttwotimedb INTEGER, winnertwodriftdb TEXT, driftthreetimedb INTEGER, winnerthreetimedb TEXT, findtextdb INTEGER" ) 
  
end 
  
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createNewUDatabankForDrift ) 
  
  
  
function driftcleartoplist ( playerSource ) 
  
    if hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) then 
  
        outputChatBox ( "The Drift to 3 have set to 0", 0, 255, 0, source ) 
  
        executeSQLInsert ( "drifttoptimes", "'0', 'No Name', '0', 'No Name', '0', 'No Name', '1'" ) 
  
    end 
  
end 
  
addCommandHandler ( "cleandrift", driftcleartoplist ) 
  
    
function drivtsavetop () 
  
        outputChatBox ( "Player have finish the race and start now the timer controll save", 0, 255, 0, source ) 
  
        winnertimeone = executeSQLSelect ( "drifttoptimes", "driftonetimedb", "findtextdb = '1'" ) 
  
        outputChatBox ( "Best Time from drift race is" ..winnertimeone[1].driftonetimedb, 0, 255, 0, source ) 
  
end 
  
addEvent( "driftsendtoclient", true ) 
addEventHandler( "driftsendtoclient", getRootElement(), drivtsavetop ) 

Link to comment

yh that was the problem lol THX :D

But now i have a other question i bet super easy but i have never done this before.

Now i have the end time from the race: (client side)

savetimerfortopdrift = tostring(tonumber(drifttimer))

how can i send that now to my script where is the db for check is the time in the top 3 or not. (server side)?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...