Jump to content

Ryancit2

Members
  • Posts

    266
  • Joined

  • Last visited

Everything posted by Ryancit2

  1. In other words, 'not' use hota hai opposite boolean k liye. btw wo '_' ka mujhay bhi nahi pata tha, main isey use bhi nahi karta.
  2. You are welcomed, happy to know it helped you
  3. There is no way, in client-side-only to open GUI for ALL THE PLAYERS IN SERVER!
  4. Yes, happens when you addCommand in serverside and then triggerClientEvent to open GUI, that can be minimized by this: triggerClientEvent("openGUI", root) -- WRONG! triggerClientEvent(player, "openGUI", player) -- Right, will be triggered for only the player who typed command.
  5. No it wont, command is added in client side + it will trigger function for client only.
  6. No, here is explanation... You should call functions in same file like function(arg) while you have a choice triggerEvent, say you made your own event like "onClientDepositMoney" but this event will not be triggered unless you make it happen manually, in this case, you'll use 'triggerEVent' within SAME file, now when you add "onClientDepositMoney" EXTERNALLY in some other script, the event will be triggered on original script and will call the function from OTHER script too, here is example: -- atms_c.lua function confirmDeposit(acc, money) -- Acc is account of player, got from serverside ofcourse while money is numeric value. if (not money) or (not acc) then return end local prev = getAccountData(acc, "atms.money") or 0 setAccountData(acc, "atms.money", tonumber(prev) + money) triggerEvent("onDepositMoney", root, getAccountName(acc), money) end addEventHandler("onClientGUIClick", deposit_btn, confirmDeposit, false) addEvent("onDepositMoney", true) -- Make event trigger-able externally... Now some other resource, some other file: -- logs_c.lua function writeLog(acc, money) if (not acc) or (not money) then return end writeLog(acc, "Player has deposited $"..money.."in his bank.") end addEventHandler("onDepositMoney", root, writeLog)
  7. function toggleGUI() guiSetVisible(guiEditor.Window[1], (not guiGetVisible(guiEditor.Window[1]))) showCursor(not isCursorShowing()) end addCommandHandler("toggle", toggleGUI) bindKey("O", "down", toggleGUI) -- Simple function ;D
  8. Not sure about that. Though, VPS helpline would help you in that case, try calling COMSATS helpdesk (?)
  9. Compare your 'ALTER TABLE' sample with my pseudo using ingame performance browser, you'll see a huge difference if you call your sample 1000 times versus mine. Local tables won't even affect a single unit while 1000 entries call on each dbQuery would probably cause huge lag.
  10. Ryancit2

    Combobox

    Simple example: addEventHandler ("onClientResourceStart",resourceRoot,function() local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 200,100 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 local vehiclesComboBox = guiCreateComboBox ( left, top, windowWidth,windowHeight, "Vehicle Names", false ) -- We create a combo box. for index, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- We loop through all vehicles. guiComboBoxAddItem ( vehiclesComboBox, getVehicleName ( vehicle ) ) -- We add the vehicle name to our combo box. end end) addCommandHandler("gettext", function (command) local item = guiComboBoxGetSelected(vehiclesComboBox) local text = guiComboBoxGetItemText(vehiclesComboBox, item) outputChatBox("Currently selected item with ID: " .. tostring(item) .. " and with text: " .. text) end) Now go ig, start this and type /gettext
  11. Yes, you'll need a good knowledge of basic mathematics to get client's resolution, then get center, then divide center with number of rectangles and then draw the rectanles. or, i don't know if its better way but you can create a guiLable in bottom-center of client's screen, then draw rectangle images inside it using images, then set image color one by one on regular intervals.
  12. Ryancit2

    Combobox

    You can use following: guiCreateComboBox guiComboBoxGetItemText guiComboBoxGetSelected
  13. Probably that will ruin the performance even at good VPS hosts like CIT's. The correct answer was that you should make local tables in server side: dbTableName = { "dbColumn, entry", "dbColumn, entry", } This way, when script starts, call whole database table onResourceStart() -- I'll assume you have got a db table via dbQuery on resource start and name is table{} for k, v in pairs(table) do dbTableName[#dbTableName+1] = k..", "..v end Is tarha you have same entries as of database table but in local table within serverside, now you may call this table a 1000 times, this wont affect the performance, then onResourceStop, do this: -- I'll assume that you have dropped table from database file by 'DROP TABLE IF EXISTS' statement... -- Now you can call the dbTableName{} and save its entries by this: for k, v in pairs(dbTableName) do local val = split(v, ", ") dbExec( connection, "INSERT INTO table_name VALUES (?,?)", val[1], val[2] ) end This is called simple callBack, you just used dbExec two times within script and see, you have the same entries in dbTable plus server performance won't be affected even at poor VPS hosts and with 100 db calls a minute I hope that helped you with performance issues, there are tons of more issues like this...
  14. mathematics won't leave your brain till death
×
×
  • Create New...