Jump to content


  • Posts

  • Joined

  • Last visited

About knightscript

  • Birthday 17/11/1999


  • Gang
  • Location
    New Hampshire
  • Occupation
    Web Programmer for living
  • Interests
    Gaming, Developing stuff, Gaming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

knightscript's Achievements


Poot-butt (14/54)



  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?
  • Create New...