Jump to content

knightscript

Members
  • Posts

    127
  • Joined

  • Last visited

Everything posted by knightscript

  1. Thanks, made it work local spawn = exports["NTTC_Tables"]:getRandomLoot("Los Santos") local spawn = exports["NTTC_Tables"]:getRandomLoot("Los Santos") LV = {} LS = {} SF = {} Other = {} function displayLoadedRes ( res ) i = 1 for k,v in pairs(spawntables()) do local zone = getZoneName( v[1],v[2],v[3], true ) if (zone == "Los Santos") then LS[i] = tostring(v[1]..","..v[2]..","..v[3]) i = i+1 end end end addEventHandler ( "onResourceStart", getRootElement(getThisResource( )), displayLoadedRes ) function getRandomLoot(location) --local x,y,z = number[1], number[2], number[3] if (location == "Los Santos") then table = spawntables()[math.random ( #LS )] return table else return "other" end --return LS end Maybe its useful to someone.
  2. I tried to, wasnt able, was just able to send a string, the table I was trying to send was for example: table = [] table['x'] = x table['y'] = y table['z'] = z return table['x'],table['y'],table['z']
  3. Yes, yes, just figured out that it seems I cant send a table through an export, I tried this: outputServerLog("X = "..exports["NTTC_Tables"]:getRandomLoot("Los Santos")) and on my function function getRandomLoot(location) local number = table.random(locations_for_items_and_spawns) --outputServerLog( number[1]..","..number[2]..","..number[3] ) return "x,y,z" end result:
  4. Hello, I am trying to export a function called "getRandomLoot", which is in a resource name NTTC_Tables, I am trying to export this function to be able to use it on another resource, the function: function getRandomLoot(location) local number = table.random(locations_for_items_and_spawns) --outputServerLog( number[1]..","..number[2]..","..number[3] ) local x,y,z = number[1], number[2], number[3] local position = getZoneName ( x, y, z, true ) table = [] table['x'] = x table['y'] = y table['z'] = z return table end <meta> <script src="async.lua" type="shared" /> <script src="client.lua" type="client" cache="false"/> <script src="locations.lua" type="server"/> <script src="server.lua" type="server"/> <export function="getRandomLoot" type="server" /> <export function="spawntables" type="server" /> </meta> This function returns what I want it to when I call it on the same file, but when I try to call this function from another resource: local checkres = exports["NTTC_Tables"]:getRandomLoot("Los Santos") --doesnt work ERROR: ERROR: [NTTC]/NTTC_Account_Management/server.lua:78: attempt to call a nil value [09:06:41] ERROR: [NTTC]/NTTC_Account_Management/server.lua:75: call: failed to call 'NTTC_Tables:getRandomLoot' [string "?"] Line 79 is a timer: function test() local checkres = exports["NTTC_Tables"]:getRandomLoot("Los Santos") --<<<<< line 75 --outputServerLog("X = "..checkres['x']..", Y = "..checkres['y']..", Z ="..checkres['z']) end setTimer( test, 500, 5) --<<<< line 78 I have no idea what is wrong, im running Ubuntu 18.04.1 LTS Thanks in advance EDIT: Found out that the problem is on my function "getRandomLoot" for some reason, it works in the resource no problem but when trying to call it, it shows the error message listed above, im trying to fix it on my own, will edit if I manage to fix it and will post the fix EDIT2: Tried removing the _ from the resource name, didnt fix
  5. Thank you so much for explaining this, i will try this and update my comment with the result, one more question not exactly related, is there a way to set a weapons alpha (a gun that i give with giveGun)? thank you
  6. Thanks, I do understand, what I dont understand is how can I fade out and fade in an image? i cant manage to understand how onclientrender could work
  7. Hello, I am trying to make a script that swaps the image on screen for a new one from a table I really am lost and dont have idea what to do next, local screenW, screenH = guiGetScreenSize() local randomize2 = math.random ( #Imagens ) local alpha = 255 local current_image = "" function ImageRender(image,alpha) if getElementData (getLocalPlayer( ),"logedin") == false or getElementData (getLocalPlayer( ),"logedin") == nil then current_image = guiCreateStaticImage(0, 0, screenWidth, screenHeight, tostring(Imagens[image]), false) guiMoveToBack( current_image ) guiSetAlpha(current_image, alpha ) end end addEventHandler("onClientResourceStart", resourceRoot,ImageRender) function RenderImageSwap() if getElementData (getLocalPlayer( ),"logedin") == false or getElementData (getLocalPlayer( ),"logedin") == nil then if (alpha > 0) then newAlpha = alpha < 25 if (newAlpha < 0) then ImageRender(randomize2,255) else ImageRender(current_image,newAlpha) end end end end setTimer( RenderImageSwap, 1000, 0) This is my code right know, which unfortunately, isnt working at all, does anyone know how to make a fade out an image (set alpha to alpha - 25.5 in a duration of 10 seconds for example) and if it reaches zero, it fades the next one in (set alpha of new image to alpha + 25.5 in a duration of 5 seconds for example) thanks I really tried my best but I dont know what functions to use, was thinking on getCurrentTick but I dont get how it works
  8. well you just have to adapt the code I gave you just use getDistanceBetweenPoints3D and i dont know what you use to know if its a criminal that is trying to revive
  9. Forgive me, I wasnt at home, I will work on an example and I will send it to you, i will use 1920x1080 and make calculations there, theoretically if I do it relative it should work on any res, i will update my comment when its ready.
  10. You could use onClientClick to get the position in the screen in combination with GuiGetScreenSize (to calculate the relative screen position)
  11. You could create a PNG image thats bigger than the original one with transparency, have an onclick for it
  12. Thanks, fixed it, it seems one of the image files were missing, i still dont get why for some users it worked fine and for others it didnt,
  13. I mean, there was no need to humilliate him, you could of told him more or less what functions to use, here, tested it, CLIENT: function math.round(number) local _, decimals = math.modf(number) if decimals < 0.5 then return math.floor(number) end return math.ceil(number) end local revive_percentage = 0 local timer = 0 function add_percentage_per_second() if (revive_percentage < 100) then revive_percentage = revive_percentage + 1.25 if (revive_percentage >= 100) then setPedAnimation(getLocalPlayer()) removeEventHandler("onClientRender", getRootElement(), start_revive_process) revive_percentage = 0 end end end local screenW, screenH = guiGetScreenSize() function start_revive_process() if (revive_percentage == 0) then setTimer(add_percentage_per_second,62.5,80) --ads a timer that executes once every second for 5 seconds, adding 20% each time. setPedAnimation(getLocalPlayer( ),"ped","FLOOR_hit_f",-1,false) --start anim revive_percentage = revive_percentage+1 end dxDrawText(math.round(revive_percentage).."%", screenW * 0.4802, screenH * 0.9500, screenW * 0.5198, screenH * 0.9694, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, false, true, false, false) dxDrawRectangle(screenW * 0.4219, screenH * 0.9491, screenW * 0.1568, screenH * 0.0204, tocolor(255, 255, 255, 255), false) dxDrawRectangle(screenW * 0.4219, screenH * 0.9491, screenW * revive_percentage/638, screenH * 0.0204, tocolor(255, 0, 0, 255), false) end function StartReviveClient() addEventHandler( "onClientRender", getRootElement(), start_revive_process ) end addEvent( "startrevive", true ) addEventHandler( "startrevive", getRootElement( ), StartReviveClient ) and add this on your server side, I imagine you know how to adapt it: function startRevive(playerSource, commandName) triggerClientEvent( getRootElement( ), "startrevive", playerSource) --this calls the client event end addCommandHandler( "revive", startRevive) how does it work: 1.) it creates a timer that executes once every 62.5 milliseconds 80 times, which is 5 seconds (62.5 x 80 = 5000) to function "add_percentage_per_second (ignore function name, wanted to do it a little more fast-paced, 1.25 percent 80 times equals 100% if you want to change the total time of revive, you now know the math needed WARNING: THIS IS NOT THE MOST OPTIMIZED WAY TO DO IT I did this in 10 minutes, hopefully it helps
  14. This is because DayZ gamemode has a protection, you should look for a timer in your gamemode that does something like this local skin = getElementData(player,"skin") if (skin ~= getElementModel(player) then setElementModel(player,skin) end if you find this, check the element data, and just add setElementData(player,"DATANAME",YOURSKINID) example, if your DayZ protection dataname is "DayZSkin", and the skin you set is 150 setElementData(player,"DayZSkin",150) FULL CODE With dataname "DayZSkin": newskin = createMarker ( 1856.0751, 851.0827, 9.408, "cylinder", 1.5, 255, 255, 0, 170 ) function skin(hitPlayer) if getElementType(hitPlayer) == "player" then setPlayerSkin ( hitPlayer, 211 ) setElementData( hitPlayer, "DayZSkin",211) --this is what you must add. end end addEventHandler ( "onMarkerHit", newskin, skin )
  15. But can this affect only a couple users and not all of them?
  16. Its calling many elementdatas, but this happens with any gui, happens with inventory system, with gang system
  17. its like nothing was on the screen, you can see when I hover over the buttons in my VM, nothing happens
  18. That is not the problem, its just something that sets some element data, nothing to do with the actual problem shown in the video or else it wouldnt work in any computer
  19. Hello, I dont know if someone has posted this here before, I searched and wasn´t able to find anyone having this problem, my problem is, I have a DayZ script, which I have been modifying, but since the start some of my players were not able to click on the GUI from the Inventory, nor the gang system, nor the login panel, this just happens with some players, for example, everything works on my computer, but with a virtual machine, I am not able to click on anything, here is a video of what I am talking about, I have no idea why this is caused, there is no related problems in my debugscript, actually, there is only 1 thing that is wrong in my server and been lazy to fix it, just a warning and I am missing an event client side which has nothing to do with this, since it affects various resources, the only way I´ve been able to fix this is by restarting the resource, that seems to fix the issue but I cant restart every time someone logs in: VIDEO: VIDEO (dont know the tags to embed video here) Any help is appreciated
  20. Hello, sorry for late reply, just tried using setElementFrozen, and it just freezes the vehicle and the elevator object goes through the car and goes up Hello, sorry for late reply, tried this yesterday and the problem persists Hello, I fixed it in a funny way, what I did is add a second elevator object, and made its alpha 0 (invisible) and attached it to the original elevator, it works now, I´ll leave the code for whoever needs it local elevatorcolshape = createColRectangle ( 1666, 1188, 30.6, 20.0 ) local elevator = createObject(3115, 1676.9, 1197.8, 24.2) local elevatorclone = createObject(3115, 1676.9, 1197.8, 24.2) attachElements(elevatorclone,elevator ) setElementAlpha(elevatorclone, 0 ) local elevatorSTATE = "techo" function elevator1337(source,command,goto ) local playeraccount = getPlayerAccount( source ) local accname = getAccountName( playeraccount ) local playerx,playery,playerz = getElementPosition( source ) local elevatorx,elevatory,elevatorz = getElementPosition(elevator) local distance = getDistanceBetweenPoints3D(playerx, playery, playerz, elevatorx,elevatory,elevatorz ) if (accname == "knight") then if (goto) then if getPedOccupiedVehicle ( source ) then outputDebugString( distance ) -- get the vehicle element local playerVehicle = getPlayerOccupiedVehicle ( source ) attachElements(playerVehicle, elevator,0,0,1) -- get the current freeze status setElementFrozen ( playerVehicle, true ) setTimer(setElementFrozen, 1950, 1, playerVehicle,false ) setTimer(detachElements, 1950, 1, playerVehicle,elevator ) end if (goto == "piso") then if (elevatorSTATE ~= "piso") then if (isElementWithinColShape(source, elevatorcolshape ) and playerz < 20) then outputChatBox( "[BASE 1337]: NO PUEDES LLAMAR EL ELEVADOR PORQUE TE VA A APLASTAR",source,255,0,0,true ) else -- local isinveh = isPedInVehicle( source ) -- if (isinveh) then -- attachElements(getPedOccupiedVehicle(source),elevator,0,0,15) -- end elevatorSTATE = "piso" outputChatBox( "[BASE 1337]: ELEVADOR MOVIENDOSE A: "..goto,source,0,255,0,true ) moveObject( elevator, 500, 1676.9, 1197.8, 18.2) setTimer(moveObject, 750, 1, elevator, 500, 1685.9, 1197.8, 18.2) setTimer(moveObject, 1500, 1, elevator, 500, 1685.9, 1197.8, 9.7) -- if (isinveh) then -- setTimer(detachElements,3000, 1,getPedOccupiedVehicle(source),elevator) -- end end else outputChatBox( "[BASE 1337]: EL ELEVADOR YA ESTA EN: "..goto,source,255,0,0,true ) end end if (goto == "techo") then if (elevatorSTATE ~= goto) then -- local isinveh = isPedInVehicle( source ) -- if (isinveh) then -- attachElements(getPedOccupiedVehicle(source),elevator,0,0,15) -- end elevatorSTATE = goto outputChatBox( "[BASE 1337]: ELEVADOR MOVIENDOSE A: "..goto,source,0,255,0,true ) moveObject( elevator, 500, 1685.9, 1197.8, 18.2) setTimer(moveObject, 750, 1, elevator, 500, 1676.9, 1197.8, 18.2) setTimer(moveObject, 1500, 1, elevator, 500, 1676.9, 1197.8, 24.2) -- if (isinveh) then -- setTimer(detachElements,3000, 1,getPedOccupiedVehicle(source),elevator) -- end else outputChatBox( "[BASE 1337]: EL ELEVADOR YA ESTA EN: "..goto,source,255,0,0,true ) end end end end end addCommandHandler("elev", elevator1337 ) Thanks for the help guys
  21. Hello, I am trying to make an elevator script using an createObject, moveObject and attachElements to attach a vehicle to the object, the problem is, the vehicle goes through the object even if I add an Z offset, this is my code: local elevatorcolshape = createColRectangle ( 1666, 1188, 30.6, 20.0 ) local elevator = createObject(3115, 1676.9, 1197.8, 24.2) local elevatorSTATE = "techo" function elevator1337(source,command,goto ) local playeraccount = getPlayerAccount( source ) local accname = getAccountName( playeraccount ) local playerx,playery,playerz = getElementPosition( source ) local elevatorx,elevatory,elevatorz = getElementPosition(elevator) if (accname == "knight") then if (goto) then if (goto == "piso") then if (elevatorSTATE ~= "piso") then if (isElementWithinColShape(source, elevatorcolshape ) and playerz < 20) then outputChatBox( "[BASE 1337]: NO PUEDES LLAMAR EL ELEVADOR PORQUE TE VA A APLASTAR",source,255,0,0,true ) else local isinveh = isPedInVehicle( source ) if (isinveh) then attachElements(getPedOccupiedVehicle(source),elevator) end elevatorSTATE = "piso" outputChatBox( "[BASE 1337]: ELEVADOR MOVIENDOSE A: "..goto,source,0,255,0,true ) moveObject( elevator, 1000, 1676.9, 1197.8, 18.2) setTimer(moveObject, 1250, 1, elevator, 1000, 1685.9, 1197.8, 18.2) setTimer(moveObject, 2500, 1, elevator, 1000, 1685.9, 1197.8, 9.7) if (isinveh) then setTimer(detachElements,3000, 1,getPedOccupiedVehicle(source),elevator) end end else outputChatBox( "[BASE 1337]: EL ELEVADOR YA ESTA EN: "..goto,source,255,0,0,true ) end end if (goto == "techo") then if (elevatorSTATE ~= goto) then local isinveh = isPedInVehicle( source ) if (isinveh) then attachElements(getPedOccupiedVehicle(source),elevator,0,0,3) end elevatorSTATE = goto outputChatBox( "[BASE 1337]: ELEVADOR MOVIENDOSE A: "..goto,source,0,255,0,true ) moveObject( elevator, 500, 1685.9, 1197.8, 18.2) setTimer(moveObject, 750, 1, elevator, 500, 1676.9, 1197.8, 18.2) setTimer(moveObject, 1500, 1, elevator, 500, 1676.9, 1197.8, 24.2) if (isinveh) then setTimer(detachElements,3000, 1,getPedOccupiedVehicle(source),elevator) end else outputChatBox( "[BASE 1337]: EL ELEVADOR YA ESTA EN: "..goto,source,255,0,0,true ) end end end end end addCommandHandler("elev", elevator1337 ) I would like to know if there is a way to avoid the car going through the item and fall, thanks
  22. Alright, Ill try it out and let you know how it goes, thank you
  23. Alright, one last thing, this should do the trick, replace this: amount = str:gsub('%A',amount) with this: amount = string.gsub('%A',amount)
  24. Alright, try changing if (string.count(amount,"-")) then to this: if (string.count(tostring(amount),"-")) then
  25. You could use string.count to check if "amount" contains a negative "-" symbol, and use Split to remove it from the string, EDIT: function string.count (text, search) if ( not text or not search ) then return false end return select ( 2, text:gsub ( search, "" ) ); end addCommandHandler("pay", function(player, cmd, name, amount) local amount = tonumber(amount) if name and amount then local target = findPlayer(name) local money = getPlayerMoney(target) if (string.count(amount,"-")) then amount = str:gsub('%A',amount) end if money >= amount then takePlayerMoney(player, amount) givePlayerMoney(target, amount) outputChatBox("#FFffFF Átutaltál neki: #c8c8c8" .. getPlayerName(target) .. " #0088ff" .. amount .. " Forintot.", player, 0, 255, 0, true) outputChatBox("#c8c8c8 " .. getPlayerName(player) .. " #FFffFFutalt neked #0088ff" .. amount .. " Forintot.", target, 0, 255, 0, true) else outputChatBox("#FFffFF Nincs elég pénzed.", target, 255, 0, 0, true) end end end ) Try this
×
×
  • Create New...