Jump to content

thund3rbird23

Members
  • Posts

    129
  • Joined

  • Last visited

Everything posted by thund3rbird23

  1. I see! I will do more debugs in the future. I already seen your debugging tutorial. And what do you think about my last question? Can fix it somehow?
  2. Okay, I did it with the same code which I attach it to the hand. Now works perfect. But one more thing.... The weapon is moving lumpy (?) it almost jumps out of my hand when I rotate. Watch it in the video: https://www.youtube.com/watch?v=35gfJkEXoj4 Can I fix this? Or I can't do nothing with this?
  3. But the armaobject is in the loop?! --- debugs --- k returns false arma returns 1 {"DEFAULTAK", 30, 1254} 2 {"GOLDAK", 30, 2965} wep returns false(2x) previousWeaponID returns nil armaobject returns false currentWeaponID returns nil --- debugs --- I'm not sure you wanted these debuglines or in this way but I hope you can understand something It isn't be easier if I attach the weapon to the back like I attach to the hand?
  4. Did you mean this? I changed and still don't attach the weapon on my back it's in my hand: function removeDefaultAK(source) for k,arma in ipairs(weapons) do local wep = getElementData(source,arma[1]) local x,y,z = getElementPosition(source) if previousWeaponID == arma[2] then --wep not hand armaobject = createObject(arma[3],x,y,z) -- object created attachElementToBone(armaobject,source,3,0.19,-0.31,-0.1,0,270,-90)-- here back coords obj attached end if currentWeaponID == arma[2] then --wep hand end end if isElement(armaobject) then destroyElement(armaobject) -- destroyed object end end
  5. No, I'm just did test by myself. But this code doesn't even work locally I mean I can't see the weapons on my back.
  6. Thanks for your suggestions. I added if isElement(armaObject) then ... and get no errors, but the code does nothing or I doing something wrong. Because the weapon still attached in my hand. I'm using an inventory system and triggering a server side event called "removeDefaultAK" if the player tuck in or putting away their weapon (I don't know which is the right word in English, sorry.) So now the code looks like this: weapons = { {"DEFAULTAK",30,1254},--wep,id,object {"GOLDAK",30,2965}, } function removeDefaultAK(source) for k,arma in ipairs(weapons) do local wep = getElementData(source,arma[1]) local x,y,z = getElementPosition(source) if previousWeaponID == arma[2] then --wep not hand armaobject = createObject(arma[3],x,y,z) -- object created attachElementToBone(armaobject,source,3,0.19,-0.31,-0.1,0,270,-90)-- here back coords obj attached end if currentWeaponID == arma[2] then --wep hand if isElement(armaobject) then destroyElement(armaobject) -- destroyed object end end end end addEvent("removealapAK", true) addEventHandler("removealapAK", getRootElement(), removeDefaultAK) By the way, if I want to use your suggestion instead of the ipairs then I need to set player's currentweapon_1 elementdata to true or to the weapon name in the table ex.: AK-47 when he take out their weapon if I'm right?!
  7. Thanks, but the destroyElement don't work. Bad argument @ 'destroyElement' [Expected element at argument 1, got nil]
  8. One more thing, I changed the models to: function obtenerObjeto(arma) local defaultak = getElementData(localPlayer, "defaultak") local goldak = getElementData(localPlayer, "goldak") local m if arma == 30 and defaultak == 1 then m = 1254 elseif arma == 30 and goldak == 1 then m = 2965 end return m end and got a lot warning messages in debugscript which cause lagging. carmas.Lua:14: Bad argument @ 'createObject' [Expected number at argument 1, got nil] carmas.Lua:15 Bad argument @ 'setElementCollisionsEnabled' [Expected element at argument 1, got boolean] carmas.Lua: 19 Bad argument @ 'destroyElement' [Expected element at argument 1, got boolean] These 3 functions are: jugadores[jug][slot] = createObject(model,0,0,0) -- line 14 error setElementCollisionsEnabled(jugadores[jug][slot],false) -- line 15 error destroyElement(jugadores[jug][slot]) -- line 19 error If I'm using just arma == 30 like this: if arma == 30 then m = 1254 then I get no errors but then I can't seperate/specify objects just only one... and I create every skins to an existing object which I set invisible before... so I must specify the defaultak and the goldak. Can I get this working somehow?
  9. Sorry, I don't wanted to be rude. Ok, now I understand. Changed the model and working. Thanks!
  10. Did you read the question? I want to use that resource which is linked. But if I attach the weapon in player's hand with bone_attach resource then this resource isn't attach the weapon to back.
  11. If I'm attach the weapon with bone_attach then I can't attach the weapon to the player's back? Because I attach the weapon in player's hand with this: local playerInterior = getElementInterior(player) local playerDimension = getElementDimension(player) local x, y, z = getElementPosition(player) ak[player] = createObject(2965,0,0,0) setElementInterior(ak[player], playerInterior) setElementDimension(ak[player], playerDimension) exports['bone_attach']:attachElementToBone(ak[player], player, 12, 0, 0, 0, 0, -90, 0) And using THIS resource to attach the weapon to player's back then it's not moved to anywhere.
  12. I just needed the cameraFireing function the other parts are already done and now works perfect together with your fix. Thank you!
  13. Ok, I get "event is fired" and "source is in zone" when I firing in the marker (positions) And where I do place these in server side?: local victim = isElement(hitElement) and getElementType(hitElement) == "player" and hitElement or false if hitElement then local message = "#ffffffThe camera: #ca5454("..getElementData(hitElement,"char.MarkerZoneName")..") #ffffffdetected shots." end Or how to call/reference it for these if I want to output the message when I fire in the marker?
  14. This is return nothing. No errors in debug and no chatbox message: function cameraFireing(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) local victim = isElement(hitElement) and getElementType(hitElement) == "player" and hitElement or false if victim then if getElementData(source, "char.inMarkerZone") then outputChatBox("test") end end end addEventHandler("onClientPlayerWeaponFire", localPlayer, cameraFireing)
  15. Well, I want to detect if someone in the marker is shooting or killing someone then send a message to the police group. I have a few positions and if the player is in these positions then I set element data "char.isZoneCamera, true". I know it's possible to do that, I had a script few years ago and that works well, but I lost that script so now I want to make one like that. local positions = { {1528.837890625, -1674.6318359375, 13.3828125, 50, "Police"}, {1304.6455078125, -1700.59375, 13.546875, 50, "Cinema"}, {1548.044921875, -1789.8291015625, 13.546875, 50, "Near City Hall"}, {1477.966796875, -1759.06640625, 13.58437538147, 50, "City hall"}, {1192.4443359375, -1322.03125, 13.3984375, 50, "Hospital"} } for k,v in ipairs(positions) do local x,y,z = v[1], v[2], v[3] local marker = createMarker(x,y,z-1, "cylinder", v[4], 255,255,255,0) setElementData(marker, "marker.ZoneName", v[5]) setElementData(marker, "marker.isZoneCamera", true) end --- detect shots --- function cameraFireing(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if isElement(hitElement) then if (getElementType(hitElement) == "player" and hitElement ~= source) then if getElementData(source, "char.inMarkerZone") then triggerServerEvent("sendGroupMessage", root,"#ffffffThe camera: #ca5454("..getElementData(hitElement,"char.MarkerZoneName")..") #ffffffdetected shots.") end end end end addEventHandler("onClientPlayerWeaponFire", root, cameraFireing) --- detect kills --- function cameraKilling(killerElement, weapon, bodypart) if (getElementType(source) == "player") then if getElementData(source, "char.inMarkerZone") then triggerServerEvent("sendGroupMessage", root, "#ffffffThe camera: #ca5454(" .. getElementData(source, "char.MarkerZoneName") .. ") #ffffffdetected a kill.") end end end addEventHandler("onClientPlayerWasted", getLocalPlayer(), cameraKilling)
  16. Then get nothing in return, no errros and no triggerServerEvent because the hitElement is nil but I don't know why.
  17. Bad argument @ 'getElementType' [Expected element at argument 1, got nil] function cameraFireing(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (getElementType(hitElement) == "player" and hitElement ~= source) then if getElementData(source, "char.inMarkerZone") then triggerServerEvent("sendGroupMessage", root, "#ffffffThe camera: #ca5454(" .. getElementData(hitElement, "char.MarkerZoneName") .. ") #ffffffdetected shots.") end end end addEventHandler("onClientPlayerWeaponFire", root, cameraFireing)
  18. Okay, finally a few hours I figured out how it works. But thank you all for your time and replies. function sendGroupMessage(msg) for index, player in ipairs (getElementsByType("player")) do if exports["s_groups"]:isPlayerInGroup(player, 1) then outputChatBox("#F9BF3B[Police]#ffffff " .. msg, player, 255, 255, 255, true) end end end addEvent("sendGroupMessage", true) addEventHandler("sendGroupMessage", getRootElement(), sendGroupMessage)
  19. That's come from another Lua file. But eh, too difficult to make in this way, I think it's have an easier way to do that. Let's say I have 3 groups: 1, Police, 2: Government, 3: Maffia and if the player in the police group then I want to send him a message but for everyone who are in that group, not for only one or for only localplayer.
  20. If I triggering the server event: triggerServerEvent("sendGroupMessage", root, "Test") Then don't gets errors... but if I debug the sendGroupMessage function, then prints: "elem:player[Jeff] 1 Test nil" function sendGroupMessage(groupId, msg) for k, v in ipairs(getElementsByType("player")) do iprint(v,k,groupId,msg) if exports.s_groups:isPlayerInGroup(v, tonumber(groupId)) then outputChatBox("#F9BF3B[" .. availableGroups[groupId] .. "]#ffffff " .. msg, v, 255, 255, 255, true) end end end addEvent("sendGroupMessage", true) addEventHandler("sendGroupMessage", root, sendGroupMessage) So I don't get anything in the chatbox and the groupId returns the message which provided in the triggerServerEvent instead of the groupid and the msg is nil.
  21. I know what's localPlayer means. Just wrote that in the function for illustrate the code works with localPlayer but I need to send to all players who are in the ID 1 group. Okay, so the function isPlayerInGroup is in server side: function isPlayerInGroup(player, groupId) if isElement(player) and groupId then groupId = tonumber(groupId) if groupId and availableGroups[groupId] then local playerGroups = getElementData(player, "player.groups") or {} if playerGroups and playerGroups[groupId] then return true end end end return false end And I think I need to write another server side function (?): function sendGroupMessage(groupId, msg) for k, v in ipairs(getElementsByType("player")) do if isPlayerInGroup(v, tonumber(groupId)) then outputChatBox("#F9BF3B[" .. availableGroups[groupId] .. "]#ffffff " .. msg, v, 255, 255, 255, true) end end end addEvent("sendGroupMessage", true) addEventHandler("sendGroupMessage", root, sendGroupMessage) And after that I need to trigger server event: triggerServerEvent("sendGroupMessage", 1, "Test") Or I'm totally wrong?
  22. Because it's in another Lua file and I want to call in client side and the isPlayerInGroup is server side. As I said the function works but I want to send that message to all players who are in the ID 1 group not for only the localPlayer.
  23. I want to check if the player is in a specific group and if so then gets a message. I have an isPlayerInGroup function: function isPlayerInGroup(player, groupId) if isElement(player) and groupId then groupId = tonumber(groupId) if groupId and availableGroups[groupId] then local playerGroups = getElementData(player, "player.groups") or {} if playerGroups and playerGroups[groupId] then return true end end end return false end and how can I send to all players who are in example group id 1? this code is working with localPlayer but then just get the message who are clicked on the button. if exports.s_groups:isPlayerInGroup(localPlayer,1) then outputChatBox("Test") end
×
×
  • Create New...