Dazee Posted November 15, 2014 Share Posted November 15, 2014 Okay so i have created this script but i want it to every time i make a delivery it adds +1 value to the previous value in the column of the smuggles how can i do that ? here's the fulll code. databaseConnection = dbConnect("sqlite", "file.db") function createTeamCriminalOnStart() criminalTeam = createTeam("Criminal", 255,255,255) end function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end function smuggleStart(player) if isPlayerInTeam(player, "Criminal") then northRockHut = createMarker(-706.5,954.0999,11.3999, "cylinder", 2.0, 175,0,255,150) outputChatBox("You need to deliver the smuggled goods to North Rock Hut!",player) else outputChatBox("You are not a criminal!",player) end end function ifDelivered(thePlayer, matchingDimension) local randomAmmount = math.random(250,5000) local addOne = 1 if isElementWithinMarker(thePlayer, northRockHut) then destroyElement(northRockHut) executeSQLQuery("CREATE TABLE IF NOT EXISTS players (smuggles TEXT, smuggles2 TEXT, name TEXT)") executeSQLQuery("CREATE TABLE IF NOT EXISTS `players` (`smuggles` TEXT, `smuggles2` TEXT, `name` TEXT)") givePlayerMoney(thePlayer,randomAmmount) outputChatBox("You have delivered the goods and earned:",thePlayer ) executeSQLQuery("ALTER TABLE players ADD IF NOT EXISTS smuggles;") executeSQLQuery("INSERT INTO players('smuggles') VALUES(?)",tonumber(1) ) else outputChatBox("You are not at the marker!!!", thePlayer) end end function becomeCriminal(thePlayer) setPlayerTeam(thePlayer, criminalTeam) outputChatBox("You are now a criminal!") end function checkSmuggles(thePlayer) local getHisSmuggles = executeSQLQuery("SELECT smuggles FROM players WHERE name=?",playerName) if(#getHisSmuggles == 0) then outputChatBox("You haven't smuggled at all",thePlayer) else outputChatBox("You have smuggled: " ..result[1].smuggles, thePlayer) end end addEventHandler("onResourceStart", resourceRoot, createTeamCriminalOnStart) addCommandHandler("smuggle", smuggleStart) addCommandHandler("criminal", becomeCriminal) addCommandHandler("deliver", ifDelivered) addCommandHandler("smuggles", checkSmuggles) 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