Jump to content

hipolitalakaj

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by hipolitalakaj

  1. Hi! I have an inventory system which have weaponindexByID and weaponModels table. I don't get it how can I reference to the weapon model if the weaponindexByID == 30 and the weaponModels == 1254 ? I get the "ok" in the outputchatbox if I reference to the weaponid like this: if weaponIndexByID[item_id] == 30 then outputChatBox("ok") end but I want to get the "ok" in the chatbox if the weaponIndexByID == 30 and the weaponModels == 1254 --- weaponModels table --- weaponModels = { [14] = {1254, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [15] = {356, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [16] = {339, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [18] = {336, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [22] = {358, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [24] = {353, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [23] = {357, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [28] = {349, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [21] = {346, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, } --- weaponIndexByID table --- weaponIndexByID = { [14] = 30, [15] = 31, [16] = 8, [17] = 24, [18] = 5, [19] = 4, [20] = 3, [21] = 22, [22] = 34, [23] = 33, [24] = 29, [25] = 28, [26] = 32, [27] = 23, [28] = 25, }
  2. What do you mean? Something like this? ---- client ---- function receiveItems(data) item_table = {} item_table = data if(itemElement and getElementType(itemElement) == "player" and itemElement == localPlayer or itemElement==nil )then item_table_player = data for index, value in ipairs (item_table) do if value[5] > 0 then item_table_action[tonumber(value[5])] = {item_table[tonumber(index)][6], item_table[tonumber(index)][1], item_table[tonumber(index)][3]} end end end isMove = false movedItem = 0 newCount = 0 movedSlot = -1 movedCount = 0 movedValue = 0 selectedAmount = 0 currentActionSlot = 0 end addEventHandler("onClientResourceStart", getRootElement(), receiveItems)
  3. Um, thanks for your reply. So I need to put a timer? if yes, where I need to put that timer? I still don't get it
  4. Hi! I trying to trigger a clientside event in server.lua which exists in client.lua but the debugscript says "Server triggered clientside event onClientReceiveItems, but event is not added clientside" What's wrong? ---- client ---- function receiveItems(data) item_table = {} item_table = data if(itemElement and getElementType(itemElement) == "player" and itemElement == localPlayer or itemElement==nil )then item_table_player = data for index, value in ipairs (item_table) do if value[5] > 0 then item_table_action[tonumber(value[5])] = {item_table[tonumber(index)][6], item_table[tonumber(index)][1], item_table[tonumber(index)][3]} end end end isMove = false movedItem = 0 newCount = 0 movedSlot = -1 movedCount = 0 movedValue = 0 selectedAmount = 0 currentActionSlot = 0 end addEvent("onClientReceiveItems", true) addEventHandler("onClientReceiveItems", getRootElement(), receiveItems) ---- server ---- function loadPlayerItems(element) local ownerID = tonumber(getElementData(element, "acc:id") or -1) array[0][ownerID] = {} local item = -1 for i = 1, 50 do array[0][ownerID][i] = {-1, -1, -1, -1, -1, -1, -1} end local loadItems = dbPoll(dbQuery(connection, "SELECT * FROM items WHERE owner = ? AND type = 0", ownerID), -1) if #loadItems > 0 then for i, row in ipairs(loadItems) do item = tonumber(row['itemid']) or -1 value = row['value'] or -1 count = tonumber(row['count']) or -1 slot = tonumber(row['slot']) or -1 type = tonumber(row['type']) or -1 slot = tonumber(row['slot']) or -1 id = tonumber(row['id']) or -1 actionslot = tonumber(row['actionslot']) or -1 duty = tonumber(row['dutyitem']) or -1 array[tonumber(getType(element)) or 0][ownerID][slot] = {tonumber(item), value, tonumber(count), tonumber(id), tonumber(actionslot), tonumber(slot), tonumber(duty)} end end triggerClientEvent(element, "onClientReceiveItems", element, array[tonumber(getType(element)) or 0][ownerID]) end addEvent("playerLoadItemsToServer", true) addEventHandler("playerLoadItemsToServer", root, loadPlayerItems)
  5. Umm, now loads the full glock skin, lol it's not invisible https://imgur.com/a/GRuRmBJ
  6. Its works, if I give the ID 30 AK (which is default) then invisible, but if I attach the camo AK to the player's hand with bone_attach then I see the default & the camo AK too... Thanks, but it's not working. Btw it's a glock's txd am I need to get a glock dff too that's why isn't insivible? or what? https://imgur.com/a/u9mnqOj
  7. I can't make to invisible in this way, because I need to provide element for SetElementAlpha function. and the default ak is already in game, not created by me with createweapon function.
  8. I think u meant https://wiki.multitheftauto.com/wiki/SetElementAlpha it is work in this situation? Because I need to make the original (default) AK-47 invisible not a weapon which I created with createweapon function.
  9. Now I'm stuck in the invisible model part... can't make it with txd workshop, I already tried to change the texture to white/black image and untick the alpha in properties but isn't be invisible... anyone have an insivible model please?
  10. Ah okay, I will try it. Thanks for your help.
  11. It's okay but if I give ak to the player (I need to provide the default AK id 30) and the weapon ID 30 model ID is 355.. so if I do the "engineImportTXD" , "engineReplaceModel" I need to provide the 355 Model ID for every custom skin.. or can I give example weapon ID 30 with any usable object ID (2965) instead of 355 model ID?
  12. And how can I do it that replace the weapon only for the localplayer who using the eg.: camo ak? because if I make the original ak inivisble and replace with the custom then changes the skin for everyone not just for localplayer who using the custom ak. isn't it? (eh my english is s.cks but hope u understand what I mean)
  13. Oh, I see. Then which function can I do it? Because currently my character is boxing the air if I click mouse 1...
  14. My character still "boxing" the air I think it's because the equiped weapon is meele (0) and I need to set the equipped weapon to ID 5 which is rifle, right? https://wiki.multitheftauto.com/wiki/SetPedWeaponSlot I trying to change the weaponslot to ID 5 , but it isn't working... the getpedweaponslot returns 0 in the chatbox after I run the command. setPedWeaponSlot(localPlayer, 5) And the "rifle_crouchfire" anim still not working if the state is crouch.
  15. Yeah , but I can't do it for localplayer only in that way... because if someone uses eg.: camo ak-47 from their inventory then all other players who have ak-47 (id 30) seen camo ak I did research about custom weapons example before I posted this, but found nothing custom weapons with txd and dff.. just with shaders (with png files) which are ugly.
  16. What yes? I said I doesn't have opened line but the debugscript says that "Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end'" But I want to keep the original AK-47 too.
  17. Ah, I see. And why I get this error: Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end' if I doesn't have opened line and the 'addeventhandler' get closed at line 51 after end?
  18. Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end' What? I don't see opened ( and the eventhandler closed already at the line 51 end)
  19. You're forgot to close function at line 15 but I didn't get it where... Loading script failed: aktest\client,lua:29: 'end' expected (to close 'function' at line 15) near 'else' function test() x,y,z = getElementPosition(localPlayer) weapon = createWeapon("ak-47", x, y, z) setWeaponAmmo(weapon, 1) setWeaponClipAmmo(weapon, 32) setWeaponState(weapon, "ready") setElementAlpha(weapon, 0) local newAK = createObject(2965, x, y, z) attachElements(weapon, newAK) exports['bone_attach']:attachElementToBone(newAK, localPlayer, 12, 0, 0, 0, 0, -90, 0) end addCommandHandler("aktest", test) addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press then setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setWeaponState(weapon, "ready") end if button =="mouse2" and press then if button == "mouse2" and press and getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", -1, false, false, false, false) end setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) end else setPedAnimation(localPlayer, false) end if button =="mouse2" and press and button =="mouse1" and press then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_fire", - 1,false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end if button == "mouse1" and press and button =="mouse2" and press and getControlState(localPlayer, "crouch") then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", - 1, false, false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end end end) addEventHandler("onClientWeaponFire" , root, function(hitElement, hitX, hitY, hitZ) setPedAimTarget(localPlayer, hitX, hitY, hitZ) end )
  20. addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press or $ setPedAnimation(localPlayer, "rifle", "RIFLE_fire", -1, false, false, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setWeaponState(weapon, "ready") end if button =="mouse2" and press then if getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "RIFLE_crouchfire", -1, false, false, false, false) else setPedAnimation(localPlayer, "rifle", "RIFLE_fire", -1, false, false, false, false) setPedAimTarget(localPlayer, x, y, z) end end end) anyways, the getcontrolstate not working or bugging if it is crouch? because then ignore the animation but if I change to jump or walk it's working...
  21. Thanks again! You're really helped me a lot. I did the animation thing. It's possible to change the onclientkey press to hold? because the current state I can't fire and aim with the weapon constant...
  22. Thanks man! it's fire now, but what can I do with the aim? I can't aim with mouse2 ... and my character is "boxing" if I click mouse1, like my current weapon is meele.
  23. Ah, I can't figure out how to use those functions ... at current state the weapon fires only 1 if I clicks mouse1 and my character using "boxing" anim , can't aim with mouse2 and shoot normal like the default weapons (ak47,m4,etc...) function test() x,y,z = getElementPosition(localPlayer) weapon = createWeapon("ak-47", x, y, z) setWeaponAmmo(weapon, 120) setWeaponClipAmmo(weapon, 32) setWeaponState(weapon, "ready") setElementAlpha(weapon, 0) local newAK = createObject(2965, x, y, z) attachElements(weapon, newAK) exports['bone_attach']:attachElementToBone(newAK, localPlayer, 12, 0, 0, 0, 0, -90, 0) fireWeapon(weapon) end bindKey("mouse1", "down", test) addCommandHandler("aktest", test)
×
×
  • Create New...