BennyBunny Posted August 22, 2011 Share Posted August 22, 2011 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
JR10 Posted August 22, 2011 Share Posted August 22, 2011 @ 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
BennyBunny Posted August 22, 2011 Author Share Posted August 22, 2011 yh that was the problem lol THX 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
JR10 Posted August 22, 2011 Share Posted August 22, 2011 Is that script in the same resource? If so use: triggerServerEvent If not, you need exports. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now