-
Posts
696 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Dzsozi (h03)
-
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
It works, thank you! -
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
I would like to ask for help with one more thing. I was trying to do the skins depending on the shop, so this double table thing, but I don't really understand how should I get the skins inside the second table. I tried one method but it is not working, how I could do that? function changeSkin ( player, key ) if (key == "arrow_l") then if (index [player] == 1) then index [player] = skinShops[current][#skins] else index [player] = (index[player] - 1) end else if (index [player] == skinShops[current][#skins]) then index [player] = 1 else index [player] = (index[player] + 1) end end setElementModel (player, skinShops[current][skins][index [player]]) playSoundFrontEnd (player, 32) end And here's the tables skinShops = { -- markerX, markerY, markerZ, markerDimension, markerInterior, previewX, previewY, previewZ, previewRot, previewDimension, previewInterior, previewCamX, previewCamY, previewCamZ, previewCamLX, previewCamLY, previewCamLZ, exitPosX, exitPosY, exitposZ, markerID --marker #1 {413.72509765625, 1039.0155029297, 18, 0, 0, --shopMarkerPos, dimension, interior 418.73413085938, 1038.1110839844, 25.25609588623, 61.661361694336, 0, 0, --previewPos, rot, dimension, interior 414.91680908203, 1039.669921875, 26.514999389648, 415.83294677734, 1039.3103027344, 26.337924957275, --previewCamPos 414.23324584961, 1042.4398193359, 25.409734725952, 5.6778540611267, 0, 0, --exitPos, rot, dimension, interior 1, skins = {2, 8}}, --markerID --marker #2 {-17.091650009155, -928.99041748047, 9.45, 0, 0, -9.9858913421631, -928.94659423828, 10.419666290283, 184.99253845215, 0, 0, -10.584600448608, -933.49438476563, 10.881799697876, -10.511178970337, -932.49749755859, 10.911037445068, -15.293229103088, -933.56903076172, 10.419666290283, 213.12492370605, 0, 0, 2, skins = {25, 26}}, } And I get this error: attempt to get length of global 'skins' (a nil value). What is the problem? -
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Works, thank you very much! -
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Alright, so I bumped into another issue. I transfered the marker creation to client side, so I can add dxDrawText on them, and etc, but now I have a little problem with triggering the server side function. I have the following in the client side script: addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() for k, v in pairs(skinShops) do local skinShopBlip = createBlip(v[1], v[2], v[3], 45, 2, 0, 180, 255, 255) local skinShopMarker = createMarker(v[1], v[2], v[3], "cylinder", 1.5, 0, 180, 255, 75) setElementData(skinShopMarker, "markerID-->skinShop", v[24]) addEventHandler("onClientRender", root, function() exports.vice_util:dxDrawTextOnElement(skinShopMarker, "Ruhabolt", 1, 20, 255, 255, 255, 255, 2, "default-bold") end) setElementDimension(skinShopMarker, v[4]) setElementInterior(skinShopMarker, v[5]) addEventHandler("onClientMarkerHit", skinShopMarker, function(hitPlayer, matchingDimension) triggerServerEvent("selectSkin", hitPlayer, hitPlayer) end) end end) The following in a shared/global script (in the meta file it's type is set to shared): availableSkins = { 2, 7, 12, 13, 16, 19, 20, 21, 22, 23, 24, 25, 26, } skinShops = { -- markerX, markerY, markerZ, markerDimension, markerInterior, previewX, previewY, previewZ, previewRot, previewDimension, previewInterior, previewCamX, previewCamY, previewCamZ, previewCamLX, previewCamLY, previewCamLZ, exitPosX, exitPosY, exitposZ, markerID --marker #1 {413.72509765625, 1039.0155029297, 24.25, 0, 0, --shopMarkerPos, dimension, interior 418.73413085938, 1038.1110839844, 25.25609588623, 61.661361694336, 0, 0, --previewPos, rot, dimension, interior 414.91680908203, 1039.669921875, 26.514999389648, 415.83294677734, 1039.3103027344, 26.337924957275, --previewCamPos 414.23324584961, 1042.4398193359, 25.409734725952, 5.6778540611267, 0, 0, --exitPos, rot, dimension, interior 1}, --markerID --marker #2 {1953.2912597656, -2073.4045410156, 12.933400154114, 0, 0, 1939.267578125, -2085.708984375, 12.905400276184, -90, 0, 0, 1951.8502197266, -2083.51171875, 14.838299751282, 1950.8914794922, -2083.7155761719, 14.640121459961, 1954.2136230469, -2086.5083007813, 12.888199806213, 60, 0, 0, 2}, } And the following in the server side script: local originalSkin local index = {} --[[addEventHandler("onResourceStart", resourceRoot, function() for i = 1, #skinShops do local currentShop = skinShops[i] if currentShop then local skinShopMarker = createMarker(currentShop[1], currentShop[2], currentShop[3], "cylinder", 1.5, 0, 180, 255, 75) setElementData(skinShopMarker, "markerID-->skinShop", currentShop[24]) setElementDimension(skinShopMarker, currentShop[4]) setElementInterior(skinShopMarker, currentShop[5]) addEventHandler("onMarkerHit", skinShopMarker, selectSkin) end end end)]] function selectSkin (player) if getElementType(player) == "player" and not isPedInVehicle(player) and not isPedDead(player) then current = getElementData(source, "markerID-->skinShop") setElementFrozen ( player, true ) showCursor ( player, true ) bindKey ( player, "backspace", "down", cancelBuy ) bindKey ( player, "enter", "down", buySkin ) bindKey ( player, "arrow_l", "down", changeSkin ) bindKey ( player, "arrow_r", "down", changeSkin ) fadeCamera ( player, true ) index [player] = 1 setElementPosition ( player, skinShops[current][6], skinShops[current][7], skinShops[current][8] ) setTimer(function() setPedRotation ( player, skinShops[current][9] ) end, 500, 1, player) setElementDimension (player, skinShops[current][10]) setElementInterior (player, skinShops[current][11]) setCameraMatrix ( player, skinShops[current][12], skinShops[current][13], skinShops[current][14], skinShops[current][15], skinShops[current][16], skinShops[current][17] ) originalSkin = getElementModel( player ) else cancelEvent() end end addEvent("selectSkin", true) addEventHandler("selectSkin", root, selectSkin) function cancelBuy ( player ) setElementFrozen ( player, false ) showCursor ( player, false ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setCameraTarget ( player, player ) setElementModel ( player, originalSkin ) unbindKey ( player, "backspace", "down", cancelBuy ) unbindKey ( player, "enter", "down", buySkin ) unbindKey ( player, "arrow_l", "down", changeSkin ) unbindKey ( player, "arrow_r", "down", changeSkin ) end function changeSkin ( player, key ) if (key == "arrow_l") then if (index [player] == 1) then index [player] = #availableSkins else index [player] = (index[player] - 1) end else if (index [player] == #availableSkins) then index [player] = 1 else index [player] = (index[player] + 1) end end setElementModel (player, availableSkins[index [player]]) playSoundFrontEnd (player, 32) end function buySkin ( player ) setElementFrozen ( player, false ) showCursor ( player, false ) playSoundFrontEnd ( player, 44 ) unbindKey ( player, "backspace", "down", cancelBuy ) unbindKey ( player, "enter", "down", buySkin ) unbindKey ( player, "arrow_l", "down", changeSkin ) unbindKey ( player, "arrow_r", "down", changeSkin ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setCameraTarget ( player, player ) takePlayerMoney(player, 50) end And I get this error when I hit the marker: shopS.lua:29: attempt to index field '?' (a nil value) And when I hit backspace to exit the shop I get the same but at line 47. These lines are the setElementPosition(player ...) lines in the selectSkin and the cancelBuy functions. What could be the problem and how to fix it? -
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Okay, I will try it, thank you very much! -
For others who want to do that, you forgot to add weapon-skill ("poor", "std", and "pro") but other than that this one works perfectly, thank you so much!
-
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Then I guess it would be easier to make another table in the skinshops table and delete the availableskins table, so I can have skins depending on the shops. Maybe? -
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Oh, I understand, I could fix it, thank you very much! I would have one more question. How can I make types of "shops"? For example I have marker #1 and there would be skin id 1 only, and at marker #2 there would be skin id 2 only, just an example, but hope you understand me. I assume I would have to do something with the availableSkins table, define the marker ID there as well, or something like that, but I don't know how. Could you help me with that please? -
I have a little problem with tables and markers
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Did you mean something like this? local originalSkin local current = 1 local availableSkins = { 2, 7, 12, 13, 16, 19, 20, 21, 22, 23, 24, 25, 26, } local skinShops = { -- markerX, markerY, markerZ, markerDimension, markerInterior, previewX, previewY, previewZ, previewRot, previewDimension, previewInterior, previewCamX, previewCamY, previewCamZ, previewCamLX, previewCamLY, previewCamLZ, exitPosX, exitPosY, exitposZ, markerID --marker #1 {1950.908203125, -2049.2995605469, 12.4, 0, 0, --shopMarkerPos, dimension, interior 1976.33984375, -2048.2937011719, 12.884400367737, 80, 0, 0, --previewPos, rot, dimension, interior 1963.5827636719, -2053.611328125, 15.560099601746, 1964.4354248047, -2053.1540527344, 15.307735443115, --previewCamPos 1974.8217773438, -2056.7233886719, 14.861300468445, 60, 0, 0, --exitPos, rot, dimension, interior 1}, --markerID --marker #2 {1953.2912597656, -2073.4045410156, 12.933400154114, 0, 0, 1939.267578125, -2085.708984375, 12.905400276184, -90, 0, 0, 1951.8502197266, -2083.51171875, 14.838299751282, 1950.8914794922, -2083.7155761719, 14.640121459961, 1954.2136230469, -2086.5083007813, 12.888199806213, 60, 0, 0, 2}, } local index = {} addEventHandler("onResourceStart", resourceRoot, function() for i = 1, #skinShops do local currentShop = skinShops[i] if currentShop then skinShopMarker = createMarker(currentShop[1], currentShop[2], currentShop[3], "cylinder", 1.5, 0, 180, 255, 75) setElementData(skinShopMarker, "3dtext", "Ruhabolt") setElementData(skinShopMarker, "markerID-->skinShop", currentShop[24]) setElementDimension(skinShopMarker, currentShop[4]) setElementInterior(skinShopMarker, currentShop[5]) addEventHandler("onMarkerHit", skinShopMarker, selectSkin) end end end) function selectSkin (player) local current = getElementData(skinShopMarker, "markerID-->skinShop") showCursor ( player, true ) bindKey ( player, "backspace", "down", cancelBuy ) bindKey ( player, "enter", "down", buySkin ) bindKey ( player, "arrow_l", "down", changeSkin ) bindKey ( player, "arrow_r", "down", changeSkin ) fadeCamera ( player, true ) index [player] = 1 setElementPosition ( player, skinShops[current][6], skinShops[current][7], skinShops[current][8] ) setPedRotation ( player, skinShops[current][9] ) setElementDimension (player, skinShops[current][10]) setElementInterior (player, skinShops[current][11]) setElementFrozen ( player, true ) setCameraMatrix ( player, skinShops[current][12], skinShops[current][13], skinShops[current][14], skinShops[current][15], skinShops[current][16], skinShops[current][17] ) originalSkin = getElementModel( player ) end function cancelBuy ( player ) local current = getElementData(skinShopMarker, "markerID-->skinShop") showCursor ( player, false ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setElementFrozen ( player, false ) setCameraTarget ( player, player ) setElementModel ( player, originalSkin ) end function changeSkin ( player, key ) if (key == "arrow_l") then if (index [player] == 1) then index [player] = #availableSkins else index [player] = (index[player] - 1) end else if (index [player] == #availableSkins) then index [player] = 1 else index [player] = (index[player] + 1) end end setElementModel (player, availableSkins[index [player]]) playSoundFrontEnd (player, 32) end function buySkin ( player ) local current = getElementData(skinShopMarker, "markerID-->skinShop") showCursor ( player, false ) playSoundFrontEnd ( player, 44 ) unbindKey ( player, "backspace", "down", cancelBuy ) unbindKey ( player, "enter", "down", buySkin ) unbindKey ( player, "arrow_l", "down", changeSkin ) unbindKey ( player, "arrow_r", "down", changeSkin ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setElementFrozen ( player, false ) setCameraTarget ( player, player ) takePlayerMoney(player, 50) end Or this? local current = 1 local originalSkin local availableSkins = { 2, 7, 12, 13, 16, 19, 20, 21, 22, 23, 24, 25, 26, } local skinShops = { -- markerX, markerY, markerZ, markerDimension, markerInterior, previewX, previewY, previewZ, previewRot, previewDimension, previewInterior, previewCamX, previewCamY, previewCamZ, previewCamLX, previewCamLY, previewCamLZ, exitPosX, exitPosY, exitposZ, markerID --marker #1 {1950.908203125, -2049.2995605469, 12.4, 0, 0, --shopMarkerPos, dimension, interior 1976.33984375, -2048.2937011719, 12.884400367737, 80, 0, 0, --previewPos, rot, dimension, interior 1963.5827636719, -2053.611328125, 15.560099601746, 1964.4354248047, -2053.1540527344, 15.307735443115, --previewCamPos 1974.8217773438, -2056.7233886719, 14.861300468445, 60, 0, 0, --exitPos, rot, dimension, interior 1}, --markerID --marker #2 {1953.2912597656, -2073.4045410156, 12.933400154114, 0, 0, 1939.267578125, -2085.708984375, 12.905400276184, -90, 0, 0, 1951.8502197266, -2083.51171875, 14.838299751282, 1950.8914794922, -2083.7155761719, 14.640121459961, 1954.2136230469, -2086.5083007813, 12.888199806213, 60, 0, 0, 2}, } local index = {} addEventHandler("onResourceStart", resourceRoot, function() for i = 1, #skinShops do local currentShop = skinShops[i] if currentShop then local skinShopMarker = createMarker(currentShop[1], currentShop[2], currentShop[3], "cylinder", 1.5, 0, 180, 255, 75) setElementData(skinShopMarker, "3dtext", "Ruhabolt") setElementData(skinShopMarker, "markerID-->skinShop", currentShop[24]) setElementDimension(skinShopMarker, currentShop[4]) setElementInterior(skinShopMarker, currentShop[5]) addEventHandler("onMarkerHit", skinShopMarker, selectSkin) current = getElementData(skinShopMarker, "markerID-->skinShop") end end end) function selectSkin (player) showCursor ( player, true ) bindKey ( player, "backspace", "down", cancelBuy ) bindKey ( player, "enter", "down", buySkin ) bindKey ( player, "arrow_l", "down", changeSkin ) bindKey ( player, "arrow_r", "down", changeSkin ) fadeCamera ( player, true ) index [player] = 1 setElementPosition ( player, skinShops[current][6], skinShops[current][7], skinShops[current][8] ) setPedRotation ( player, skinShops[current][9] ) setElementDimension (player, skinShops[current][10]) setElementInterior (player, skinShops[current][11]) setElementFrozen ( player, true ) setCameraMatrix ( player, skinShops[current][12], skinShops[current][13], skinShops[current][14], skinShops[current][15], skinShops[current][16], skinShops[current][17] ) originalSkin = getElementModel( player ) end function cancelBuy ( player ) showCursor ( player, false ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setElementFrozen ( player, false ) setCameraTarget ( player, player ) setElementModel ( player, originalSkin ) end function changeSkin ( player, key ) if (key == "arrow_l") then if (index [player] == 1) then index [player] = #availableSkins else index [player] = (index[player] - 1) end else if (index [player] == #availableSkins) then index [player] = 1 else index [player] = (index[player] + 1) end end setElementModel (player, availableSkins[index [player]]) playSoundFrontEnd (player, 32) end function buySkin ( player ) showCursor ( player, false ) playSoundFrontEnd ( player, 44 ) unbindKey ( player, "backspace", "down", cancelBuy ) unbindKey ( player, "enter", "down", buySkin ) unbindKey ( player, "arrow_l", "down", changeSkin ) unbindKey ( player, "arrow_r", "down", changeSkin ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setElementFrozen ( player, false ) setCameraTarget ( player, player ) takePlayerMoney(player, 50) end (None of them work) -
Hello! I would like to create a table for skin shop markers, and create a marker for each position I give in the table. The markers are being created, the camera positions are set, everything is good except one thing, I always get the positions of the last given section of the table. local originalSkin local availableSkins = { 2, 7, 12, 13, 16, 19, 20, 21, 22, 23, 24, 25, 26, } local skinShops = { -- markerX, markerY, markerZ, markerDimension, markerInterior, previewX, previewY, previewZ, previewRot, previewDimension, previewInterior, previewCamX, previewCamY, previewCamZ, previewCamLX, previewCamLY, previewCamLZ, exitPosX, exitPosY, exitposZ --marker #1 {1950.908203125, -2049.2995605469, 12.4, 0, 0, --shopMarkerPos, dimension, interior 1976.33984375, -2048.2937011719, 12.884400367737, 80, 0, 0, --previewPos, rot, dimension, interior 1963.5827636719, -2053.611328125, 15.560099601746, 1964.4354248047, -2053.1540527344, 15.307735443115, --previewCamPos 1974.8217773438, -2056.7233886719, 14.861300468445, 60, 0, 0}, --exitPos, rot, dimension, interior --marker #2 {1953.2912597656, -2073.4045410156, 12.933400154114, 0, 0, 1939.267578125, -2085.708984375, 12.905400276184, -90, 0, 0, 1951.8502197266, -2083.51171875, 14.838299751282, 1950.8914794922, -2083.7155761719, 14.640121459961, 1954.2136230469, -2086.5083007813, 12.888199806213, 60, 0, 0}, } local index = {} addEventHandler("onResourceStart", resourceRoot, function() for k, v in pairs(skinShops) do current = k end for i = 1, #skinShops do local currentShop = skinShops[i] if currentShop then local skinShopMarker = createMarker(currentShop[1], currentShop[2], currentShop[3], "cylinder", 1.5, 0, 180, 255, 75) setElementDimension(skinShopMarker, currentShop[4]) setElementInterior(skinShopMarker, currentShop[5]) addEventHandler("onMarkerHit", skinShopMarker, selectSkin) end end end) function selectSkin (player) showCursor ( player, true ) bindKey ( player, "backspace", "down", cancelBuy ) bindKey ( player, "enter", "down", buySkin ) bindKey ( player, "arrow_l", "down", changeSkin ) bindKey ( player, "arrow_r", "down", changeSkin ) fadeCamera ( player, true ) index [player] = 1 setElementPosition ( player, skinShops[current][6], skinShops[current][7], skinShops[current][8] ) setPedRotation ( player, skinShops[current][9] ) setElementDimension (player, skinShops[current][10]) setElementInterior (player, skinShops[current][11]) setElementFrozen ( player, true ) setCameraMatrix ( player, skinShops[current][12], skinShops[current][13], skinShops[current][14], skinShops[current][15], skinShops[current][16], skinShops[current][17] ) originalSkin = getElementModel( player ) end function cancelBuy ( player ) showCursor ( player, false ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setElementFrozen ( player, false ) setCameraTarget ( player, player ) setElementModel ( player, originalSkin ) end function changeSkin ( player, key ) if (key == "arrow_l") then if (index [player] == 1) then index [player] = #availableSkins else index [player] = (index[player] - 1) end else if (index [player] == #availableSkins) then index [player] = 1 else index [player] = (index[player] + 1) end end setElementModel (player, availableSkins[index [player]]) playSoundFrontEnd (player, 32) end function buySkin ( player ) showCursor ( player, false ) playSoundFrontEnd ( player, 44 ) unbindKey ( player, "backspace", "down", cancelBuy ) unbindKey ( player, "enter", "down", buySkin ) unbindKey ( player, "arrow_l", "down", changeSkin ) unbindKey ( player, "arrow_r", "down", changeSkin ) setElementPosition ( player, skinShops[current][18], skinShops[current][19], skinShops[current][20] ) setPedRotation ( player, skinShops[current][21] ) setElementDimension(player, skinShops[current][22]) setElementInterior(player, skinShops[current][23]) setElementFrozen ( player, false ) setCameraTarget ( player, player ) takePlayerMoney(player, 50) end Here's my script. So for example if I go into marker #1 the positions are the positions of marker #2. How can I fix it, so each markers have their own camera positions and other settings that I give?
-
I would like to make an M249 of the minigun, I got everything fine, only thing I have to do now is to slow down the fire rate. Is this posibble somehow? It shoots too fast. I tried using the slow down weapon flag but it didn't change anything.
-
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Got it fixed, thank you so much for taking time on replying and helping me!! -
How can I disable katana's random instant kill?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Not the knife killing from behind but the katana instant kill. If I keep hitting somebody with katana he/she gets lower hp, but then he gets killed suddenly, and it's random, sometimes gets instant killed for the first hit, but sometimes gets killed after 10 hits, but his HP is not low enough to get killed, for example after 10 hits he's got 50hp, but at the 11th hit he gets killed instantly. Hope you know what I mean. -
Hello! I would like to make the katana give you damage, but disable the random instant kills, is this possible? If so, how can I do that?
-
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
I managed to fix it, the "handling" of it works perfect now, only problems are that I get errors in debugscript about getSlotFromWeapon. It says the following: Expected weapon-type at argument 1, got string, and it's at line 259 and 260 which are these lines: weaps["next"] = tonumber(getNextWeapon(getSlotFromWeapon(weaps["curr"]))) weaps["prev"] = tonumber(getPreviousWeapon(getSlotFromWeapon(weaps["curr"]))) It's inside the selectWeapon function, the function that draws the selector. function selectWeapon() weaps["next"] = tonumber(getNextWeapon(getSlotFromWeapon(weaps["curr"]))) weaps["prev"] = tonumber(getPreviousWeapon(getSlotFromWeapon(weaps["curr"]))) if weaps["curr"] == "" then weaps["old"] = getPedWeapon(localPlayer) weaps["curr"] = weaps["old"] end local textx = left + (currentWidth / 2) local texty = (top + (currentHeight / 2)) dxDrawText( "Fegyvereid",textx, texty - 215, textx, texty - 215, tocolor(255,255,255,255), 2, "default", "center", "center", false,false,true) if weaps["curr"] == weaps["old"] then dxDrawRectangle ( left - currentOutline, top - currentOutline, currentWidth + currentOutline*2, currentHeight + currentOutline*2, tocolor ( 200, 0, 100, 180 ) ) elseif weaps["prev"] == weaps["old"] then dxDrawRectangle ( left + 26 - currentOutline, top - 16 + currentHeight + gapBetween - currentOutline, currentWidth - 52 + currentOutline*2, currentHeight - 32 + currentOutline*2, tocolor ( 200, 0, 100, 75 ) ) elseif weaps["next"] == weaps["old"] then dxDrawRectangle ( left + 26 - currentOutline, top + 48 - currentHeight - gapBetween - currentOutline, currentWidth - 52 + currentOutline*2, currentHeight - 32 + currentOutline*2, tocolor ( 200, 0, 100, 75 ) ) end dxDrawRectangle ( left, top, currentWidth, currentHeight, tocolor ( 0, 0, 0, 180 ) ) dxDrawRectangle ( left + 26, top + 48 - currentHeight - gapBetween, currentWidth - 52, currentHeight - 32, tocolor ( 0, 0, 0, 75 ) ) dxDrawRectangle ( left + 26, top - 16 + currentHeight + gapBetween, currentWidth - 52, currentHeight - 32, tocolor ( 0, 0, 0, 75 ) ) dxDrawImage(left + 26, top - currentHeight + gapBetween, 256-128, 128-64, "weap/".. weaps["next"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 100), true) nextAmmo = getPedTotalAmmo(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["next"]))) - getPedAmmoInClip(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["next"]))) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["next"]))) if nextAmmo and getSlotFromWeapon(weaps["next"]) ~= 0 and getSlotFromWeapon(weaps["next"]) ~= 1 and getSlotFromWeapon(weaps["next"]) ~= 10 then dxDrawText( "".. tostring(nextAmmo) .."",textx, texty - 156, textx, texty - 156, tocolor(200,0,100,100), 1, "default", "center", "center", false,false,true,true) end dxDrawImage(left, top, 256, 128, "weap/".. weaps["curr"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 255), true) currentAmmo = getPedTotalAmmo ( getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["curr"]))) - getPedAmmoInClip(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["curr"]))) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["curr"]))) if currentAmmo and getSlotFromWeapon(weaps["curr"]) ~= 0 and getSlotFromWeapon(weaps["curr"]) ~= 1 and getSlotFromWeapon(weaps["curr"]) ~= 10 then dxDrawText( "".. tostring(currentAmmo) .."",textx, texty + 48, textx, texty + 48, tocolor(200,0,100,255), 1.5, "default", "center", "center", false,false,true,true) end dxDrawImage(left + 26, top + currentHeight + gapBetween, 256-128, 128-64, "weap/".. weaps["prev"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 100), true) previousAmmo = getPedTotalAmmo(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["prev"]))) - getPedAmmoInClip(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["prev"]))) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), tonumber(getSlotFromWeapon(weaps["prev"]))) if previousAmmo and getSlotFromWeapon(weaps["prev"]) ~= 0 and getSlotFromWeapon(weaps["prev"]) ~= 1 and getSlotFromWeapon(weaps["prev"]) ~= 10 then dxDrawText( "".. tostring(previousAmmo) .."",textx, texty + 156, textx, texty + 156, tocolor(200,0,100,100), 1, "default", "center", "center", false,false,true,true) end end Is there any way to fix this error spamming? It only happens when I change to a new weapon (press left click). The other problem is when I give myself a new weapon from for example admin panel, the picture of the current weapon and the pink outline doesn't get changed. So lets say I have an AK-47. I give myself an MP5 and when I press Q, at the current weapon I still see the AK-47 and that it's selected, and not the MP5. How can I fix that as well? So when I get a new weapon, the picture and weaponslot data gets updated or something like that. Hope you know what I mean, and thank you for helping! -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
I changed a few settings a little bit, because this is not how I want it to work, but I am also getting some errors and it's not working properly. I changed it back so if I hold Q or a specified button, that is in this case is the Q, then the selector will appear. I could fix a bug where you was only able to switch between melee weapons and fist if you scrolled up and the bug that I got errors about wrong weapon slots. They were strings and I was getting errors about that strings, but I changed them to 0 in the table and now it works. But I don't know one thing, what to change to the weaps["curr"] variable at the changeWeap() function? If I change it to 0 it not works properly, neither if I change it to anything else. Do you have any idea what to change to this one? Or how to fix this problem? (As I said, I have edited the script to work a little bit different, I want to force the players to hold the button if they want to change weapons.) local screenWidth, screenHeight = guiGetScreenSize() local currentWidth, currentHeight = 250, 125 local currentOutline = 4 local gapBetween = 32 local left = (screenWidth/2) - (currentWidth/2) local top = (screenHeight/2) - (currentHeight/2) local controls = { "aim_weapon","radio_next","radio_previous", "fire", "vehicle_fire", "vehicle_secondary_fire" } local isRendered local nextAmmo = nil local currentAmmo = nil local previousAmmo = nil function getNextWeapon(cSlot) local tempSlot = {} local curSlot if cSlot then curSlot = cSlot else curSlot = getPedWeaponSlot(localPlayer) end if (curSlot == 0) then curSlot = 13 end tempSlot["ID"] = 13 repeat tempSlot["ID"] = tempSlot["ID"]-1 until (tempSlot["ID"] < curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0) return getPedWeapon(localPlayer, tempSlot["ID"]) end function getPreviousWeapon(cSlot) local tempSlot = {} local curSlot if cSlot then curSlot = cSlot else curSlot = getPedWeaponSlot(localPlayer) end if (curSlot == 13) then curSlot = 0 end tempSlot["ID"] = - 1 repeat tempSlot["ID"] = tempSlot["ID"] + 1 if tempSlot["ID"] == 13 then tempSlot["ID"] = -1 curSlot = -1 end until (tempSlot["ID"] > curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0) return getPedWeapon(localPlayer, tempSlot["ID"]) end local weaps = { ["old"] = 0, ["curr"] = 0, ["next"] = 0, ["prev"] = 0 } function changeNextWeapon() if weaps["curr"] == 0 then weaps["old"] = getPedWeapon(getLocalPlayer()) weaps["curr"] = weaps["old"] else weaps["curr"] = getNextWeapon(getSlotFromWeapon(weaps["curr"])) end end function changePrevWeapon() if weaps["curr"] == 0 then weaps["old"] = getPedWeapon(getLocalPlayer()) weaps["curr"] = weaps["old"] else weaps["curr"] = getPreviousWeapon(getSlotFromWeapon(weaps["curr"])) end end function changeWeap() setPedWeaponSlot(localPlayer, getSlotFromWeapon(weaps["curr"])) weaps["curr"] = weaps["prev"] end function selectWeapon() weaps["next"] = getNextWeapon(getSlotFromWeapon(weaps["curr"])) weaps["prev"] = getPreviousWeapon(getSlotFromWeapon(weaps["curr"])) local textx = left + (currentWidth / 2) local texty = (top + (currentHeight / 2)) dxDrawText( "Fegyvereid",textx, texty - 215, textx, texty - 215, tocolor(200,0,100,255), 2, "default", "center", "center", false,false,true) if weaps["old"] == weaps["curr"] then dxDrawRectangle ( left - currentOutline, top - currentOutline, currentWidth + currentOutline*2, currentHeight + currentOutline*2, tocolor ( 200, 0, 100, 180 ) ) end dxDrawRectangle ( left, top, currentWidth, currentHeight, tocolor ( 0, 0, 0, 180 ) ) dxDrawRectangle ( left + 26, top + 48 - currentHeight - gapBetween, currentWidth - 52, currentHeight - 32, tocolor ( 0, 0, 0, 180 ) ) dxDrawRectangle ( left + 26, top - 16 + currentHeight + gapBetween, currentWidth - 52, currentHeight - 32, tocolor ( 0, 0, 0, 180 ) ) dxDrawImage(left + 26, top - currentHeight + gapBetween, 256-128, 128-64, "weap/".. weaps["next"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 100), true) nextAmmo = getPedTotalAmmo(getLocalPlayer(), getSlotFromWeapon(weaps["next"])) - getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(weaps["next"])) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(weaps["next"])) if nextAmmo then --and weaponslot > 0 then dxDrawText( "".. nextAmmo .."",textx, texty - 156, textx, texty - 156, tocolor(200,0,100,100), 1, "default", "center", "center", false,false,true,true) end dxDrawImage(left, top, 256, 128, "weap/".. weaps["curr"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 255), true) currentAmmo = getPedTotalAmmo ( getLocalPlayer(), getSlotFromWeapon(weaps["curr"])) - getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(weaps["curr"])) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(weaps["curr"])) if currentAmmo then --and weaponslot > 0 then dxDrawText( "".. currentAmmo .."",textx, texty + 48, textx, texty + 48, tocolor(200,0,100,255), 1.5, "default", "center", "center", false,false,true,true) end dxDrawImage(left + 26, top + currentHeight + gapBetween, 256-128, 128-64, "weap/".. weaps["prev"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 100), true) previousAmmo = getPedTotalAmmo(getLocalPlayer(), getSlotFromWeapon(weaps["prev"])) - getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(weaps["prev"])) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(weaps["prev"])) if previousAmmo then --and weaponslot > 0 then dxDrawText( "".. previousAmmo .."",textx, texty + 156, textx, texty + 156, tocolor(200,0,100,100), 1, "default", "center", "center", false,false,true,true) end end addEventHandler( "onClientResourceStart", getRootElement( ), function ( ) toggleControl ( "next_weapon", false ) toggleControl ( "previous_weapon", false ) end ); function onClientKey(key, state) if key == "mouse_wheel_up" and isRendered then changeNextWeapon() elseif key == "mouse_wheel_down" and isRendered then changePrevWeapon() elseif key == "q" and state and not isRendered then addEventHandler("onClientRender", root, selectWeapon) isRendered = not isRendered for k, control in ipairs ( controls ) do toggleControl ( control, false ) end elseif key == "q" then removeEventHandler("onClientRender", root, selectWeapon) isRendered = not isRendered for k, control in ipairs ( controls ) do toggleControl ( control, true ) end elseif key == "mouse1" and state and isRendered then changeWeap() for k, control in ipairs ( controls ) do toggleControl ( control, false ) end end end addEventHandler("onClientKey", getRootElement(), onClientKey) -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
I still don't really understand what or how to do it. What to write and where, could you please help me out? How I could skip the empty weapon slots? I would really appreciate if you could help me out with this! -
[QUESTION] Replace only one specified car, not all models
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Alright, thank you CodyL! -
Hello! I was wondering if it is posibble to change only one car's dff and txd and not overwrite every model. So for example, I have this mod here http://www.gtaall.com/gta-san-andreas/cars/80602-hermes-ratrod.html and I have a default hermes in-game. I drive into a marker and the hermes that I was sitting in gets replaced with this one, but only that one hermes I drived into the marker. Is this possible somehow? If so, how?
-
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Thank you for taking time on creating this diagram and replying, I will try it tomorrow, right now I don't really understand, maybe it's because I don't see the script and I'm tired, but thank you, will try something again! -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Bump. -
Okay, thank you so much again!!
-
It works client-side, but can I make a custom event? For example onPlayerLevelUp and onClientPlayerLevelUp? Or how do these custom events work?
-
Oh my god, I can't believe, thank you very much!!!!!! <3 It works perfectly!! I would like to ask just 1 more question, sorry for bothering you, but how can I make the event I was talking about, for checking if a player leveled up? So therefore I could add notifications from other scripts and things like that.
-
The setPlayerTP command works perfectly with this. How can I make it with givePlayerTP?