- 
                
Posts
188 - 
                
Joined
 - 
                
Last visited
 
Everything posted by Imposter
- 
	I believe the function requires all three, if you want to find the difference between the other two, why not do it mathematically? Just make a function yourself that does that BTW hello manve1!
 - 
	Hi, I want to know how to connect a client to another server from one, for example a player joins a server, a condition is not met, so it connects him to the 2nd server. Thanks!!
 - 
	Hi, i need help selecting, i need to grab the row "player_name" but i cant get it working, here is my code. function onPlayerLogin(thePreviousAccount, theCurrentAccount) -- Attempt to load data local theAccountQuery = dbQuery(theHandler, "SELECT * FROM account_stats WHERE player_name=?;", getAccountName(theCurrentAccount)) local theAccountResult = dbPoll(theAccountQuery, -1) if (theAccountResult) then outputChatBox("FOUND ACCOUNT!", source) outputChatBox(theAccountResult['player_name'], source) -- Doesnt Work else outputChatBox("DATA NOT FOUND!", source) end -- Free Query dbFree(theAccountQuery) end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin)
 - 
	Meh, i guess i'll go with MySQL then
 - 
	I just have a few questions about SQLite, first question: can i put my sql database in a folder in a higher directory than my server and access it? question two: can two servers access the same db at once? Thanks, NooP
 - 
	Solidsnake14, thanks once again, did anyone ever tell you that you are a genius?
 - 
	It didnt work, The UI doesnt show it, neither does the client announce it.
 - 
	Hey guy, Its been a while since I've posted, i have a problem in this bit of code, when i press the "m" key, it opens the menu, which triggers the server, the server gets the client AccountName and sends it back to the client to view on the GUI, but it doesnt happen, the server finds the data, and outputs it, as I did that to test it, but the client doesnt seem to get triggered, here is the code. Thanks! Server addEvent("sendGUIData", true) function sendGUIData() local theAccount = getPlayerAccount(source) if (theAccount) then if isGuestAccount(getPlayerAccount(source)) then outputChatBox("Please log in", source) else local theAccountName = getAccountName(getPlayerAccount(source)) outputChatBox("Hello " .. theAccountName) triggerClientEvent("setGUI", source, theAccountName) end end end addEventHandler("sendGUIData", getRootElement(), sendGUIData) Client local lp = getLocalPlayer() local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 241, 324 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 userMenu = guiCreateWindow(left, top, windowWidth, windowHeight, "User Menu", false) guiWindowSetSizable(userMenu, false) tabPanel1 = guiCreateTabPanel(10, 75, 221, 241, false, userMenu) tab1 = guiCreateTab("Info", tabPanel1) label1 = guiCreateLabel(10, 10, 200, 16, "Account Name: ", false, tab1) guiLabelSetHorizontalAlign(label1, "left", false) guiLabelSetVerticalAlign(label1, "center") label2 = guiCreateLabel(10, 30, 200, 16, "Account Registration: ", false, tab1) guiLabelSetHorizontalAlign(label2, "left", false) guiLabelSetVerticalAlign(label2, "center") label3 = guiCreateLabel(10, 50, 200, 16, "Account ACL: ", false, tab1) guiLabelSetHorizontalAlign(label3, "left", false) guiLabelSetVerticalAlign(label3, "center") label4 = guiCreateLabel(10, 70, 200, 16, "Player Rank: ", false, tab1) guiLabelSetHorizontalAlign(label4, "left", false) guiLabelSetVerticalAlign(label4, "center") label5 = guiCreateLabel(10, 150, 200, 16, "Rank 1:", false, tab1) guiLabelSetHorizontalAlign(label10, "left", false) guiLabelSetVerticalAlign(label10, "center") label6 = guiCreateLabel(10, 170, 200, 16, "Rank 2:", false, tab1) guiLabelSetHorizontalAlign(label12, "left", false) guiLabelSetVerticalAlign(label12, "center") label7 = guiCreateLabel(10, 190, 200, 16, "Rank 3:", false, tab1) guiLabelSetHorizontalAlign(label13, "left", false) guiLabelSetVerticalAlign(label13, "center") label8 = guiCreateLabel(10, 90, 200, 16, "Game Points: ", false, tab1) guiLabelSetHorizontalAlign(label8, "left", false) guiLabelSetVerticalAlign(label8, "center") label9 = guiCreateLabel(10, 110, 200, 16, "Iris Points: ", false, tab1) guiLabelSetHorizontalAlign(label9, "left", false) guiLabelSetVerticalAlign(label9, "center") tab2 = guiCreateTab("Cars", tabPanel1) tab3 = guiCreateTab("Perks", tabPanel1) tab4 = guiCreateTab("Options", tabPanel1) addEvent("setGUI", true) function setGUI(accountname) outputChatBox(accountname) guiSetText(label1, "Account Name: " .. accountname ) end addEventHandler("setGUI", resourceRoot, setGUI) function resourceStart () guiSetVisible (userMenu, false) bindKey("m", "down", menuShow) end addEventHandler("onClientResourceStart", resourceRoot, resourceStart) function menuShow() visableornot = guiGetVisible (userMenu) if (visableornot == true) then guiSetVisible (userMenu, false) showCursor (false) end if (visableornot == false) then triggerServerEvent ("sendGUIData", getLocalPlayer()) guiSetVisible (userMenu, true) showCursor (true) end end
 - 
	When you start the resource, or when a player Login, do you have any error in the consol about this script ? LOL seems to work now ...
 - 
	What am i doing wrong? function onLogin() local thePlayer = getPlayerFromName(getPlayerName(source)) outputChatBox("Hello!", thePlayer) end addEventHandler("onPlayerLogin", getRootElement(), onLogin) I don't know why, but when i simply just write source, it doesnt work
 - 
	but getID is not declared
 - 
	Where should i put it? LOL just noticed hope i see u there sometime
 - 
	But can you guys still tell me how to do it? Still no help?
 - 
	I dont know where to start, should I do those wiki tutorials?
 - 
	Oh sorry im didn't understand what u meant, and BTW learnng lua is exactly what im doing, i just need this script because i dont know how to integrate MySQL into MTASA furniture = {}
 - 
	How would i declare the table?
 - 
	Im making a furniture system based off of the housesystem_mysql by NoneAtMe and i changed many parts of it ( im using it because i dont really know how to link mysql with mta. I have an error at line 68 [2012-07-30 08:44:47] ERROR: [roleplay]\furniture\server.lua:68: attempt to index global 'furniture' (a nil value) Server Side ------------------------------------------- --------------MySQL Connection------------- ------------------------------------------- local hostip = "127.0.0.1" local username = "root" local password = "" local database = "db_furniture" local dbpTime = 500 ------------------------------------------- ------------Connect On Startup------------- ------------------------------------------- addEventHandler("onResourceStart", getResourceRootElement(), function() handler = dbConnect("mysql", "dbname="..database..";host="..hostip, username, password, "autoreconnect=1") if not(handler) then outputServerLog("[FurnitureSystem] Could not connect to the MySQL Server, shutting down...") outputChatBox("[FurnitureSystem] Could not connect to the MySQL Server, shutting down...") else outputServerLog("[FurnitureSystem] Successfully connected to the MySQL Server, loading...") outputChatBox("[FurnitureSystem] Successfully connected to the MySQL Server, loading...") furniture_onLoad() end end) ------------------------------------------- --------Create Furniture On Startup-------- ------------------------------------------- function furniture_onLoad() if(created == true) then error("The furniture has already been created upon execution!") return end buildStartTick = getTickCount() local query = dbQuery(handler, "SELECT * FROM objects;" ) local result, numrows = dbPoll(query, dbpTime) outputChatBox(tonumber(numrows)) total = tonumber(numrows) if (result) then if (numrows > 0) then for index, row in pairs(result) do local id = row['id'] local owner = row['owner'] local price = row['price'] local posx, posy, posz, rot = row['posx'], row['posy'], row['poz'], row['rot'] local int, dim = row['int'], row['dim'] -- loadFurniture(id, owner, price, posx, posy, posz, rot, int, dim) end dbFree(query) else error("Furniture Table is empty!") end else error("Furniture Table not Found!") end created = true setTimer(function() local elapsed = (buildEndTick-buildStartTick) outputServerLog("It took "..(elapsed/1000).." seconds to build all the furniture.") end, 1000, 1) end local function createFurniture(id, owner, price, posx, posy, posz, rot, int, dim) if(id) and (owner) and (posx) and (posy) and (posz) and (rot) and (price) and (int) and (dim) then furnitureID = id furniture[total+1] = createObject(id, posx, posy, posz, rot, 0, 0 ) -- This is the object furnitureData[id] = {} local furniture = furniture[id] -- I'm too lazy... setElementData(furniture, "furniture", true) -- Just for client code only setElementInterior(furniture, int) setElementDimension(furniture, dim) -- Set data for HOUSE -- furnitureData[id]["id"] = id furnitureData[id]["owner"] = owner furnitureData[id]["price"] = price furnitureData[id]["posx"] = posx furnitureData[id]["posy"] = posy furnitureData[id]["posz"] = posz furnitureData[id]["rot"] = rot furnitureData[id]["int"] = int furnitureData[id]["dim"] = dim setElementData(furniture, "id", id) setElementData(furniture, "owner", owner) setElementData(furniture, "price", price) setElementData(furniture, "posx", posx) setElementData(furniture, "posy", posy) setElementData(furniture, "posz", posz) setElementData(furniture, "rot", rot) setElementData(furniture, "int", int) setElementData(furniture, "dim", dim) outputServerLog("[FURNITURESYSTEM] Furniture with ID "..id.." created sucessfully!") buildEndTick = getTickCount() -- TRIGGER TO ALL CLIENTS THAT THE FURNITURE HAS BEEN CREATED -- -- setTimer(triggerClientEvent, 1000, 1, "onClientFurnitureSystemObjectMade", getRootElement(), furniture) else if not(id) then error("[FURNITURESYSTEM] Missing ID! Cannot create furniture!") else error("[FURNITURESYSTEM] Missing/Invalid Arguements") end end end function makeFurniture(thePlayer, command) local id = 2896 local owner = getAccountName(getPlayerAccount(thePlayer)) local price = math.random(100,200) local int = 1 local dim = 1 local posx, posy, posz = getElementPosition(thePlayer) local rot = getPedRotation(thePlayer) createFurniture(id, owner, price, posx, posy, posz, rot, int, dim) end addCommandHandler ( "makefurniture", makeFurniture )
 - 
	What is wrong here, why wont it replace the ped model?? function makeAltair() outputChatBox ( "Altair Mod - NooP" ) txd = engineLoadTXD ( "altair.txd" ) engineImportTXD ( txd, 258 ) dff = engineLoadDFF ( "altair.dff", 258 ) engineReplaceModel ( dff, 258 ) end addEventHandler ( "onClientResourceStart", resourceRoot, ReplaceVehicle ) function setAltair() setElementModel ( getLocalPlayer(), 258 ) end addCommandHandler("altair", setAltair) <meta> <script src="client.lua" type="client" /> <file src="altair.txd" /> <file src="altair.dff" /> </meta>
 - 
	this can be used for server side too?
 - 
	thanks to you i successfully made it, you are like a brother but just one more thing, you know how when you add a handler as onResourceStart, why does it do it when other resources start, can it do it only when the same resource starts?
 - 
	OK i got it all working, but i dont understand why this isnt working, the buttons arent even outputting the text function guiClick (button, state, absoluteX, absoluteY) local cash = guiGetText (worktxt) if (source == storebtn) then outputChatBox("should work...") triggerServerEvent ("withdraw", lp, cash) elseif (source == withdrawbtn) then outputChatBox("should work...") triggerServerEvent ("deposit", lp, cash) end end
 - 
	would this work if i wanted to send the bankmoney to the clientside??? server side triggerClientEvent( "menuShow", getRootElement(), cash ) clientside addEvent("menuShow", true ) function menuShow ( thePlayer, cash ) visableornot = guiGetVisible (bankwindow) if (visableornot == true) then guiSetVisible (bankwindow, false) showCursor (false) end if (visableornot == false) then guiSetText ( balancelbl, "Your Balance : $" .. cash ) guiSetVisible (bankwindow, true) showCursor (true) end end addEventHandler("menuShow", getRootElement(), menuShow)
 - 
	Ok, i fixed that using serverside function storeMoney( thePlayer, command, cash) local account = getPlayerAccount ( thePlayer ) if isGuestAccount ( account ) then return not outputChatBox ( "* Invalid account.", thePlayer, 255, 0, 0 ) end if getPlayerMoney(thePlayer) >= tonumber(cash) then local bankMoney = getAccountData ( account, "bankCash" ) or 0 local store = bankMoney+cash takePlayerMoney ( thePlayer, cash ) setAccountData ( account, "bankCash", store ) outputChatBox ( "DEBUG: " .. store ) outputChatBox ( "You stored $" .. cash .. " in your bank!", thePlayer) else outputChatBox ( "You do not have $" .. cash ..", you have $" .. getPlayerMoney(thePlayer) .. " and are short by $" .. cash-getPlayerMoney(thePlayer), thePlayer) end end addCommandHandler ( "store" , storeMoney ) and I want to know how i can pass arguements to the serverside from clientside clientside local screenX, screenY = guiGetScreenSize() local width, height = 331,140 local x = (screenX/2) - (width/2) local y = (screenY/2) - (height/2) local lp = getLocalPlayer() bankwindow = guiCreateWindow(x,y,331,140,"Bank System",false) balancelbl = guiCreateLabel(18,31,170,20,"Your Balance :",false,bankwindow) cashlbl = guiCreateLabel(18,61,170,20,"Your Cash :",false,bankwindow) worktxt = guiCreateEdit(22,95,158,27,"",false,bankwindow) storebtn = guiCreateButton(186,93,52,31,"Deposit",false,bankwindow) withdrawbtn = guiCreateButton(248,93,70,31,"Withdraw",false,bankwindow) guiWindowSetSizable(bankwindow,false) guiSetVisible (bankwindow, false) function resourceStart () bindKey ("j", "down", menuShow) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) function menuShow () visableornot = guiGetVisible (bankwindow) if (visableornot == true) then guiSetVisible (bankwindow, false) showCursor (false) end if (visableornot == false) then guiSetVisible (bankwindow, true) showCursor (true) end end function guiClick (button, state, absoluteX, absoluteY) if (source == storebtn) then triggerServerEvent ("withdraw", lp) elseif (source == withdrawbtn) then triggerServerEvent ("deposit", lp) end end addEventHandler("onClientRender",root, function() dxDrawText("$01234567",1080.0,159.0,1281.0,214.0,tocolor(37,110,37,255),1.8,"pricedown","left","top",false,false,false) end ) so when i click store, it sends the amount of cash entered in the editbox to the server so i can use my function that i made, how do I do this?
 
