-
Posts
1,491 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Walid
-
What i already tested it , working fine try to stop the resource delete the db then start the resource.
-
the problem in your code here it's accountName not acountName. it should be like this local database = dbConnect( "sqlite", "files.db" ); function makeDB () dbExec(database, "CREATE TABLE IF NOT EXISTS accounts (account TEXT, money INTEGER)") end function saveDataBase() local playerAccount = getPlayerAccount ( source ) local playerMoney = getPlayerMoney ( source ) if playerAccount and not isGuestAccount(playerAccount) then local accountName = getAccountName(playerAccount) if AccountExist ( accountName ) then dbExec(database, "UPDATE accounts SET money = ? WHERE account = ?",tonumber(playerMoney),tostring(accountName)) else dbExec(database, "INSERT INTO accounts VALUES (? , ?) ",tostring(accountName),tonumber(playerMoney)) end end end function AccountExist ( AccountName ) local result = dbPoll(dbQuery(database, "SELECT * FROM accounts WHERE account = ?", tostring (AccountName)),-1) if ( type ( result ) == "table" and #result == 0 or not result ) then return false else return true end end function getPlayerMoneyFromDb(accName) local check = dbPoll(dbQuery(database, "SELECT * FROM accounts WHERE account = ?",tostring(accName)), -1) if type(check) == "table" and #check == 0 or not check then return false else return tonumber(check[1]["money"]) end end function loadDataBase (_,cur) local accountName = getAccountName(cur) local moneyData = getPlayerMoneyFromDb(accountName) if moneyData then outputChatBox(moneyData,source) end end addEventHandler("onPlayerLogin", root, loadDataBase) addEventHandler("onPlayerQuit", root, saveDataBase) addEventHandler("onPlayerLogout", root, saveDataBase) addEventHandler("onResourceStart", resourceRoot, makeDB)
-
i gave you two solutions just use one of them.
-
the problem is here to fix it Replace money TEXT with money INTEGER also you can fix it by replacing tonumber with tostring here
-
Example function getPlayerMoneyFromDb(accountName) local check = dbPoll(dbQuery(database, "SELECT * FROM accounts WHERE account = ?",tostring(accountName)), -1) if type(check) == "table" and #check == 0 or not check then return false else return tonumber(check[1]["money"]) end end onPlayerLogin function loadDataBase ( _,cur) local acountName = getAccountName(cur) local moneyData = getPlayerMoneyFromDb(accountName) -- You code here end addEventHandler ( "onPlayerLogin", root, loadDataBase );
-
You must specify from which array you want to get the value so you need to use "WHERE" like this dbQuery(database, "SELECT * FROM accounts WHERE account = ?, --[[ account name here ]]")
-
it should be like this local database = dbConnect( "sqlite", "files.db" ); function makeDB () dbExec(database, "CREATE TABLE IF NOT EXISTS accounts ( account TEXT,money TEXT)"); end addEventHandler("onResourceStart", resourceRoot, makeDB) function saveDataBase() local playerAccount = getPlayerAccount ( source ); local playerMoney = getPlayerMoney ( source ); if playerAccount and not isGuestAccount(playerAccount) then local accountName = getAccountName(playerAccount) if AccountExist ( accountName ) then dbExec(database, "UPDATE accounts SET money = ? WHERE account = ?",playerMoney,accountName) else dbExec(database, "INSERT INTO accounts VALUES (? , ?) ",accountName,playerMoney) end end end addEventHandler("onPlayerQuit", getRootElement(), saveDataBase) function AccountExist ( AccountName ) local result = dbPoll(dbQuery(database, "SELECT * FROM accounts WHERE account = ?", tostring (AccountName)),-1) if ( type ( result ) == "table" and #result == 0 or not result ) then return false else return true end end You need to use dbQuery (not dbExec) with dbPoll to get the result.
-
Why two timers here setTimer (function () if isElement(copter) and isElement(huter) then destroyElement (copter) destroyElement (hunter) end end ,3100,1)
-
A common resource for the image will save memory. but Make sure the other resources it.
-
replace "onClientGuiClick" with "onClientGUIClick". here
-
What are you talking about there is no GUI in my code only Gives hydra on start. Next time post full code with Gui.
-
It should work addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent( "clientReady", resourceRoot ) end ) addEvent("replacemodel", true) addEventHandler("replacemodel", root, function() txd = engineLoadTXD ( "hydra.txd" ) engineImportTXD ( txd, 587 ) dff = engineLoadDFF ( "hydra.dff", 0 ) engineReplaceModel ( dff, 587 ) end ) -- Server side local readyPlayerList = {} addEvent("clientReady", true ) addEventHandler("clientReady",resourceRoot, function() table.insert( readyPlayerList, client ) theHydra() end ) function theHydra() for i, v in pairs (readyPlayerList) do if getTeamName(getPlayerTeam(v)) == "Warriors" then local money = getPlayerMoney(v) if (money > 24999) then takePlayerMoney(v, 25000) triggerClientEvent(v, "replacemodel",v) local x, y, z = getElementPosition(v) local veh = createVehicle(520, x, y, z) warpPedIntoVehicle(v, veh) end end end end -- table.removevalue function, in case you don't already have it function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end
-
replace getTeamFromName with getTeamName
-
where is the table local readyPlayerList = {} -- Client side addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent( "clientReady", resourceRoot ) end ) addEvent("replacemodel", true) addEventHandler("replacemodel", resourceRoot, function() txd = engineLoadTXD ( "hydra.txd" ) engineImportTXD ( txd, 587 ) dff = engineLoadDFF ( "hydra.dff", 0 ) engineReplaceModel ( dff, 587 ) end ) -- Server side local readyPlayerList = {} addEvent("clientReady", true ) addEventHandler("clientReady",resourceRoot, function() table.insert( readyPlayerList, client ) theHydra() end ) function theHydra() for i, v in pairs (readyPlayerList) do if getTeamFromName(getPlayerTeam(v)) == "Warriors" then local money = getPlayerMoney(v) if (money > 24999) then takePlayerMoney(v, 25000) triggerClientEvent(v, "replacemodel",resourceRoot) local x, y, z = getElementPosition(v) local veh = createVehicle(520, x, y, z) warpPedIntoVehicle(v, veh) end end end end -- table.removevalue function, in case you don't already have it function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end
-
Cmon man it's table ,replace source with v
-
-- Client side addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent( "clientReady", resourceRoot ) end ) -- Server side local readyPlayerList = {} addEvent("clientReady", true ) addEventHandler("clientReady",resourceRoot, function() table.insert( readyPlayerList, client ) end ) function YourFunction() for i, v in pairs (readyPlayerList) do -- your code here -- Use TriggerClientEvent now to replace the hydra model end end -- table.removevalue function, in case you don't already have it function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end Or use "onPlayerLogin"
-
Wrong , simply because you are trying to check the resource team The source of this event "onClientResourceStart" is the started resource's root element.
-
Lol it's already add use /vmods -- Car mods /gmods -- Gun mods
-
All What you need is
-
Server IP: mtasa://5.135.194.228:22003 Forum link : http://www.cog4ever.com Facebook Page : http://www.facebook.com/COGcommunity... Twitter : http://www.twitter.com/COGserver
-
KillPed server side function -- Client side if ( source == button ) then triggerServerEvent("KillPed",resourceRoot) end -- Server Side function YourFunction() killPed(client) end addEvent("KillPed",true) addEventHandler("KillPed",resourceRoot,YourFunction)
-
Yeh i already create it.
-
killPed setElementHealth setPedArmor fixVehicle setVehicleNitroActivated setVehicleNitroCount setVehicleNitroLevel setTimer
-
Many things wrong in your code Example: 1) Here you are trying to check if the marker == player , because the source of this event onMarkerHit is the marker that got hited by the element. Wrong: Correct: local myMarker = createMarker(385.34344,2032.22693,7.83594 ,"cylinder",255,255,255,255) function MarkerHit(player,Dim) if (Dim and isElement(player) and getElementType(player) == "player") then -- You code here end end 2) There is no function called isElementModel Wrong: Correct : local model = getElementModel(source) if model == 0 then -- Your code here end