
Hero192
Members-
Posts
512 -
Joined
-
Last visited
Everything posted by Hero192
-
Hey guys, i want to know how to get the saved data from the mysql in case i want to change the website so i'll have to transfer the data from this web to other one with out losing players's data how can i do that ?
-
Thanks alot i understood many things from you just now and thanks for helping via pm this topic can be locked
-
Now, i understand well thanks again and for your time to explain this
-
this account from the sqlite table always returns 'nil'
-
I'll use it in other save thats why
-
It's working thanks alot but i need to equal in the load part if the account in sqlite table equal to the player account it doesn't works if i did that, and i need this part to do something function loadDataBase(_, account) local data = AccountExist(getAccountName(account)) if data then if data["account"] == getAccountName(account) then setPlayerMoney(source, data["money"]) spawnPlayer(source, data["x"], data["y"], data["z"]) fadeCamera(source, true) setCameraTarget(source) end end end
-
Yes i did like 3 Times but with the same result
-
Thanks for your try but it doesn't works it returns with some errors ERROR: attempt to index local 'data' (a boolean value) at line 34 Also when i connect the code to Mysql to check the table is created succesfully but there's no columns and rows inside it
-
Hey guys i m trying to do a saver , position,money and account but it doesn't works plus no error, please i need someone to give me a hand i stuck on this point, Here's my code! local connection = exports.sql:getSQLConnection() addEventHandler("onResourceStart",resourceRoot, function() dbExec(connection, "CREATE TABLE IF NOT EXISTS accountdata ( account TEXT, x TEXT, y TEXT, z TEXT, money INTEGER)") end) function saveDataBase() local account = getPlayerAccount ( source ) local money = getPlayerMoney ( source ) local x, y, z = getElementPosition ( source ) if account and not isGuestAccount(account) then local accountName = getAccountName(account) if AccountExist ( accountName ) then dbExec ( connection, "INSERT INTO accountdata (x, y, z, money, account ) VALUES ( ?, ?, ?, ?, ?, ? )", x, y, z, money, accountName) end end end function AccountExist ( AccountName ) local result = dbPoll( dbQuery ( connection, "SELECT * FROM accountdata WHERE account = ?", tostring (AccountName)),-1) if ( type ( result ) == "table" and #result == 0 or not result ) then return false else return true end end function loadDataBase ( ) local account = getPlayerAccount ( source ) local accountName = getAccountName(account) local data = AccountExist(accountName) if ( data and type ( data ) == 'table' ) then for index, val in ipairs ( data ) do if ( val['account'] == account ) then local x = tonumber ( val['x'] ) local y = tonumber ( val['y'] ) local z = tonumber ( val['z'] ) local money = tonumber ( val['money'] ) givePlayerMoney ( source, money ) setElementPosition (source, x, y, z ) end end end end addEventHandler("onPlayerLogin", root, loadDataBase) addEventHandler("onPlayerQuit", root, saveDataBase) addEventHandler("onPlayerLogout", root, saveDataBase)
-
Hey guys im making a login system but i stuck on something, i want when i start the resource only people who have no account or they're guest account they who can see the gui ,since the onResourceStart event do not accept 'source' i tried this way but nothing works.. i did trigger from client to server it's for the GUI Visiblity Here's the code, no error it just doesn't works addEventHandler( "onResourceStart", root, function () checkGuestAccount() end) function checkGuestAccount () local account = getPlayerAccount(source) if not account or isGuestAccount(account) then showPlayerHudComponent ( source, "clock", true ) showPlayerHudComponent ( source, "radar", true ) showPlayerHudComponent ( source, "area_name", true ) showChat ( source, true ) showCursor( source, true ) fadeCamera( source, true, 1 ) setCameraMatrix(source, -1212.281, 185.058, 84.00, -1780, 790, 70) outputChatBox("* Welcome .",source,255,255,0) triggerClientEvent(source,"onJoin",source) else return false end end
-
Do you have any tutorial or video? because it will be hard for my first time
-
Ok thanks, i will try that, and after doing that ,how to manage the database from my server? something professional not like XAMP
-
Hey guys i want to know how to create a mysql server to connecte the database with mysql I Use db functions like dbConnect
-
Hey guys, how to save the player position when he Quit/Disconnect with Mysql? i will learn from that the mysql i already know some of it but i need examples like that many thanks for who tried to help me with example
-
What's the different between the function getDistanceBetweenPoints3D and getDistanceBetweenPoints2D distance 3D and 2D? Thanks in advance
-
Hey guys, please anyone know how to make this radio link to URL ? http://player.hitradio.ma Thanks
-
about your example, so the 2nd / 3rd Messages are combined now to the table messages after using table.insert fonction?
-
Hey guys, can i know why we use table.insert ? don't recommand for me the lua website because it's hard to understand and please give me example
-
client is defined with localPlayer, look at the top of my code and i know basic lua scripting .. my problem is with mta functions
-
If i was good i wasn't going to post this topic, i posted this to find someone who can give me his hand and help me out to correct and learn from my fails , be sure next time i can't do the same fail if you helped me
-
There's no errors, client side: local root = getRootElement() local client = getLocalPlayer() buswindow = guiCreateWindow(419,244,500,287,"Bus",false) guiSetVisible (buswindow, false) guiWindowSetSizable(buswindow,false) busGrid = guiCreateGridList(9,20,482,224,false,buswindow) costColumn = guiGridListAddColumn(busGrid,"Price:",0.7) spawnBtn = guiCreateButton(17,247,157,31,"Spawn",false,buswindow) rejectBtn = guiCreateButton(329,247,157,31,"Cancel",false,buswindow) addEvent("showgui",true) addEventHandler("showgui",root, function (moneyTable) guiSetVisible(buswindow,true) showCursor(true) guiGridListClear(busGrid) for i,v in ipairs (moneyTable) do local row = guiGridListAddRow (busGrid) guiGridListSetItemText (busGrid, row, 1, v[1], false, false) end end) addEventHandler ("onClientGUIClick", root, function () if (source == rejectBtn) then guiSetVisible(buswindow,false) showCursor(false) elseif (source == spawnBtn) then local row,col = guiGridListGetSelectedItem(busGrid) if row and col and row ~= -1 and col ~= -1 then guiSetVisible(buswindow,false) showCursor(false) triggerServerEvent("warpplayer",client,guiGridListGetSelectedItem(busGrid)+1) end end end)
-
so you mean that? still doing the same and the problem is when i selecte the gridlist to check the prices of markers distance it give me the same price.. you said: You need to find the marker on warpplayer to get its position. how to do that? addEvent ("warpplayer",true) addEventHandler ("warpplayer",root, function () local px, py, pz = getElementPosition(client) local mx, my, mz = unpack ( markerpos ) local distance = getDistanceBetweenPoints2D ( px, py , mx, my ) local cash = math.floor(distance / 2) if ( getPlayerMoney ( source ) < cash ) then outputChatBox (" You need ".. cash .."$ to use this service.", source, 255,0,0) else takePlayerMoney (source, cash ) end end)
-
local markers = { --Markers table [1]={x=2220.43, y=2469.49, z=10.82, bx=2221.24, by=2468.76, blip=8, dim=0, int=0}, [2]={x=1625.00, y=1850.43, z=10.82, bx=1625.00, by=1850.43, blip=8, dim=0, int=0}, [3]={x= 1718.26, y=1484.68, z=10.82, bx=1718.26, by=1484.68, blip=8, dim=0, int=0}, [4]={x=1214.07, y=-1316.54, z=13.56, bx=1214.07, by=-1316.54, blip=8, dim=0, int=0}, } local moneyTable = { [1]={1111}, -- How to remplace the argument [1] in theTable by distance numbers as price [2]={1111}, [3]={1111}, [4]={1111}, } busmarker = {} playerpos = {} addEventHandler("onResourceStart",resourceRoot, function () for index, data in pairs(markers) do local busmarker = createMarker(data.x, data.y, data.z-1, "cylinder", 1.5,247,187, 7, 120) markerpos = { getElementPosition( busmarker ) } addEventHandler("onMarkerHit",busmarker,onMarkerHit) end end) addEvent ("warpplayer",true) addEventHandler ("warpplayer",root, function () local px, py, pz = unpack ( playerpos ) local mx, my, mz = unpack ( markerpos ) playerpos = { getElementPosition( source ) } local distance = getDistanceBetweenPoints2D ( px, py , mx, my ) local cash = math.floor(distance / 2) if ( getPlayerMoney ( source ) < cash ) then outputChatBox (" You need ".. cash .."$ to use this service.", source, 255,0,0) else takePlayerMoney (source, cash ) end end) function onMarkerHit(hitPlayer) if ( getElementType ( hitPlayer ) == 'player' and not isPedInVehicle ( hitPlayer ) and not isPedDead ( hitPlayer ) ) then triggerClientEvent(hitPlayer,"showgui",hitPlayer,moneyTable) end end
-
anyone can help me?