Jump to content

Ayush Rathore

Members
  • Posts

    156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Ayush Rathore

  1. i think he need this addEventHandler('onClientRender', root, function() dxDrawImageSection(400, 200, 64, 64, 0, 0, 64, 64, 'img.jpg') -- Draw a certain section dxDrawImage(400, 300, 128, 128, 'img.jpg') -- Draw the whole image to be able to identify the difference end) use this image
  2. no this will do you need local query = dbQuery(database, "SELECT * FROM players") local result = dbPoll(query,-1) for x, ad in ipairs( result ) do outputChatBox(result[x]['dataname']) end local query = dbQuery(database, "SELECT * FROM players") local result = dbPoll(query,-1) for x, ad in ipairs( result ) do for i, v in ipairs( {'kills','deaths','money'} ) do outputChatBox(result[x][v]) end end this is for multiple is my code working ?
  3. well he has not given full script
  4. no problem as now you know
  5. login as admin in server and type /debugscript 2 in chat and then start this resource and then tell the error it cause you will see the error in middle bottom with red color
  6. use this local query = dbQuery(database, "SELECT * FROM players") local result = dbPoll(query,-1) for _, ad in ipairs( result ) do end u see dbQuery is only prepare statement and to actually finding result set you should use dbPoll P.S quote me (so that i can get notification)
  7. you should use the default mta freeroam resource for your server as it would be bug free
  8. it will give error as result set starts from 1
  9. tell me first where the serial is present
  10. well as you can see tab is the result set of query so it starts from tab[1] and so on #tab is the count of result set meaning result set contains x no of student for i=0,#tab do end will iterate all the values you use Last thing if you can't understand me please let me know
  11. pm script function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end else return false end end function sendMess(from,to,message) if from ~= to then if message == "" then outputChatBox("No Message given", thePlayer, 255, 0, 0) return false else outputChatBox("PM to "..getPlayerName(to).." : "..message, from, 238, 232, 84) outputChatBox("PM from "..getPlayerName(from).." : "..message, to, 236, 205, 45) outputChatBox("Use /re [message] to answer.", to, 236, 205, 45) setElementData(from, "pmPartner", to) setElementData(to, "pmPartner", from) end else outputChatBox("You can't speak to your self.", from, 255, 0, 0) return false end end function privateMessage(thePlayer,cmd,sendToName,...) local message = table.concat({...}, " ") local name = getPlayerFromPartialName(sendToName) local player = exports.idres:getPlayerFromID(tonumber(sendToName)) local b = 0 if player then b = 1 sendMess(thePlayer,player,message) return true end if name then b = 1 sendMess(thePlayer,name,message) return true end if b == 0 then outputChatBox("No Player Found", thePlayer, 255, 0, 0) end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, commandName, _, ...) local message = table.concat({...}, " ") local pmblocked = getElementData(thePlayer, "pmblocked") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if tonumber(pmblocked) == 1 then outputChatBox("This person has disable his pm try later.", thePlayer, 255, 0, 0, true) else sendMess(thePlayer,toPlayer,message) end else outputChatBox("None is pming you!", thePlayer, 255, 0, 0, true) end end addCommandHandler("re", privateMessageReply) id resource's x.lua ID = { } exports["scoreboard"]:scoreboardAddColumn("ID", root, 20, "ID", 1) -------------------------- [ Events ] -------------------------- addEventHandler("onPlayerJoin", root, function() for i = 1, getMaxPlayers() do if not ID[i] then ID[i] = source setElementData(source, "ID", i) break; end end end) -- addEventHandler("onPlayerQuit", root, function() ID[getPlayerID(source)] = nil end) -- addEventHandler("onResourceStart", resourceRoot, function() for _, v in ipairs(getElementsByType("player")) do for i =1 ,getMaxPlayers() do if not ID[i] then ID[i] = v setElementData(v, "ID", i) break; end end end end) -------------------------- [ Functions ] ----------------------- function getPlayerID(thePlayer) if thePlayer and isElement(thePlayer) and getElementType(thePlayer) == "player" and getElementData(thePlayer, "ID") then return getElementData(thePlayer, "ID") end return false end -- function getPlayerFromID(id) if id and tonumber(id) and ID[tonumber(id)] then return ID[tonumber(id)] end return false end now id resource's meta.xml <meta> <script src="x.lua" type="server" /> <export function="getPlayerFromID" type="server" /> </meta> Hope that will fulfill your needs
  12. function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end else return false end end function privateMessage(thePlayer,cmd,sendToName,...) local message = table.concat({...}, " ") if type(sendToName) == 'number' then player = exports.id_reso:getPlayerFromID(sendToName) if player then toPlayer = player if toPlayer ~= thePlayer then if message == "" then outputChatBox("No Message given", thePlayer, 255, 0, 0) return false else outputChatBox("PM to "..getPlayerName(toPlayer).." : "..message, thePlayer, 238, 232, 84) outputChatBox("PM from "..getPlayerName(thePlayer).." : "..message, toPlayer, 236, 205, 45) outputChatBox("Use /re [message] to answer.", thePlayer, 236, 205, 45) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) end else outputChatBox("You can't speak to your self.", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found.", thePlayer, 255, 0, 0) return false end else local name = getPlayerFromPartialName(sendToName) if name then toPlayer = name if toPlayer ~= thePlayer then if message == "" then outputChatBox("No Message given", thePlayer, 255, 0, 0) return false else outputChatBox("PM to "..getPlayerName(toPlayer).." : "..message, thePlayer, 238, 232, 84) outputChatBox("PM from "..getPlayerName(thePlayer).." : "..message, toPlayer, 236, 205, 45) outputChatBox("Use /re [message] to answer.", thePlayer, 236, 205, 45) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) end else outputChatBox("You can't speak to your self.", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found.", thePlayer, 255, 0, 0) return false end end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, commandName, _, ...) local message = table.concat({...}, " ") local pmblocked = getElementData(thePlayer, "pmblocked") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if message ~= "" then outputChatBox("PM to "..getPlayerName(toPlayer).." : "..message, thePlayer, 238, 232, 84, true) outputChatBox("PM from "..getPlayerName(thePlayer).." : "..message, toPlayer, 236, 205, 45, true) outputChatBox("Use /re [message] to answer.", toPlayer, 236, 205, 45, true) else outputChatBox("SYNTAX: /"..commandName.." [message]", thePlayer, 255, 0, 0, true) end if pmblocked == 1 then outputChatBox("This person has disable his pm try later.", thePlayer, 255, 0, 0, true) end else outputChatBox("None is pming you!", thePlayer, 255, 0, 0, true) end end addCommandHandler("re", privateMessageReply) after copying it change the export function resource to your id resource in the above player = exports.id_reso:getPlayerFromID(sendToName) and and in meta.xml of id resource add <export function="getPlayerFromID" type="server" />
  13. after seeing your code it should be this local ping = getPlayerPing(getLocalPlayer()) local x, y = guiGetScreenSize ( ) local posA,posB = x*0.95,y*0.03 local posC,posD = x*0.87,y*0.03 local root = getRootElement() local player = getLocalPlayer() local counter = 0 local starttick local currenttick addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(player,"FPS",counter) counter = 0 starttick = false end end ) function drawStates () addEventHandler ( "onClientRender", root, pingState ) addEventHandler ( "onClientRender", root, fpsState ) end addEventHandler ( "onClientResourceStart", resourceRoot, drawStates ) function fpsState() local ping = getPlayerPing(getLocalPlayer()) dxDrawText ( "FPS:"..getElementData(getLocalPlayer(),"FPS"), posA, posB, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" ) dxDrawText ( "PING:"..ping.." ms", posC, posD, x, y, tocolor ( 30, 144, 255, 255 ), 1.0, "default-bold" ) end fileDelete("client.lua") it will fit all res think sx*0.1 as 1/10 of sx and sy*0.1 as 1/10 of sy so sy*0.2 will be 2/10 of sy for example if sx = 1366 and sy =768 then sx*0.1 = 136.6 sx*0.2 = (136.6*2) well i am not good at making people understand but few example above can click your brain on how i did it
  14. give that id script that i can tell ?
  15. By making them relative like local sx,sy = guiGetScreenSize() posX,posY = sx*0.1,sy*0.1 posX,posY will be same for all resolution relative starts from 0.0 to 1.0
  16. tell me the position of database you want to backup
  17. yes you are wrong as setTimer will provide vehicle as a parameter and what you wrote will cause the error this [16:16:11] WARNING: lol\x.lua:91: Bad argument @ 'destroyElement' [Expected elem ent at argument 1, got nil] [16:16:11] WARNING: lol\x.lua:91: Bad argument @ 'setTimer' [Expected function a t argument 1, got boolean]
  18. addEvent("backpackGroundOpen",true) addEventHandler("backpackGroundOpen",getRootElement(),function() if isPedInVehicle(source) then return end if isElementInWater(source) then return end setPedAnimation(source,"BOMBER","BOM_Plant_Loop",1000,true,false,false,false) local x,y,z = getElementPosition(source) prot = getPedRotation(source) local offsetRot = math.rad(prot+90) local vx = x + 0.75 * math.cos(offsetRot) local vy = y + 0.75 * math.sin(offsetRot) local vrot = prot+180 local backpackSlots = getElementData(source,"MAX_Slots") if (backpackSlots == 12 or backpackSlots == 16) then backpackGround[source] = createObject(1866,vx,vy,z-0.8,100,180,vrot) elseif (backpackSlots == 13 or backpackSlots == 17) then backpackGround[source] = createObject(1867,vx,vy,z-0.8,100,180,vrot) elseif (backpackSlots == 20 or backpackSlots == 24) then backpackGround[source] = createObject(1868,vx,vy,z-0.8,100,180,vrot) elseif (backpackSlots == 25 or backpackSlots == 29) then backpackGround[source] = createObject(1869,vx,vy,z-0.9,100,180,vrot) elseif (backpackSlots == 30 or backpackSlots == 34) then backpackGround[source] = createObject(1870,vx,vy,z-0.8,100,180,vrot) elseif (backpackSlots == 35 or backpackSlots == 39) then backpackGround[source] = createObject(1871,vx,vy,z-0.75,-70,0,vrot) end if elementBackpack[source] and isElement(elementBackpack[source]) then setElementAlpha(elementBackpack[source],0) end end) Try This
  19. function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end else return false end end function privateMessage(thePlayer,cmd,sendToName,...) local message = table.concat({...}, " ") local name = getPlayerFromPartialName(sendToName) if name then toPlayer = name if toPlayer ~= thePlayer then if message == "" then outputChatBox("No Message given", thePlayer, 255, 0, 0) return false else outputChatBox("PM to "..getPlayerName(toPlayer).." : "..message, thePlayer, 238, 232, 84) outputChatBox("PM from "..getPlayerName(thePlayer).." : "..message, toPlayer, 236, 205, 45) outputChatBox("Use /re [message] to answer.", thePlayer, 236, 205, 45) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) end else outputChatBox("You can't speak to your self.", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found.", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, commandName, _, ...) local message = table.concat({...}, " ") local pmblocked = getElementData(thePlayer, "pmblocked") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if message ~= "" then outputChatBox("PM to "..getPlayerName(toPlayer).." : "..message, thePlayer, 238, 232, 84, true) outputChatBox("PM from "..getPlayerName(thePlayer).." : "..message, toPlayer, 236, 205, 45, true) outputChatBox("Use /re [message] to answer.", toPlayer, 236, 205, 45, true) else outputChatBox("SYNTAX: /"..commandName.." [message]", thePlayer, 255, 0, 0, true) end if pmblocked == 1 then outputChatBox("This person has disable his pm try later.", thePlayer, 255, 0, 0, true) end else outputChatBox("None is pming you!", thePlayer, 255, 0, 0, true) end end addCommandHandler("re", privateMessageReply) Try This
  20. function baseCopy() local randomName = randomString(10) local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year local res = getResourceName(getThisResource()) local pathtocopy = ":"..res.."/".."database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db" fileCopy("database.db",pathtocopy) end Try This
  21. wait i will correct it ang give it to you function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end else return false end end function payScript(player,cmd,other,amount) local name = getPlayerFromPartialName(other) local atg local rpm = getPlayerMoney(player) local err = {} if name == false then err[#err+1] = "Name not specified correctly." end if tonumber(amount) < 0 then err[#err+1] = "Amount can't be negative." end atg = tonumber(amount) if (rpm-atg) < 0 then err[#err+1] = "Given amount is more than yours." end if(player == name) then err[#err+1] = "You can't give it to yourself." end if #err == 0 then setPlayerMoney(name,atg) outputChatBox("Given:"..atg.." to:"..getPlayerName(name),player,0,255,0) setPlayerMoney(player,(rpm-atg)) outputChatBox("Left:"..(rpm-atg).." to you.",player,0,255,0) else for i=1,#err do outputChatBox(err[i],player,0,255,0) end end end addCommandHandler( "pay", payScript ) Try this
×
×
  • Create New...