Jump to content

Snow-Man

Members
  • Posts

    350
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Snow-Man

  1. Still doesnt work on check if the horse exists or not, same problem as mine since the beginning
  2. Thank you so much @IIYAMA thats really helps me a lot to fix the mess that i have already did. what confuses me that when i get table into another tables inside and when i try to get a return from what?
  3. Hello everyone, while im working on my script i have got a little problem about checking if the horse id exists on the farm or not, im lost through a lot of tables this part shows the creation of the table farmID[id] = {} local f = {marker = marker, id=id, location={x, y, z}, owner = nil, creator=player, CreationTime = getTickCount(), price=price, horses={}} farm[id] = {} table.insert(farm[id], f) horseID = {} function createhorse(player, ID, farmid) if not ID and type(ID) ~= "number" then outputChatBox("Incorrect ID, correct command /createhorse [horse ID] [farm ID]", player, 255, 0,0) return false end if not farmid and type(farmid) ~="number" then outputChatBox("Incorrect farmID, correct command /createhorse [horse ID] [farm ID]", player, 255, 0,0) return false end if horseID[ID] then outputChatBox("horse ID already exists", player, 255 ,0 ,0) return false end if farm[farmid] then for i, v in ipairs(farm[farmid]) do if v.horses == ID then outputChatBox("this horse already exist in the farm", player, 255, 0,0) end end end if not farm[farmid] then outputChatBox("Farm ID doesnt exist", player, 255, 0,0) return false end if farm[farmid] and not horseID[ID] then for i, v in ipairs ( farm[farmid] ) do if v.horses ~= horseID[ID] then local x, y, z = getElementPosition( player ) local _, _, rz = getElementRotation( player ) local horse = createPed( 0, x, y, z, rz) table.insert(v.horses,ID) else outputChatBox("ERROR #1", player, 255, 0,0) end end end end this works well but it doesnt work on the part of checking if the horse exists in the farm or not exactly this part for i, v in ipairs ( farm[farmid] ) do if v.horses ~= horseID[ID] then end end thank you everyone for taking the time to read this
  4. @Shady1 thank you so much for helping, your example really made me understand the table insert, its really works well now
  5. function addKill(name, num) if (not name or not num) then return false end if (not topKillers[name] ) then topKillers[name] = {name, 0} end local key = getKeyFromVal(topKillers, name) if topKillers[key][1] == name then topKillers[key][2] = topKillers[key][2] + num end end its already the same nothing changed, its only sorts the saved table
  6. @roaddogHello, thank you for helping i have used your example, it sorts the table from data i mean this tkill = {{"aa", 10}, {"bb", 2}, {"cc", 5}} but when add more data, it doesnt sort them, i have already made this to sort function sortKills() table.sort(topKillers, function (a, b) return a[2] > b[2] end) return topKillers end and i tried to get the top killers on dx text like the following code for i, v in pairs ( sortKills() ) do slot = slot + 1 if slot <= 5 then xy = xy + 51 textKill = ("( "..tostring( v[2] ).." ) | "..tostring(( v[1] )) ) or "( N/A ) | N/A" dxDrawRectangle(8, 282+xy, 182, 49, tocolor(0, 0, 0, 175), false) dxDrawText(textKill , 9, 282+xy, 191, 331+xy, tocolor(255, 255, 255, 255), 1.25, "default-bold", "center", "center", false, false, false, false, false) end end so, in the final output i get this result ( 10 ) | aa ( 5 ) | cc ( 2 ) | bb ( 7 ) | Ben
  7. Already tried that but didn't work
  8. hello everyone i have a problem on my script that doesnt sort data when it gets new data into it function getKillStats() table.sort(topKillers, function (a, b) return a[1] < b[1] end ) return topKillers end how i add the new data by this way if topKillers[k] then topKillers[k] = topKillers[k] + 1 else topKillers[k] = 1 end
  9. hello, i have started working on safeareas script by using slothbot for protection but bots attacks me whatever happens even if i cancel that addEvent("onPlayerHitSafeZone", true) addEventHandler("onPlayerHitSafeZone", root, function() if getElementType(source) == "player" then for i, v in ipairs(getElementsByType( "ped" ) ) do if getElementData(v, "slothbot") then createBlipAttachedTo( v, 21) if (getElementData(v, "BotTeam") == getTeamName(getPlayerTeam(source))) then setElementData(v, "attacking", false) setElementData(v, "target", false) iprint("friendly mode") else setElementData(v, "attacking", true) setElementData(v, "target", source) iprint("unfriendly mode..") end end end end end ) if that code isnt right, whats the solution to give bots order to hit or cancel attack
  10. I have already did one like this dxSetRenderTarget(texture, true) dxDrawText(500, 500, 240, 250, .....) dxSetRenderTarget () dxDrawImage(500, 500, 120, 125, image...) But the same problems doesn't display, when i apply the texture the text just disappear
  11. local sX, sY = guiGetScreenSize() local texture = dxCreateRenderTarget( 426, 449) function dxDrawAnimWindow(text,height,width,color,font,anim, core) btwidth = width btheight = height/20 local tick = getTickCount() local elapsedTime = tick - start local endTime = start + 1500 local duration = endTime - start local progress = elapsedTime / duration local x1, y1, z1 = interpolateBetween ( 0, 0, 0, width, height, 255, progress, anim) local x2, y2, z2 = interpolateBetween ( 0, 0, 0, btwidth, btheight, btheight/11, progress, anim) posx = (sX/2)-(x1/2) posy = (sY/2)-(y1/2) max = string.len(core) local scrolling = (( scrollManager/max )*10) dxRectangle ( posx, posy-y2, x2, y2, color ) dxRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) dxRectangle((x1+x2),posy, 12, 449, tocolor(0, 0, 0, 200), false) dxRectangle((x1+x2)+2, (posy+2)+max*scrolling, 8, 35, tocolor(25, 25, 25, 150), false) dxSetRenderTarget( texture, true) dxText ( core, posx+2, posy-max*scrolling, 854, 624, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) dxSetRenderTarget() dxDrawImage(posx+2, posy, 426, 449, texture,0, 0, 0, tocolor(255, 255, 255, 100), false) dxText ( text, 0, -(y1)-y2, sX, sY, tocolor ( 255, 255, 255, 255 ), z2,font,"center","center") end i have edited it but still the same problem, i have even tried on independent script but doesn't work too
  12. Yes, i changed that in the end when i wanted to make the text get the right size, I know it doesn't have the right positions but it's not the problem
  13. local sX,sY = guiGetScreenSize() local texture = dxCreateRenderTarget( 426, 449) function dxDrawAnimWindow(text,height,width,color,font,anim, core) btwidth = width btheight = height/20 local tick = getTickCount() local elapsedTime = tick - start local endTime = start + 1500 local duration = endTime - start local progress = elapsedTime / duration local x1, y1, z1 = interpolateBetween ( 0, 0, 0, width, height, 255, progress, anim) local x2, y2, z2 = interpolateBetween ( 0, 0, 0, btwidth, btheight, btheight/11, progress, anim) posx = (sX/2)-(x1/2) posy = (sY/2)-(y1/2) max = string.len(core) local scrolling = (( scrollManager/max )*10) dxRectangle ( posx, posy-y2, x2, y2, color ) dxRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) dxImage((x1*1.7), posy+12, (z2/2)+7, z1+183, "file/scroll_b.png",false) dxImage((x1*1.7), (posy+12)+max*scrolling, (z2/2)+7, z2+25, "file/scroll.png",false) local rtW, rtH = dxGetMaterialSize(texture) dxSetRenderTarget( texture, true) dxText ( core, posx+2, posy-max*scrolling, rtW, rtH, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) dxSetRenderTarget() dxDrawImage(posx+2, posy, rtW, rtH, texture,0, 0, 0, tocolor(255, 255, 255, 0), false) dxText ( text, 0, -(y1)-y2, sX, sY, tocolor ( 255, 255, 255, 255 ), z2,font,"center","center") if isMouseInPosition(((x1+x2)-3)*0.855, (posy-y2)-5, 750, 170) then dxText("X", ((x1+x2)-3)*0.855, (posy-y2)-5, 750, 170, tocolor(255, 255, 255, 255), 1.2, "bankgothic", "left", "center", false, false, false, false, false) else dxText("X", ((x1+x2)-3)*0.855, (posy-y2)-5, 750, 170, tocolor(255, 255, 255, 255), 0.9, "bankgothic", "left", "center", false, false, false, false, false) end end Hello @Addlibs thank you for replying the variable of core is long text contains around 400 letters and the variable of scrollManager = 0 and it goes by 1 or -1 even trying to scroll down or up
  14. Thank you for the reply. whats vultaic MGM? i have 2 problems, the first that the text isnt showing on the texture that already applied im trying to make it scrollable text and second there is no sync between scrolling action and the text
  15. Hello, i have been trying to make scrollable text using dxSetRenderTarget but it doesnt work when i apply the render here is the part of the code everything works fine till i apply it then it doesnt show up posx = (sX/2)-(x1/2) posy = (sY/2)-(y1/2) max = string.len(core) local scrolling = (( scrollManager/max )*10) dxRectangle ( posx, posy-y2, x2, y2, color ) dxRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) dxImage((x1+x2), posy+12, (z2/2)+7, z1+183, "file/scroll_b.png",false) dxImage((x1+x2), (posy+12)+max*scrolling, (z2/2)+7, z2+25, "file/scroll.png",false) local rtW, rtH = dxGetMaterialSize(texture) dxSetRenderTarget( texture, true) dxText ( core, posx+2, posy-max*scrolling, x1*1.997, y1*1.389, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) dxSetRenderTarget() dxDrawImage(posx+2, posy, rtW, rtH, texture,0, 0, 0, tocolor(255, 255, 255, 0), false) and there is no synchronization between the text and scroll icon
  16. Hello ?? I have got that problem before while working on custom animations. Firing with weapon but it's not in hand and at the same can not switch to another weapons How i solved it by stopping the resource and reconnecting.
  17. thank you so much for helping, i have changed a lot on the code and mixed between what you write here and my code and works well even selectedItem = 1 now it works on continuous list
  18. this is the part of the loop and now i have an error when i reach the end of the table this error attempt to index field "?" (a nil value ) exactly the error comes from "i" this one -> for i=startIndex, startIndex+maxShownItems do local startIndex = 1 local maxShownItems = 8 addEventHandler("onClientRender", root, function() for i=startIndex, startIndex+maxShownItems do local xy = (i-startIndex)*29 if i ~= startIndex then dxDrawBorderedText(1,(" "..skinTable[i].name.." "..skinTable[i].price.."$"), (985/x)*sx, (sy*0.40)+xy, (1258/x)*sx, (646*y)/sy, tocolor(255, 255, 255, 255), scale, "bankgothic", "left", "top", false, false, false, false, false) else dxDrawBorderedText(1,(" "..skinTable[i].name.." "..skinTable[i].price.."$"), (985/x)*sx, (sy*0.40)+xy, (1258/x)*sx, (646*y)/sy, tocolor(255, 255, 0, 255), scale, "bankgothic", "left", "top", false, false, false, false, false) end end end ) i have changed this part and it works better and having the result what i wanted for addEventHandler( "onClientKey", root, function(b, state) if b and validKeys[b] then if b == "arrow_u" and state then if startIndex-1 > 0 then startIndex = startIndex - 1 else startIndex = #skinTable end playSoundFrontEnd(1) elseif b == "arrow_d" and state then if startIndex+1 <= #skinTable then startIndex = startIndex + 1 else startIndex = 1 end playSoundFrontEnd(1) end end end )
  19. I have changed from the code that you already posted to local maxShownItem = 8 And table contains almost 385 data
  20. You have to reduce number of z rotation setElementRotation(peds,0,0,pz + (x/100))
  21. Thank you it's works but had another problem it doesn't select last 8 data from the table It selects only lower than #skinTable-maxShownItem In my case local maxShownItem = 8
  22. Hello everybody, i have started on new script but faced some troubles on showing data through index of the tables, didnt know the right calculation for that and trying to make it only shows 8 data at once here part of my code where i found ther problem on it if i ~= index then dxDrawBorderedText(1," "..skinTable[index].name.." "..skinTable[index].price.." $", (985/x)*sx, ((356*y)/sy)*((index*52)/#skinTable), (1258/x)*sx, (646*y)/sy, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) else iprint(((356*y)/sy)*((index*30)/#skinTable)) dxDrawBorderedText(1," "..skinTable[index].name.." "..skinTable[index].price.." $", (985/x)*sx, ((356*y)/sy)*((index*52)/#skinTable), (1258/x)*sx, (646*y)/sy, tocolor(255, 255, 0, 255), 1.2, "bankgothic", "left", "top", false, false, false, false, false) end explaining some variables i = 1 index starts from 1 and follow i but that works fine and #skinTable, the result for that is 385 its a long table this is the result of my code https://imgur.com/Ly2OqZW and what i expected to have https://imgur.com/yFAw6or
  23. already did that before but doesnt work tried on capred but nothing works
  24. yes its possible by using the following functions -getPlayerSerial - givePlayerMoney -getAccount -addEvent -addEventHandler and others table as attached to the source ( the player who is going to create a new account ) and a lot of customized functions if you need any help i can help you more on it
  25. Yes, i have already used that but when i use texture name from that script it will apply on all part for example i have used this texture cj_ped_hat to apply shader on specific hat but sadly it has been applied on all hats i needed to apply it on redcap hat but when i used it doesnt work only worked for me is cj_ped_hat
×
×
  • Create New...