Jump to content

Dzsozi (h03)

Members
  • Posts

    696
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Dzsozi (h03)

  1. Yes, I also believe that. Sorry, what do you mean by that? With the export functions you get the middle position of the defined vehicle's bed. So from that point on, you can adjust the position of the object by adding or extracting values to/from the position you got.
  2. No I don't have to do what you wrote. I already did the system and it works perfectly without even using 3ds max or zmodeler or custom ped models. I am using only the CJ skin, clothes, clothing textures and texture replacing shaders. By the way I am asking how can I change the color of a texture created by dxCreateTexture, and I don't remember asking it before.
  3. Hello! I am making a custom CJ system and I am using custom clothes. I would like to make colorable clothes as well, where the player can define the color of the clothing or even the hair color for example. I am using dxCreateTexture to make the custom clothes' textures. My question is how can I change the color of the custom textures? Let's say I have a white T-shirt, and I want to use a colorpicker to change its color. Could somebody help me out with that please?
  4. Thank you for your explanations! Unfortunately, I am still getting an error message, this time I tried using it with a command. I have also made the connect and reConnect functions callable within the missionmanager resource. I put the local resourceFunctions = {} function communicator (functionName, ...) resourceFunctions[functionName](...) end function resourceFunctions.getCommunicationFunctions (communicationFunctions) loadstring(communicationFunctions)() end function testme() local connected = call( getResourceFromName ("missionManager"), "connect", {communicator = "communicator", communicationFunctions = true}) iprint(connected) reConnect("hmm does this work???") end addCommandHandler("tme", testme) code in a different resource. But when I use the tme command I get the following errors, even though I changed line 7 to your new line: missionmanager\server.lua:7: attempt to index field '?' (a nil value) testmission\sourceS.lua:12: call: failed to call 'missionmanager:connect' INFO: false (this is the iprint) testmission\sourceS.lua:16: attempt to call global 'reConnect' (a nil value)
  5. Hmm, it is kinda strange, I don't get any errors but neither any outputs when using your first code. If I understood correctly, I must use the first code in the missionmanager resource and the second code of the first example in the any other resource I would like to. But I get an error when trying to use your second example's codes: missionmanager/mission1.lua: failed to call 'missionmanager:connect' and the iprint returns a false value. Can you help me out? I don't know what could be the problem. Also I would like to ask you to explain a few things for me please. I have never used the loadstring function, what does that do and how to use it? And I don't know what's the difference between the ' and " in lua. Why the whole function is between ' ? Or this is what loadstring is good for? I don't quite understand it.
  6. It seems like you don't understand my problem, I know how to export a function.
  7. Hello! I would like to make a mission manager resource. Let's say I have a resource called missionmanager. In this resource I have script, that looks something like this: availableMissions = {} function startMission(id) if id and availableMissions[id] then if availableMissions[id].startFunction then availableMissions[id].startFunction() end end end And then I have a different script in this same resource with the mission like this: availableMissions[1] = {} availableMissions[1].startFunction = function() outputChatBox("a") end I would like to use the startMission function as an export function in other different resources, so I can start a mission whenever I want with the startMission(1) function. I've tested the above codes but it doesn't work, only if I put them in the same script, but I don't want to make every mission in one script, I would like to have different script files for each mission. How can I do that?
  8. I fixed it already, one problem was that I checked the wrong level when I used my custom event handler, but it's all working now fine!
  9. Works totally fine now, I also figured out that I also made a mistake. Thank you for your help guys!
  10. No, I don't think because as I said if I skip a rank name, the script still returns the following level's rank name. When I set my level from 8 (Felon) to 16 (Hustler) the script returns my rank name as Reckless which is between these two. It should return Hustler since I set my rank to 16.
  11. I changed it because if it is - and I am leveling up from 2 to 3 then I should already change rank to Person of Interest from Citizen, but this is not the case, only if I write + there. That's not the main problem, my main problem is if I am level 3 - Person of Interest and then I use /setlevel 150 for example, then the display still says Person of Interest and not Kingpin. So I mean it doesn't directly check the rank name for some reason.
  12. Thank you, it is kinda working, but not the way I expected and I want it to work. Here's my current script (I edited your code a little): local levelToRank = { [1] = {"Citizen", "Citizen"}, [3] = {"Person of Interest", "Lookout"}, [5] = {"Felon", ""}, [10] = {"Reckless", ""}, [15] = {"Hustler", "Good Guy"}, [20] = {"Thug", ""}, [25] = {"Fixer", ""}, [30] = {"Soldier", ""}, [40] = {"Gangster", ""}, [50] = {"Trigger", "Meddler"}, [60] = {"Associate", ""}, [70] = {"Enforcer", ""}, [75] = {"Immortal", ""}, [80] = {"Organizer", ""}, [85] = {"Lieutenant", ""}, [90] = {"High Roller", ""}, [100] = {"Public Enemy", ""}, [110] = {"Shot Caller", ""}, [120] = {"Rainmaker", ""}, [130] = {"Right Hand", ""}, [140] = {"Street Boss", ""}, [150] = {"Kingpin", ""}, [160] = {"Chapo", ""}, } function getPlayerTitleName(player) local playerLevel = getPlayerLevel(player) local rank = playerLevel if(levelToRank[rank])then return levelToRank[rank][1] end repeat rank = rank + 1 until levelToRank[rank] return levelToRank[rank][1] end But there is one problem. When I set my rank from 3 to for example 8 my title name is Person of Interest while it should be Felon, since 8 is above 5 and the Felon rank is from level 5. And it only changes when I set my level from 8 to 9, then it changes to Felon but that's no good for me. I always would like to get the correct rank name whenever I call the "getPlayerTitleName" function.
  13. Hello! So I am trying to make a level system with rank titles added to it. My only problem is that I can't figure out how can I get the range between the ranks. More clearly: local levelToRank = { [1] = {"Citizen", "Citizen"}, [3] = {"Person of Interest", "Lookout"}, [5] = {"Felon", ""}, [10] = {"Reckless", ""}, [15] = {"Hustler", "Good Guy"}, [20] = {"Thug", ""}, [25] = {"Fixer", ""}, [30] = {"Soldier", ""}, [40] = {"Gangster", ""}, [50] = {"Trigger", "Meddler"}, [60] = {"Associate", ""}, [70] = {"Enforcer", ""}, [75] = {"Immortal", ""}, [80] = {"Organizer", ""}, [85] = {"Lieutenant", ""}, [90] = {"High Roller", ""}, [100] = {"Public Enemy", ""}, [110] = {"Shot Caller", ""}, [120] = {"Rainmaker", ""}, [130] = {"Right Hand", ""}, [140] = {"Street Boss", ""}, [150] = {"Kingpin", ""}, [160] = {"Chapo", ""}, } Here's my table with the rank names. I want to make it work like if I am level 1 and under level 3 then my returned rank name would be Citizen, but if I am level 3 but under level 5 then my rank would be displayed as Person of Interest and so on. So basically I would like to get the range between the levels. As you can see, the keys in the tables are the ranks where the name should be starting to display. So the range is the table key and the following table key, but I don't know how to properly get that and return the correct string. Please somebody help me out, it looks easy but I can't figure out the calculations and looping methods.
  14. This utility script allows you to get a vehicle's available cargo space position, for example the roof rack of the Perennial, the bed of the Yosemite, the back of the Pony or many more vehicles! Also, as we know GTA has something called variants for vehicles (https://wiki.multitheftauto.com/wiki/Vehicle_variants), for example a Bobcat either spawns with some Sprunk cans, a single tire or nothing in it's bed. This resource also allows you to clear the cargo's available space if it is occupied by any unnecessary things (a.k.a. variant) if you need some space for something bigger (makes the vehicle's actual cargo placeholder variants (if there are any) disappear for example the planks in the Picador's bed, also, this same function adds the roof rack variant on the Perennial if it is missing and the function is being called)! In this resource you can find 2 exported functions: - getVehicleCargoPlacementPosition (client and server) | returns a table with x, y, z offset positions - setVehicleCargoSpaceFree (server) | returns true if the vehicle cargo space was cleared, false otherwise Open the exampleS.lua for further explanations and examples to how to use this script. DOWNLOAD
  15. I don't really want to use setElementData, I rather prefer tables on client side for this, if is that possible. Probably it is, since the script works right now, I just need to know how to store the vehicles' data when I stop/start/restart the resource. But I don't think that I need element datas on server side for that, since this is not something like I would need to be aware of to people change it's data value with cheat engine or something.
  16. If I save the data in a file how should I do that? Every vehicle’s data in a new line? Or how should I get which vehicle has the data? Database seems a bit more complicated and also I don’t want to get it on server side. I am looking for the best performance for my scripts. What do you think which is the most performance friendly solution for that?
  17. Hello! I would like to use tables for my vehicle system to save data, since I really want to have a good performance. Whatever, so I tried using toJSOn and fromJSON but I don't really understand how that works. I want to save every vehicles' blinker state/side when the resource stops and set it back when the resource starts. How can I do that with tables? Here's my current code, I tried lots of different ways but couldn't manage to get it working. I would appreciate if someone could help me out! local function toggleIndicator(key,keyState) if isTimer(spamTimer) then return end for k, vehicle in pairs(getElementsByType("vehicle")) do local driver = getVehicleOccupant(vehicle) if driver == localPlayer then if (keyState == "down") then spamTimer = setTimer(function() spamTimer = nil end, 1000, 1) indicatorInfo[vehicle] = indicatorInfo[vehicle] or {} local indicatorState = indicatorInfo[vehicle]["side"] or nil if indicatorState then --removeEventHandler("onClientRender", getRootElement(), startIndicator) indicatorInfo[vehicle]["side"] = nil handleIndicatorLights() return end if key == blinkerLeft then indicatorInfo[vehicle] = { ["side"] = "left", } elseif key == blinkerRight then indicatorInfo[vehicle] = { ["side"] = "right", } else indicatorInfo[vehicle] = { ["side"] = "both", } end end end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() bindKey(blinkerLeft, "down", toggleIndicator) bindKey(blinkerRight, "down", toggleIndicator) bindKey(blinkerBoth, "down", toggleIndicator) for k, vehicle in pairs(getElementsByType("vehicle")) do indicatorInfo[vehicle] = indicatorInfo[vehicle] or {} indicatorInfo[vehicle]["side"] = fromJSON(data) end end ) addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), function() for k, vehicle in pairs(getElementsByType("vehicle")) do if indicatorInfo[vehicle] then local data = toJSON({indicatorInfo[vehicle]["side"] or nil}) end end end ) I get this error with the current code, but I don't know how to fix it: Bad argument @ 'fromJSON' [Expected string at argument 1, got nil]
  18. You will definitely need getDistanceBetweenPoints3D (or 2D if you want to disable the distance check on the Z axis), onClientRender I guess, maybe some easy math for calculations, also you will have to define the element you want to keep the distance away from, at least this is how I would do it. So you may also need setElementData as well, but there are other ways to do it without that. If you want to recreate the meter bar as well, probably dxDrawText and dxDrawRectangle will be also needed for your work. This is all I can think of right now.
  19. Sorry for bringing up this topic again, but I have another problem that I can't solve. How can I make the drawn lights always lay on the surface (or at least always face the vehicle's top correctly)? Since right now when I go up on a hill with a light shadow attached to my vehicle it looks like this: How can I make it work like the default headlights on surface? Just to make sure, here's my current calculations again: addEventHandler("onClientPreRender", root, function() local cameraX, cameraY, cameraZ = getElementPosition(getCamera()) for groundLightShadow, info in pairs(attachedGroundLightShadows) do local x, y, z = getPositionFromElementOffset(info.element, info.pos.x, info.pos.y, info.pos.z) setElementPosition(groundLightShadow, x, y, z) end for k, data in pairs(groundLightShadows) do if data.lightShadow and isElement(data.lightShadow) then local worldX, worldY, worldZ = getElementPosition(data.lightShadow) local groundPosition = getGroundPosition(worldX, worldY, worldZ) local fixedGroundPosition = groundPosition+0.05 local onScreenX, onScreenY = getScreenFromWorldPosition(worldX, worldY, fixedGroundPosition, 20) if onScreenX and onScreenY then local distance = getDistanceBetweenPoints3D(worldX, worldY, fixedGroundPosition, cameraX, cameraY, cameraZ) if distance <= lightShadowVisibleDistance then if isLineOfSightClear(cameraX, cameraY, cameraZ, worldX, worldY, fixedGroundPosition, true, false, false, false, false, true) then local lightColor = data.color local matching = attachedGroundLightShadows[data.lightShadow] if matching then local elementX, elementY, elementZ = getElementPosition(matching.element) local rx, ry, rz = getElementRotation(matching.element) --local facez = getGroundPosition(elementX, elementY, elementZ + 5000000) local x, y, z = getPositionFromElementOffset(matching.element, matching.pos.x, matching.pos.y, matching.pos.z) local xa, ya, za = getPositionFromElementOffset(matching.element,matching.pos.x, matching.pos.y+data.size, matching.pos.z) local xb, yb, zb = getPositionFromElementOffset(matching.element,matching.pos.x, matching.pos.y-data.size, matching.pos.z) if elementZ <= fixedGroundPosition+2 then dxSetBlendMode("add") dxDrawMaterialLine3D(xa, ya, fixedGroundPosition, xb, yb, fixedGroundPosition, lightShadowTypes[data.lightShadowType], data.size*2, tocolor(lightColor[1],lightColor[2],lightColor[3],lightColor[4]), (xa+xb)/2, (ya+yb)/2, z) dxSetBlendMode("blend") end else dxSetBlendMode("add") dxDrawMaterialLine3D(xa, ya, fixedGroundPosition, xb, yb, fixedGroundPosition, lightShadowTypes[data.lightShadowType], data.size*2, tocolor(lightColor[1],lightColor[2],lightColor[3],lightColor[4]), (xa+xb)/2, (ya+yb)/2, z) dxSetBlendMode("blend") end end end end end end end, true, "low-10" )
  20. Got it working and now I understand how it works. Thank you!
  21. But on client side I need to use the function like on server side, so I need to call the function and then return the value given on server side, I want to use it inside a render function so like accountState = getPlayerAccountState(localPlayer), and then based on that I can disable or enable the register button, change it's color, add tooltip, whatever.
  22. You can use Naturalmotion's Endorphin to make custom animations, you can find several tutorials about in online and then use GTA Anim Manager to create custom IFP files and replace animations.
  23. Hello! I would like to get the current account state variable on client side, so I can adjust my login interface based on that (if the player already has an account disable the register button, etc.). My problem is I don't know how to do that, could somebody help me out? I need to call the function on client side, so I can't use element datas (as far as I know). Here's my server side script: function getPlayerAccountState(playerSource) if (playerSource) then local accountState = "canCreate" local selectQuery = dbPoll(dbQuery(connection, "SELECT * FROM accounts"), -1) if (selectQuery) then for k, v in ipairs(selectQuery) do if (tostring(v["username"]):upper() == tostring(playerUsername):upper()) then accountState = "haveUsername" break end if not (getServerOwners(playerSerial)) then if (tostring(v["serial"]):upper() == tostring(playerSerial):upper()) then accountState = "haveAccount" break end end end end return accountState end end
×
×
  • Create New...