Jump to content

Ayush Rathore

Members
  • Posts

    156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Ayush Rathore

  1. using html https://community.multitheftauto.com/index.php?p=resources&s=details&id=12905 this might help you
  2. https://wiki.multitheftauto.com/wiki/OnPlayerLogin go there you will get to know why i used this _,acc thingy and also to see that table thingy you need to logout and login again
  3. addEventHandler("onResourceStart", resourceRoot, function (resource) connectionDb = dbConnect("sqlite", "user_settings.db") if connectionDb then outputDebugString( "Connection with database was successfully established." ) dbExec(connectionDb,"create table if not exists settings(playerName TEXT, carReflect NUMBER, water NUMBER, contrast NUMBER, detail NUMBER, sky NUMBER, showFps NUMBER)") else outputDebugString( "Connection with database couldn't be established." ) end end ) function playerLogin(_,acc) local accName = getAccountName(acc) local playerQuery = dbQuery(connectionDb,"SELECT * FROM settings WHERE playerName=?",accName) local playerQueryResult = dbPoll(playerQuery, -1) if #playerQueryResult == 0 then -- if he is new user local createPlayerIndex = dbExec(connectionDb, "INSERT INTO settings VALUES(?,?,?,?,?,?,?)",accName,1,1,1,1,1,1) else -- if he is old user then load here -- do your stuff for rid, row in pairs (playerQueryResult) do -- row represents the tables that are in 'playerQueryResult', which represent the rows for column, value in pairs (row) do -- column represents column name, value represents column value outputChatBox(column..', '..value) end end end end addEventHandler("onPlayerLogin", getRootElement(), playerLogin) run this thing you will get to know everything btw delete your old user_settings.db @DriFtyZ @DriFtyZ login logout or reconnect and login to check it
  4. your first column is of type integer so how could you write a text in it ?
  5. Try this addEventHandler("onResourceStart", resourceRoot, function (resource) connectionDb = dbConnect("sqlite", "user_settings.db") if connectionDb then outputDebugString( "Connection with database was successfully established." ) dbExec(connectionDb,"create table if not exists settings(id INTEGER PRIMARY KEY, playerName TEXT, carReflect NUMBER, water NUMBER, contrast NUMBER, detail NUMBER, sky NUMBER, showFps NUMBER)") else outputDebugString( "Connection with database couldn't be established." ) end end ) function playerLogin(_,acc) local accName = getAccountName(acc) local playerQuery = dbQuery(connectionDb,"SELECT * FROM settings WHERE playerName=?",accName) local playerQueryResult = dbPoll(playerQuery, -1) if #playerQueryResult == 0 then local createPlayerIndex = dbExec(connectionDb, "INSERT INTO settings VALUES(?,?,?,?,?,?,?,?)",1,1,1,1,1,1,1,1) end end addEventHandler("onPlayerLogin", getRootElement(), playerLogin)
  6. also u should use some debugging statement like this function playerLogin(source) local playerAcc = getPlayerAccount(source) local accName = getAccountName(source) local playerQuery = dbQuery(connectionDb,"SELECT * FROM settings WHERE playerName='..accName..'") local playerQueryResult = dbPoll(playerQuery, -1) if #playerQueryResult == 0 then outputDebugString(getPlayerName(source).." Creating new settings") local createPlayerIndex = dbExec(connectionDb, "INSERT INTO settings (playerName,carReflect,water,contrast,detail,sky,showFps) VALUES ('..accName..', 1, 1, 1, 1, 1, 1") if createPlayerIndex then outputDebugString(getPlayerName(source).." Creating new settings went successful.") else outputDebugString(getPlayerName(source).." Creating new settings failed check your db connection.") end end end addEventHandler("onPlayerLogin", resourceRoot, playerLogin)
  7. Selling mistake see function playerLogin(source) local playerAcc = getPlayerAccount(source) local accName = getAccountName(source) local playerQuery = dbQuery(connectionDb,"SELECT * FROM settings WHERE playerName='..accName..'") local playerQueryResult = dbPoll(playerQuery, -1) if #playerQueryResult == 0 then local createPlayerIndex = dbExec(connectionDb, "INSERT INTO settings (playerName,carReflect,water,contrast,detail,sky,showFps) VALUES ('..accName..', 1, 1, 1, 1, 1, 1") end end addEventHandler("onPlayerLogin", resourceRoot, playerLogin) its dbQuery not dbQuerry
  8. https://community.multitheftauto.com/index.php?p=resources&s=details&id=12448 this resource might help you
  9. function attackIntruderA51 () local t={} t[#t+1] = createProjectile (localPlayer, 20, 15.49994, 1719.1, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) t[#t+1] = createProjectile (localPlayer, 20, 237.7, 1696.8, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) for _,projectile in pairs (t) do for i,v in pairs(getAttachedElements(projectile)) do if (getElementType(v)=='blip') then setBlipColor(v,255,0,0,255); end end end end addCommandHandler ("attack", attackIntruderA51) Use this it might fulfill your need
  10. Ayush Rathore

    Help.

    @JanKy mix your "onClientResourceStart" functions into one function and also put night_init() in the first line of function like this function loadShaders () InselMapStart() night_init() for path,texstures in pairs (shaderMap) do local shader = dxCreateShader('shader.fx') table.insert(shaderList, shader) local terrain = dxCreateTexture(path) dxSetShaderValue(shader, 'gTexture', terrain) for i,txd in ipairs (texstures) do engineRemoveShaderFromWorldTexture(nightShader, txd) engineApplyShaderToWorldTexture(shader,txd) end end end addEventHandler( "onClientResourceStart", resourceRoot, loadShaders )
  11. if you need any scripting help you should go to this link https://wiki.multitheftauto.com/ for a proper understanding on how we pass Parameter in Mta functions
  12. provide the Gui Creation code like guiCreate window and and guiCreateGridlist etc .
  13. function playerDropAItem(itemName) local player = client if client then local x,y,z = getElementPosition(player) local item,itemString = getItemTablePosition(itemName) local itemPickup = createItemPickup(item,x+math.random(-1.25,1.25),y+math.random(-1.25,1.25),z,itemString) end end addEvent( "playerDropAItem", true ) addEventHandler( "playerDropAItem", getRootElement(),playerDropAItem) This might help you
  14. MY : WeaponSaver.lua addEventHandler("onPlayerWasted", root, function() local weapons = getWeaponsOfPlayers(source) setElementData(source,"isDead",true) setElementData(source,"tWeapons",weapons) end ) addEventHandler("onPlayerSpawn", root, function () local weapons = getElementData(source,"tWeapons") setElementData(source,"isDead",false) if (weapons) then giveWeaponsOfPlayer(source, weapons) end end ) function getWeaponsOfPlayer(player) local weaponSlots = 12 local weaponsTable = {} for slot=1, weaponSlots do local weapon = getPedWeapon( source, slot ) local ammo = getPedTotalAmmo( source, slot ) if (weapon > 0 and ammo > 0) then weaponsTable[weapon] = ammo end end return toJSON(weaponsTable) end function giveWeaponsOfPlayer(player, weapons) if (weapons and weapons ~= "") then for weapon, ammo in pairs(fromJSON(weapons)) do if (weapon and ammo) then giveWeapon(player, tonumber(weapon), tonumber(ammo)) end end end end addEventHandler( "onPlayerLogin",root, function( ) local acc = getPlayerAccount( source ) if acc then local weap = getAccountData( acc,'Player:weapons' ) if weap then giveWeaponsOfPlayer(source, weap) end end end ) addEventHandler( "onPlayerQuit",root, function( ) local acc = getPlayerAccount( source ) if acc and not isGuestAccount( acc ) then if getElementData(source,"isDead") == true then local weap = getElementData(source,"tWeapons") setAccountData( acc,"Player:weapons",weap ) else local weap = getWeaponsOfPlayer(source) setAccountData( acc,"Player:weapons",weap ) end end end ) P.S : Your spawn.lua outputServerLog ( "***Spawn Script Loaded ***" ) local PlayersTeam = createTeam ( "Players" ) setTeamFriendlyFire ( PlayersTeam, false ) local spawnX, spawnY, spawnZ = math.random(-694,-679), math.random(951,963), 17 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) setPlayerTeam(source, PlayersTeam ) outputChatBox("#FF00DC"..getPlayerName(source).." #ff0000Welcome To K#ff4000e#ff7f00w#ffbf00i#ffff00z#00ff00z#00ff80l#00ffffe#0080ff'#0000ffs Zombie Server, :O :O. Press \"F9\" For HELP", source, r, g, b, true) end addEventHandler ( "onPlayerLogin", getRootElement(), joinHandler ) function deathHandler() setTimer( function(source) spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) end,2000,1,source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) enjoy and please like if it fits your need:)
  15. i have edited it read above just change lx*(below 1700)
  16. so my Tutorial works now see x/2-248/2 (i have done it so that it stays always in the middle of screen) x = 1920 and width = 248 so 1920/2 = is half of screen and from that - 248/2 is half width of window making it in the middle to your problem change line one to this x,y = guiGetScreenSize() fx,fy = 1920,1080 lx,ly = x/fx,y/fy posX,posY = lx*1300,ly*200 width,height = 248,284 DogCreate.Window = guiCreateWindow(posX,posY,width,height, "", false)
  17. This will fulfill your need x,y = guiGetScreenSize() DogCreate = {} addEventHandler("onClientResourceStart", resourceRoot, function() -- window DogCreate.Window = guiCreateWindow(x/2-248/2, y/2-284/2, 248, 284, "", false) --button DogCreate.BuyButton = guiCreateButton(0.14, 0.79, 0.71, 0.18, "Purchase Dog", true, DogCreate.Window) --main label DogCreate.WindowLab = guiCreateLabel(0.03, 0.13, 0.92, 0.10, "Dog Creator", true, DogCreate.Window) --editbox label DogCreate.NameLab = guiCreateLabel(0.05, 0.29, 0.24, 0.10, "Name:", true, DogCreate.Window) DogCreate.BreedLab = guiCreateLabel(0.05, 0.40, 0.24, 0.10, "Breed:", true, DogCreate.Window) DogCreate.ColorLab = guiCreateLabel(0.05, 0.52, 0.24, 0.10, "Color:", true, DogCreate.Window) --radiobutton DogCreate.MaleRadio = guiCreateRadioButton(0.34, 0.68, 0.15, 0.06, "M", true, DogCreate.Window) DogCreate.FemaleRadio = guiCreateRadioButton(0.53, 0.68, 0.15, 0.06, "F", true, DogCreate.Window) --editbox DogCreate.NameBox = guiCreateEdit(0.38, 0.29, 0.53, 0.08, "", true, DogCreate.Window) DogCreate.BreedBox = guiCreateEdit(0.38, 0.39, 0.53, 0.08, "", true, DogCreate.Window) --combobox DogCreate.DogColorCombo = guiCreateComboBox(0.38, 0.50, 0.53, 0.08, "", true, DogCreate.Window) guiRadioButtonSetSelected(DogCreate.MaleRadio, true) guiLabelSetHorizontalAlign(DogCreate.ColorLab, "center", false) guiLabelSetVerticalAlign(DogCreate.ColorLab, "center") guiLabelSetHorizontalAlign(DogCreate.BreedLab, "center", false) guiLabelSetVerticalAlign(DogCreate.BreedLab, "center") guiLabelSetHorizontalAlign(DogCreate.NameLab, "center", false) guiLabelSetVerticalAlign(DogCreate.NameLab, "center") guiLabelSetHorizontalAlign(DogCreate.WindowLab, "center", false) guiLabelSetVerticalAlign(DogCreate.WindowLab, "center") guiWindowSetSizable(DogCreate.Window, false) guiWindowSetSizable(DogCreate.Window, false) guiSetAlpha(DogCreate.Window, 0.88) guiSetProperty(DogCreate.Window, "CaptionColour", "FF000000") end ) and also now to make you understand what it is x,y = guiGetScreenSize() -- for example yours 1920X1080 --to fit in all resolution fx,fy = 1920,1080 --below step will divide x into fx pieces and y into fy pieces lx,ly = x/fx,y/fy --lx ,ly now contains a value posX,posY = lx*400,ly*300 width,height = 400,300 --now lx*(as you divided your screen in 1920 parts horizontally so you can go till 1920) -- increasing will go ahead of screen --now ly*(as you divided your screen in 1080 parts verticall so you can go till 1080) -- increasing will go beyond screen --effect of width and height -- if you have created font size greater than the width it will clip the text horizontally that is what in your gui is happening -- if you have created font size greater than the height same as above addEventHandler("onClientResourceStart", resourceRoot, function() local font = guiCreateFont( "segoeui.ttf",72 ) -- for example and (second arguement is size of font) local lbl = guiCreateLabel (posX,posY,width,height,"lol my example text", true ) -- change posX,posY to test and also it might clip guiSetFont( lbl, font ) end) -- now relative time -- Imagine your screen is divided into 10 parts horizontally -- so 1920/10 = 192 -- so 0.1 = 1920 * 0.1 = 192.00 -- Imagine your screen is divided into 10 parts vertically -- so 1080/10 = 108 -- so 0.1 = 1080 * 0.1 = 108.00 -- so for width and height same as case above for relative posX,posY = 0.4,0.3 width,height = x*0.4,y*0.3 addEventHandler("onClientResourceStart", resourceRoot, function() local font = guiCreateFont( "segoeui.ttf",72 ) -- for example and (second arguement is size of font) local lbl = guiCreateLabel (posX,posY,width,height,"lol my example text", true ) -- change posX,posY to test and also it might clip guiSetFont( lbl, font ) end) well i am not good in making people understand but .. Test and give reply read my above message
  18. you should make your window size bigger like i have done in code above or give me the fonts i will set it and give it to you
  19. use this function register(username, passowrd) if client then if username ~= nil and password ~= nil then local query = dbQuery(database, "SELECT * FROM accounts WHERE username = ? AND password = ?", username, password) local result = dbPoll(query,-1) if #result > 0 then outputChatBox("Account exists", client) else outputChatBox("Account not exists", client) end end end end addEvent("register", true) addEventHandler("register", getRootElement, register) and for security reasons use client not source
×
×
  • Create New...