-
Posts
1,803 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Citizen
-
Bonjour Andynosaure, Dans les ressources installées par défaut avec MTA, il y en a une qui s'appelle sirenEdit que tu peux essayer d'utiliser: En revanche elle nécessite l'installation et le lancement d'une ressource tierce pour fonctionner correctement: cpicker: https://community.multitheftauto.com/index.php?p=resources&s=details&id=3247 Il suffit ensuite de lancer sirenEdit, de rentrer dans un véhicule et de taper la commande /sirens. Un bouton "Print" te permettra récupérer le code lua a utiliser dans ton gamemode une fois terminé. Sinon une petite recherche dans les ressources de la communauté ma permis d'en trouver plusieurs dont celle là (si jamais sirenEdit n'est pas assez complet): sireneditor: https://community.multitheftauto.com/index.php?p=resources&s=details&id=5531 En espérant que tu y trouveras ton bonheur Cordialement, Citizen
-
Bonsoir Andynosaure, Non, MTA permet aux développeurs du serveur de remplacer les textures (TXD), models (DFF) et les infos de collision (COL) grâce à des fonctions utilisables seulement côté client (t'as dû voir que dans les tutos du wiki, on peut définir un script ".lua" comme étant un script "server" (qui sera exécuté par le serveur donc) ou comme étant un script "client" (qui sera exécuté sur le pc du joueur). Les scripts côtés client ont accès à des fonctions (fournis par MTA) qui permettent le chargement et le remplacement de textures, de models et de collisions "à la volée", c'est à dire sans altérer les fichiers de GTA des joueurs. Les joueurs n'ont qu'à se connecter au serveur, et sans rien faire au préalable, le code client va remplacer ce qu'il veut; et tout redevient normal lorsqu'ils quitteront le serveur. Voici un exemple provenant du wiki (587 c'est le model id de l'euros): outputChatBox ( "> replacing the euros vehicle" ) local txd = engineLoadTXD ( "data/euros.txd" ) engineImportTXD ( txd, 587 ) local dff = engineLoadDFF ( "data/euros.dff" ) engineReplaceModel ( dff, 587 ) Ce code fonctionne à condition que tu ais bien un fichier "euros.txd" et "euros.dff" dans un dossier "data" dans la ressource et que tu as également renseignés ces fichier dans ta meta.xml pour qu'il soit automatiquement téléchargé par le joueur qui se connecte: <file src="data/euros.txd" /> <file src="data/euros.dff" /> C'est assez rapide de faire à la main si tu en as pas beaucoup, mais si tu veux pas mettre les mains dedans ou que tu souhaites avoir un serveur hyper moddé (attention, l'abus de remplacement de models/textures/collisions est dangereux pour votre santé la stabilité du jeu), il existe une petite ressource que tu peux installer pour te faciliter la vie: ModLoader by Remi-X: https://forum.multitheftauto.com/topic/30833-rel-modloader-10-loads-any-mod-without-scripting/ Il te suffiras juste de placer les fichiers dans le bon dossier et ça fonctionne direct sans rien toucher d'autre. Cordialement, Citizen
-
Bonsoir, Je m'excuse du délai de réponse. Une bonne piste pour commencer c'est de suivre les tutos de la section française du wiki officiel MTA: https://wiki.multitheftauto.com/index.php?title=FR/Main_Page Regarde la section de droite "Programmer" et de préférence dans l'ordre. Ces tutos t'apprendront les fondamentaux dont la nuance compliqué des scripts client et serveur. Bonne lecture et soit patient, ne saute pas certains fondamentaux qui pourrait te faire perdre énormément de temps ensuite pour comprendre d'où vient un problème qui aurait pu être évité de base. Bon code !
-
Ça ne revoit pas le même élément mais sinon oui c'est tout à fait ça. Il n'y en a pas un meilleur que l'autre mais avoir un gui-browser element permet de l'intégrer facilement dans une interface (fenêtres, boutons, etc) en CEGUI. Par exemple mettre une window en parent comme tu le ferais avec un bouton CEGUI. D'autre part avoir un browser element permet d'avoir plus de contrôle sur la manière dont il sera afficher à l'écran comme par exemple la rotation sur les 3 axes x,y,z via dxDrawImage, tu peux l'intégrer avec tes interfaces en dxBidules et comme c'est une texture comme n'importe quelle autre, tu peux l'utiliser dans un shader afin de remplacer une texture du jeu. Vidéo de démonstration dans laquelle tu peux voir son utilisation en CEGUI puis en texture via un dxDrawImage et un shader en simultané: J'espère que c'est plus clair maintenant ; ) Cordialement, Citizen
-
I'm pretty sure he wants the text to show for everyone instead: function coronaa() triggerServerEvent ("szoveg", localPlayer) end addEventHandler ( "onClientMarkerHit", ajtomegilyenek, coronaa ) addEvent( "szoveg", true ) addEventHandler( "szoveg", root, function() outputChatBox("Text", root, r,g,b, true) end)
-
Un mode "hybride" en gardant les commandes classiques et le menu d'action rapide pourrait résoudre ce seul problème
-
What about setVehiclePlateText ?? (limited to 8 characters max)
-
If you do it the same way in your original function but it always says "login error", my guess is that username and/or password values are not correct. Did you try to print de value of those variables before calling dbQuery ? Are they correct ? You can also try to log the queries with debugdb 2 Come back with the results of your tests.
-
You can use dxCreateTexture (the 2nd signature of it) to get a texture out of your variable containing your image data that you can then use with dxDraw functions like a classic image. Make sure you don't loop the texture creation (I mean don't do that in an onClientRender for exemple) or you the client will eventually run out of memory.
-
You are already using relative positions and sizes. What's the current problem you are facing ? (Maybe adding screenshots of the current problem and what it should look like would help us to see what you are trying to fix).
-
No read again, don't go too fast ! You have to create an empty MySQL database. Then modify the settings.xml file to change the MySQL configuration section according to your setup. If you are on windows, you have to comment the @sql.socket setting like so: <!-- <setting name="@sql.socket" value="/var/run/mysqld/mysqld.sock"/> -->
-
Did you try to follow the steps explained in INSTALL.md ?
-
Need help with DX, positions, rotations and tables
Citizen replied to Dzsozi (h03)'s topic in Scripting
Alright, cool to hear it fixed the issue and that I didn't break anything by refactoring the calculations. Feel free to remove the commented lines and debug things to make the code cleaner (the dxDrawCircle function definition can normally be removed if you don't use it anywhere else in that script). -
Need help with DX, positions, rotations and tables
Citizen replied to Dzsozi (h03)'s topic in Scripting
For me I already had FPS drops when you added some junks the first time. Anyway, I improved everything I could find (didn't test, report errors if any): local sx, sy = guiGetScreenSize() local junkSize = sx/3 local junkImageDistance = 50 local junkPositionX, junkPositionY = sx/2-junkSize/2, sy/2-junkSize/2 local searchState = false local item = nil -- no item at first local junks = {} -- holds all junks images with position, rotation etc local board = {x = junkPositionX, y = junkPositionY, width = junkSize, height = junkSize} local mouseRadius = 20 -- how big the mouse's hitbox is (higher = easier to move junks) local repulseSpeed = 5 -- how fast the junks go away from mouse's hitbox local junkyardCollision = nil function createJunkyards() for k,v in ipairs(junkyards) do junkyardCollision = createColCuboid(v[1], v[2], v[3]-0.85, v[4], v[5], v[6]) end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), createJunkyards) local junkImages = { -- image, size, hitradius {"burgershot-bag", 128, 30}, {"burgershot-bag", 128, 30}, {"burgershot-bag", 128, 30}, {"cup", 128, 25}, {"cup", 128, 25}, {"cup", 128, 25}, {"cup", 128, 25}, {"boot", 256, 75}, {"bin-bag", 256, 75}, {"bin-bag", 256, 75}, {"apple", 128, 30}, {"apple", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"bottle", 128, 25}, {"bottle", 128, 25}, {"glass", 128, 50}, {"tin-can", 128, 25}, {"tin-can", 128, 25}, {"tin-can", 128, 25}, -- duplicated amount, didn't cause lag before, but now it lags even if i delete the junks under here {"burgershot-bag", 128, 30}, {"burgershot-bag", 128, 30}, {"burgershot-bag", 128, 30}, {"cup", 128, 25}, {"cup", 128, 25}, {"cup", 128, 25}, {"cup", 128, 25}, {"boot", 256, 75}, {"bin-bag", 256, 75}, {"bin-bag", 256, 75}, {"apple", 128, 30}, {"apple", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"paper", 128, 30}, {"bottle", 128, 25}, {"bottle", 128, 25}, {"glass", 128, 50}, {"tin-can", 128, 25}, {"tin-can", 128, 25}, {"tin-can", 128, 25} } function createJunks() -- creating junks junks = {} for k, v in ipairs(junkImages) do local image = "junkyard/files/"..v[1].".png" local size = v[2] local rot = math.random(1,360) local midX, midY = getRandomPointInCircle(board.x+board.width/2, board.y+board.width/2, board.width/2) local x, y = midX - size/2, midY - size/2 -- we want the middle of the image to be placed at that point table.insert(junks, {x = x, y = y, size = size, halfSize = size/2, img = image, rot = rot, hitradius = v[3]}) end -- creating the item (should be in another function imo) local itemSize = 64 local itemX, itemY = getRandomPointInCircle(board.x+board.width/2, board.y+board.width/2, board.width/3) itemX, itemY = itemX - itemSize/2, itemY - itemSize/2 -- we want the middle of the image to be placed at that point local itemRadius = itemSize/2 local color = tocolor(255, 0, 0, 255) -- full red by default -- no need for item to be a list of dictionaries, just a dictionary: item = {x = itemX, y = itemY, size = itemSize, halfSize = itemSize/2, radius = itemRadius, color = color} -- reseting that global itemDiscoveredAlready = false end --showCursor(true) -- debug (add it to your command that shows the junk) --bindKey("f5", "down", createJunks) -- debug (F5 to (re)create the junk) function renderJunk() -- Safety check just un case to prevent spamming errors if try to draw before calling createJunks if #junks == 0 or not item then return end dxDrawRectangle(board.x, board.y, board.width, board.height, tocolor(0, 0, 0, 150)) -- debug (junk board) --dxDrawCircle(board.x+board.width/2, board.y+board.width/2, board.width/4, 1, 1, 0, 360, tocolor(0, 0, 0, 255)) -- debug (spawn area - black circle) -- drawing item -- local itemX, itemY = item.x, item.y local itemSize = item.size local itemHalfSize = item.halfSize local itemRadius = item.radius local itemColor = item.color local itemCenterX, itemCenterY = itemX + itemHalfSize, itemY + itemHalfSize dxDrawRectangle(itemX, itemY, itemSize, itemSize, itemColor) -- Getting the cursor position once per frame local cx, cy = getCursorPosition() cx, cy = cx * sx, cy * sy -- absolute cursor position local cursorInsideBoard = cx > board.x and cx < board.x + board.width and cy > board.y and cy < board.y + board.height local mouse1State = getKeyState("mouse1") -- drawing junks -- local itemDiscovered = true -- will tell us after the loop if there is still a junk on it for k, j in ipairs(junks) do dxDrawImage(j.x, j.y, j.size, j.size, j.img, j.rot, 0, 0, tocolor(255,255,255,255), false) -- handling item discovery local imgCenterX, imgCenterY = j.x+j.halfSize, j.y+j.halfSize -- center of the junk's image -- "if the item is still considered as discovered but the current junk's hitbox collides with the item then ..." if itemDiscovered and isCircleInCircle(imgCenterX, imgCenterY, j.hitradius, itemCenterX, itemCenterY, itemRadius) then itemDiscovered = false -- "we finally consider it's not discovered" -- Setting it to false will also stop the code to call the isCircleInCircle above for the remaining junks end --dxDrawCircle(itemCenterX, itemCenterY, itemRadius, 1, 1, 0, 360, tocolor(245, 140, 20, 255)) -- debug (item's hitbox) --dxDrawCircle(imgCenterX, imgCenterY, j.hitradius, 1, 1, 0, 360, tocolor(0, 0, 200, 100)) -- debug (junk's hitbox - blue circle) --dxDrawCircle(cx, cy, mouseRadius, 1, 1, 0, 360, tocolor(255, 255, 0, 255)) -- debug (mouse's hitbox) -- Moving junks ability: if mouse1State and cursorInsideBoard and isCircleInCircle(imgCenterX, imgCenterY, j.hitradius, cx, cy, mouseRadius) then -- move it away if it collides with the cursor's hitbox local angle = findRotation(imgCenterX, imgCenterY, cx, cy) local newX, newY = getPointFromDistanceRotation(imgCenterX, imgCenterY, repulseSpeed, -angle + 180) local offsetX, offsetY = imgCenterX - newX, imgCenterY - newY j.x, j.y = j.x-offsetX, j.y-offsetY -- debug: --local newX, newY = getPointFromDistanceRotation(imgCenterX, imgCenterY, 200, -angle + 180) -- debug --dxDrawLine(imgCenterX, imgCenterY, newX, newY, tocolor(0, 200, 0, 255)) -- debug (shows direction where the junk is going - green line) end end -- We drew and calculated everything for that frame. Did we just discover the item ? if itemDiscovered then item.color = tocolor(0, 255, 0, 255 * math.abs(getTickCount() % 1000 - 500) / 500) -- full green if not itemDiscoveredAlready then itemDiscoveredAlready = true -- This will prevent it to be called for every next frames setTimer(function() onItemDiscovered(item) -- call the function for when we discover the item end, 3000, 1) end end end -- called as soon as an item is discovered function onItemDiscovered(item) searchState = false outputChatBox("item discovered !") showCursor(false) triggerServerEvent("giveFoundJunkItem", localPlayer, localPlayer) removeEventHandler("onClientRender", getRootElement(), renderJunk) itemDiscovered = false exports["sgr_main"]:syncAnimationFromServer(localPlayer, false) -- do lightweight stuff here as we are still inside a onClientRender call end function startSearching() if junkyardCollision and isElement(junkyardCollision) then if isElementWithinColShape(localPlayer, junkyardCollision) then if not isPedInVehicle(localPlayer) then if not searchState then searchState = true showCursor(true) createJunks() addEventHandler("onClientRender", getRootElement(), renderJunk) exports["sgr_main"]:syncAnimationFromServer(localPlayer, "BOMBER", "BOM_Plant_Loop", -1, true, false, false, false) end else exports["cg_notifications"]:addNotification("Járműben nem használhatod ezt a parancsot!", "error") end else exports["cg_notifications"]:addNotification("Ezt a parancsot csak szeméttelepen tudod használni!", "error") end end end addCommandHandler("turkal", startSearching) function isPlayerSearchingInJunkyard(player) if player and isElement(player) and getElementType(player) == "player" then if searchState == true then return true else return false end end return false end ----------------------------------------------------- -- From https://wiki.multitheftauto.com/wiki/DxDrawCircle (was only used for debug drawings) function dxDrawCircle( posX, posY, radius, width, angleAmount, startAngle, stopAngle, color, postGUI ) if ( type( posX ) ~= "number" ) or ( type( posY ) ~= "number" ) then return false end local function clamp( val, lower, upper ) if ( lower > upper ) then lower, upper = upper, lower end return math.max( lower, math.min( upper, val ) ) end radius = type( radius ) == "number" and radius or 50 width = type( width ) == "number" and width or 5 angleAmount = type( angleAmount ) == "number" and angleAmount or 1 startAngle = clamp( type( startAngle ) == "number" and startAngle or 0, 0, 360 ) stopAngle = clamp( type( stopAngle ) == "number" and stopAngle or 360, 0, 360 ) color = color or tocolor( 255, 255, 255, 200 ) postGUI = type( postGUI ) == "boolean" and postGUI or false if ( stopAngle < startAngle ) then local tempAngle = stopAngle stopAngle = startAngle startAngle = tempAngle end for i = startAngle, stopAngle, angleAmount do local startX = math.cos( math.rad( i ) ) * ( radius - width ) local startY = math.sin( math.rad( i ) ) * ( radius - width ) local endX = math.cos( math.rad( i ) ) * ( radius + width ) local endY = math.sin( math.rad( i ) ) * ( radius + width ) dxDrawLine( startX + posX, startY + posY, endX + posX, endY + posY, color, width, postGUI ) end return true end -- From http://cgp.wikidot.com/circle-to-circle-collision-detection function isCircleInCircle(x1, y1, r1, x2, y2, r2) return math.sqrt( ( x2-x1 ) * ( x2-x1 ) + ( y2-y1 ) * ( y2-y1 ) ) < ( r1 + r2 ) end -- From https://wiki.multitheftauto.com/wiki/FindRotation function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end -- From https://wiki.multitheftauto.com/wiki/GetPointFromDistanceRotation function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end -- From https://gamedev.stackexchange.com/questions/26713/calculate-random-points-pixel-within-a-circle-image/26714 function getRandomPointInCircle(x, y, radius) local angle = math.random() * math.pi * 2 radius = math.random() * radius local x = x + radius * math.cos(angle) local y = y + radius * math.sin(angle) return x, y end Changes: No more division in the rendering part for item and junks image center (calculated at the creation and stored in the "objects" in halfSize attribute) Getting the cursor position with the absolute convertion only once per frame instead of #junks per frame (cx, cy) Removed your exported function and calculate if inside the board manually outside the junk loop as we have all informations we need (cursorInsideBoard) Getting the mouse1 key state only once per frame instead of #junks per frame (mouse1State) Moved the string concatenations for the junk's image path into createJunks function. Also what are you trying to do at line 173 please ? -
Need help with DX, positions, rotations and tables
Citizen replied to Dzsozi (h03)'s topic in Scripting
Ok here you go (I've cheated the mouse radius in the result below): MP4 (HQ) The way to do it was to set a boolean (itemDiscovered) to true before looping through the junks and set it to false if a junk's hitbox collides the item's hitbox using the previously used isCircleInCircle. After the for loop, we check if that boolean value is still true, if yes then we discovered the item. But as we are in an onClientRender, we need another boolean (itemDiscoveredAlready) to prevent it to call the discovered function for every next frames. Source: local sx, sy = guiGetScreenSize() local junkSize = sx/3 local junkImageDistance = 50 local junkPositionX, junkPositionY = sx/2-junkSize/2, sy/2-junkSize/2 local searchingTimer = nil local searchState = false local item = nil -- no item at first local junks = {} -- holds all junks images with position, rotation etc local board = {x = junkPositionX, y = junkPositionY, width = junkSize, height = junkSize} local mouseRadius = 20 -- how big the mouse's hitbox is (higher = easier to move junks) local repulseSpeed = 5 -- how fast the junks go away from mouse's hitbox local junkyardCollision = nil local searchTime = 1000 local searchTimeMultiplier = 1 local minimumSearchTimeMultiplier, maximumSearchTimeMultiplier = 5, 15 function createJunkyards() for k,v in ipairs(junkyards) do junkyardCollision = createColCuboid(v[1], v[2], v[3]-0.85, v[4], v[5], v[6]) end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), createJunkyards) local junkImages = { -- image, size, hitradius {"burgershot-bag", 128, 30}, {"burgershot-bag", 128, 30}, {"burgershot-bag", 128, 30}, {"cup", 128, 25}, {"cup", 128, 25}, {"cup", 128, 25}, {"cup", 128, 25}, {"boot", 256, 75}, {"bin-bag", 256, 75}, {"bin-bag", 256, 75}, {"apple", 128, 10}, {"apple", 128, 10}, {"paper", 128, 10}, {"paper", 128, 10}, {"paper", 128, 10}, {"paper", 128, 10}, {"paper", 128, 10}, {"bottle", 128, 25}, {"bottle", 128, 25}, {"glass", 128, 50}, {"tin-can", 128, 25}, {"tin-can", 128, 25}, {"tin-can", 128, 25} } function createJunks() -- creating junks junks = {} for k, v in ipairs(junkImages) do local size = v[2] local rot = math.random(1,360) local midX, midY = getRandomPointInCircle(board.x+board.width/2, board.y+board.width/2, board.width/2) local x, y = midX - size/2, midY - size/2 -- we want the middle of the image to be placed at that point table.insert(junks, {x = x, y = y, size = size, img = v[1], rot = rot, hitradius = v[3]}) end -- creating the item (should be in another function imo) local itemSize = 64 local itemX, itemY = getRandomPointInCircle(board.x+board.width/2, board.y+board.width/2, board.width/3) itemX, itemY = itemX - itemSize/2, itemY - itemSize/2 -- we want the middle of the image to be placed at that point local itemRadius = itemSize/2 local color = tocolor(255, 0, 0, 255) -- full red by default -- no need for item to be a list of dictionaries, just a dictionary: item = {x = itemX, y = itemY, size = itemSize, radius = itemRadius, color = color} -- reseting that global itemDiscoveredAlready = false end showCursor(true) -- debug (add it to your command that shows the junk) bindKey("f5", "down", createJunks) -- debug (F5 to (re)create the junk) function renderJunk() -- Safety check just un case to prevent spamming errors if try to draw before calling createJunks if #junks == 0 or not item then return end dxDrawRectangle(board.x, board.y, board.width, board.height, tocolor(0, 0, 0, 150)) -- debug (junk board) --dxDrawCircle(board.x+board.width/2, board.y+board.width/2, board.width/4, 1, 1, 0, 360, tocolor(0, 0, 0, 255)) -- debug (spawn area - black circle) -- drawing item -- local itemX, itemY = item.x, item.y local itemSize = item.size local itemRadius = item.radius local itemColor = item.color dxDrawRectangle(itemX, itemY, itemSize, itemSize, itemColor) -- drawing junks -- local itemDiscovered = true -- will tell us after the loop if there is still a junk on it for k, j in ipairs(junks) do local cx, cy = getCursorPosition() cx, cy = cx * sx, cy * sy -- absolute cursor position local imgCenterX, imgCenterY = j.x+j.size/2, j.y+j.size/2 -- center of the junk's image dxDrawImage(j.x, j.y, j.size, j.size, "junkyard/files/" ..j.img..".png", j.rot, 0, 0, tocolor(255,255,255,255), false) -- dxDrawCircle(imgCenterX, imgCenterY, j.hitradius, 1, 1, 0, 360, tocolor(0, 0, 200, 100)) -- debug (junk's hitbox - blue circle) -- dxDrawCircle(cx, cy, mouseRadius, 1, 1, 0, 360, tocolor(255, 255, 0, 255)) -- debug (mouse's hitbox) -- handling item discovery local itemCenterX, itemCenterY = itemX + itemSize/2, itemY + itemSize/2 -- "if the item is still considered as discovered but the current junk's hitbox collides with the item then ..." if itemDiscovered and isCircleInCircle(imgCenterX, imgCenterY, j.hitradius, itemCenterX, itemCenterY, itemRadius) then itemDiscovered = false -- "we finally consider it's not discovered" -- Setting it to false will also stop the code to call the isCircleInCircle above for the remaining junks end dxDrawCircle(itemCenterX, itemCenterY, itemRadius, 1, 1, 0, 360, tocolor(245, 140, 20, 255)) -- debug (item's hitbox) -- Moving junks ability: if getKeyState("mouse1") and isCircleInCircle(imgCenterX, imgCenterY, j.hitradius, cx, cy, mouseRadius) then -- move it away if it collides with the cursor's hitbox if exports["sgr_main"]:isMouseInPosition(board.x, board.y, board.width, board.height) then local angle = findRotation(imgCenterX, imgCenterY, cx, cy) local newX, newY = getPointFromDistanceRotation(imgCenterX, imgCenterY, repulseSpeed, -angle + 180) local offsetX, offsetY = imgCenterX - newX, imgCenterY - newY j.x, j.y = j.x-offsetX, j.y-offsetY -- debug: --local newX, newY = getPointFromDistanceRotation(imgCenterX, imgCenterY, 200, -angle + 180) -- debug --dxDrawLine(imgCenterX, imgCenterY, newX, newY, tocolor(0, 200, 0, 255)) -- debug (shows direction where the junk is going - green line) end end end -- We drew and calculated everything for that frame. Did we just discover the item ? if itemDiscovered and not itemDiscoveredAlready then item.color = tocolor(0, 255, 0, 255) -- full green itemDiscoveredAlready = true -- This will prevent it to be called for every next frames onItemDiscovered( item ) -- call the function for when we discover the item end end addEventHandler("onClientRender", getRootElement(), renderJunk) -- called as soon as an item is discovered function onItemDiscovered( item ) outputChatBox("item discovered !") -- do lightweight stuff here as we are still inside a onClientRender call end function startSearching() if junkyardCollision and isElement(junkyardCollision) then if isElementWithinColShape(localPlayer, junkyardCollision) then if not searchState then searchTimeMultiplier = math.random(minimumSearchTimeMultiplier,maximumSearchTimeMultiplier) local finalSearchTime = searchTime*searchTimeMultiplier showCursor(true) createJunks() addEventHandler("onClientRender", getRootElement(), renderJunk) searchState = true triggerServerEvent("syncSearchingFromServer", localPlayer, localPlayer, finalSearchTime) searchingTimer = setTimer(function() showCursor(false) triggerServerEvent("giveFoundJunkItem", localPlayer, localPlayer) removeEventHandler("onClientRender", getRootElement(), renderJunk) end,finalSearchTime,1) end else exports["cg_notifications"]:addNotification("Ezt a parancsot csak szeméttelepen tudod használni!", "error") end end end addCommandHandler("turkal", startSearching) function isPlayerSearchingInJunkyard(player) if player and isElement(player) and getElementType(player) == "player" then if searchState == true then return true else return false end end return false end ----------------------------------------------------- -- From https://wiki.multitheftauto.com/wiki/DxDrawCircle (was only used for debug drawings) function dxDrawCircle( posX, posY, radius, width, angleAmount, startAngle, stopAngle, color, postGUI ) if ( type( posX ) ~= "number" ) or ( type( posY ) ~= "number" ) then return false end local function clamp( val, lower, upper ) if ( lower > upper ) then lower, upper = upper, lower end return math.max( lower, math.min( upper, val ) ) end radius = type( radius ) == "number" and radius or 50 width = type( width ) == "number" and width or 5 angleAmount = type( angleAmount ) == "number" and angleAmount or 1 startAngle = clamp( type( startAngle ) == "number" and startAngle or 0, 0, 360 ) stopAngle = clamp( type( stopAngle ) == "number" and stopAngle or 360, 0, 360 ) color = color or tocolor( 255, 255, 255, 200 ) postGUI = type( postGUI ) == "boolean" and postGUI or false if ( stopAngle < startAngle ) then local tempAngle = stopAngle stopAngle = startAngle startAngle = tempAngle end for i = startAngle, stopAngle, angleAmount do local startX = math.cos( math.rad( i ) ) * ( radius - width ) local startY = math.sin( math.rad( i ) ) * ( radius - width ) local endX = math.cos( math.rad( i ) ) * ( radius + width ) local endY = math.sin( math.rad( i ) ) * ( radius + width ) dxDrawLine( startX + posX, startY + posY, endX + posX, endY + posY, color, width, postGUI ) end return true end -- From http://cgp.wikidot.com/circle-to-circle-collision-detection function isCircleInCircle(x1, y1, r1, x2, y2, r2) return math.sqrt( ( x2-x1 ) * ( x2-x1 ) + ( y2-y1 ) * ( y2-y1 ) ) < ( r1 + r2 ) end -- From https://wiki.multitheftauto.com/wiki/FindRotation function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end -- From https://wiki.multitheftauto.com/wiki/GetPointFromDistanceRotation function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end -- From https://gamedev.stackexchange.com/questions/26713/calculate-random-points-pixel-within-a-circle-image/26714 function getRandomPointInCircle(x, y, radius) local angle = math.random() * math.pi * 2 radius = math.random() * radius local x = x + radius * math.cos(angle) local y = y + radius * math.sin(angle) return x, y end Also note that the mouseRadius will change with resolutions as it's in pixels. Same goes for repulseSpeed which is additionally dependent on FPS. For better performance, you should not add too much junks nor call exported functions (at line 127) but local functions instead (consider copying and paste the function at the bottom of that script). -
Check your meta.xml and make sure that your script menu_client.lua is included as "client" type Check this wiki page for more info: https://wiki.multitheftauto.com/wiki/Meta.xml
-
Give a link so that I can check how it is supposed to be installed.
-
As we don't have a onPlayerTeamChanged event (yet ?) you can rewrite your code to something like this: function setTeamColor() for _,player in ipairs(getElementsByType("player")) do for _,blip in ipairs(getElementsByType("blip")) do local team = getPlayerTeam(player) if team then local r,g,b = getTeamColor(team) setPlayerNametagColor(player,r,g,b) setBlipColor(blip,r,g,b,255) removeElementData(player, "isRandomColorAlreadySet") -- unmark as set (will get a new random color if he leaves the team) else -- if he doesn't have any team local isRandomColorAlreadySet = getElementData(player, "isRandomColorAlreadySet") -- check if marked as random color set if not isRandomColorAlreadySet then -- if not marked as random color set setRandomColorFor(player) -- set random color end end end end end setTimer(setTeamColor,500,0) -- 500ms is still quick enough for what it does (lower the value back if you don't agree) function setRandomColorFor( player ) local r,g,b = math.random(255), math.random(255), math.random(255) setPlayerNametagColor(player,r,g,b) setBlipColor(blip,r,g,b,255) setElementData(player, "isRandomColorAlreadySet", true) -- mark as random color set end The player will get a new random color everytime he leaves a team, he reconnects, or the script/server restarts.
-
Is there any readme with the gamemode ? Where did you find that gamemode ?
-
Test again. What SuperCroz said is right, this should work as attended. If you can not enter the vehicle, then it's probably because you are not logged in, or if you are, maybe with the wrong account. Try printing the accountName value to check that. Also, tell us what you get in the chatbox if it's not working.
-
Well, can you double click around the middle of the map.png and reply here with the value you get for mapX, mapY, mapWidth, mapHeight, absX, absY, relX, relY, x, y. I was not saying they are not defined, just that their values are wrong. So yeah, maybe show fine in chatbox but are they correct is what I'm wondering.
-
mysql:free_result doesn't return any value ! You want to fetch each row from the result by doing calls to mysql:fetch_assoc until it returns nil. function loadPlayerInfo(thePlayer) local dbid = getElementData(thePlayer, "databaseid") local result = mysql:query_fetch_assoc("SELECT * FROM dogs WHERE pID = '" ..dbid.."'") local dogs = {} if result then while true then local row = mysql:fetch_assoc( result ) if not row then break end table.insert(dogs, row) -- add the sql row to dogs list end mysql:free_result(result) -- important to prevent memory leak end if (dogs and #dogs > 0) then print("Found "..#dogs.." dog(s) for pID "..tostring(dbId)) print(dogs) else --No dog saved to DB print("No Dog In DB.") end end addCommandHandler("loaddogs", loadPlayerInfo)
-
I've used the contact form on your forum asking if you were part of the group, I don't know if it works. Anyway, processLineOfSight returns nil probably because your calculations are incorrect and you end up calling that function at a wrong x and y position. You probably wanted to do something like this at line 17: local mapX, mapY, mapWidth, mapHeight = x*10, y*7, x*600, y*551 If for some reason, it's still not working, try to print the x and y variables.