Jump to content

JR10

Retired Staff
  • Posts

    2,947
  • Joined

  • Last visited

Everything posted by JR10

  1. isPedZombie returns a boolean value, true or false, not a ped element.
  2. startX, startY, startZ are the coordinates for the starting point of the line of sight. endX, endY, endZ are the coordinates for the ending point of the line of sight. For your other problem, you're asking too much. Try something yourself and then post for help.
  3. I've already gave you the code for it, you need to learn more if you're working on a zombies game-mode. isLineOfSightClear processLineOfSight
  4. Yes you don't need that. I kinda understand what you want now, but there are several ways your idea could be made. Here's one: guards = {} gotWeapon = {} function followPed (thePlayer) local x, y, z = getElementPosition(thePlayer) guard = createPed (240, x + 2, y, z + 1) triggerClientEvent(thePlayer, 'moveGuard', guard) if (not guards[thePlayer]) then guards[thePlayer] = {} end table.insert(guards[thePlayer], guard) end addCommandHandler ("guard", followPed) function giveGun (source) if (not guards[source]) then return end if not isElement(guards[source][1]) then outputChatBox ("You have no Guard") else for i, v in pairs(guards[source]) do if (not gotWeapon[v]) then giveWeapon (v, 30, 200, true) gotWeapon[v] = true break end end end end addCommandHandler ("weapon", giveGun) function returnTable() return guards end addEvent("returnTable", true) addEventHandler("returnTable", getRootElement(), returnTable)
  5. local guards = {} function moveGuard() table.insert(guards, source) addEventHandler('onClientPedDamage', source, function(attacker) if attacker == localPlayer then cancelEvent() end end) end addEvent("moveGuard",true) addEventHandler ("moveGuard", getRootElement(), moveGuard) function followPlayer() for index, guard in pairs(guards) do if (not isElement(guard) or isPedDead(guard)) then table.remove(guards, index) else local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer) local tint, tdim = getElementInterior(guard), getElementDimension(guard) if (int ~= tint) then setElementInterior(guard, int) end if (dim ~= tdim) then setElementDimension(guard, dim) end local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(guard) local dis = getDistanceBetweenPoints2D (x, y, tx, ty) setPedRotation(guard, findRotation(tx, ty, x, y)) if (dis > 2) then setPedControlState(guard, 'forwards', true) else setPedControlState(guard, 'forwards', false) end if (dis > 4) then setPedControlState(guard, 'sprint', true) else setPedControlState(guard, 'sprint', false) end end end end addEventHandler('onClientPreRender', root, followPlayer) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end function cancelPedDamage ( attacker ) local guardsrecieved = triggerServerEvent("returnTable", attacker) if (guardsrecieved[attacker][1] == source) then cancelEvent() -- cancel any damage done to peds end end addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage )
  6. For your first problem: guards = {} function followPed (thePlayer) local x, y, z = getElementPosition(thePlayer) guard = createPed (240, x + 2, y, z + 1) triggerClientEvent(thePlayer, 'moveGuard', guard) if (not guards[thePlayer]) then guards[thePlayer] = {} end table.insert(guards[thePlayer], guard) end addCommandHandler ("guard", followPed) function giveGun (source) if (not guards[source]) then return end if not isElement(guards[source][1]) then outputChatBox ("You have no Guard") else for i, v in pairs(guards[source]) do giveWeapon (v, 30, 200, true) end end end addCommandHandler ("weapon", giveGun) function returnTable() return guards end addEvent("returnTable", true) addEventHandler("returnTable", getRootElement(), returnTable) A better approach to your second problem is this, the client that I've taken from your other topic: local guards = {} function moveGuard() table.insert(guards, source) addEventHandler('onClientPedDamage', source, function(attacker) if attacker == localPlayer then cancelEvent() end end) end addEvent("moveGuard",true) addEventHandler ("moveGuard", getRootElement(), moveGuard) function followPlayer() for index, guard in pairs(guards) do if (not isElement(guard) or isPedDead(guard)) then table.remove(guards, index) else local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer) local tint, tdim = getElementInterior(guard), getElementDimension(guard) if (int ~= tint) then setElementInterior(guard, int) end if (dim ~= tdim) then setElementDimension(guard, dim) end local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(guard) local dis = getDistanceBetweenPoints2D (x, y, tx, ty) setPedRotation(guard, findRotation(tx, ty, x, y)) if (dis > 2) then setPedControlState(guard, 'forwards', true) else setPedControlState(guard, 'forwards', false) end end end end addEventHandler('onClientPreRender', root, followPlayer) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end
  7. Really? Check your setAccountData lines, they all modify the same account data 'firstTime'. Change each to something else. setAccountData (account, "firstTime", x) setAccountData (account, "firstTime", y) setAccountData (account, "firstTime", z) Should be: setAccountData (account, "posX", x) setAccountData (account, "posY", y) setAccountData (account, "posZ", z) Now change the rest, and don't forget to update the getAccountData lines.
  8. You bind it then unbind it on each render??
  9. JR10

    XML

    You need xmlSaveFile and xmlUnloadFile at the end of the script.
  10. JR10

    XML

    xmlNodeGetValue will return 'Drakath' if: <blocked>Drakath</blocked> Use xmlNodeGetAttribute(child, 'blocked')
  11. JR10

    XML

    Post the xml file.
  12. smoothers table is not defined. Add local smoothers = {} to the top of the script.
  13. JR10

    XML

    This is a different index than what you mean.
  14. JR10

    XML

    How about xmlFindChild?
  15. Just use engineLoad* with the path after downloading and saving the files.
  16. Use element data or tables. setElementData(thePlayer, 'guard', guard)
  17. No man will help you with that. Your best option is to learn, you can take a look at the zombies resource.
  18. Try this, client: local guards = {} function moveGuard() table.insert(guards, source) end addEvent("moveGuard",true) addEventHandler ("moveGuard", getRootElement(), moveGuard) function followPlayer() for index, guard in pairs(guards) do if (not isElement(guard) or isPedDead(guard)) then table.remove(guards, index) else local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer) local tint, tdim = getElementInterior(guard), getElementDimension(guard) if (int ~= tint) then setElementInterior(guard, int) end if (dim ~= tdim) then setElementDimension(guard, dim) end local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(guard) local dis = getDistanceBetweenPoints2D (x, y, tx, ty) setPedRotation(guard, findRotation(tx, ty, x, y)) if (dis > 2) then setPedControlState(guard, 'forwards', true) else setPedControlState(guard, 'forwards', false) end end end end addEventHandler('onClientPreRender', root, followPlayer) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end
  19. You can use onPlayerLogin and accounts data for that. On login set an account data to identify whether he logged in before or not. function onLogin(old, acc) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then --new player, spawn him setAccountData(acc, 'firstTime', 'true') end end
  20. Client: local guard function moveGuard() guard = source addEventHandler('onClientPreRender', root, followPlayer) end addEvent("moveGuard",true) addEventHandler ("moveGuard", getRootElement(), moveGuard) function followPlayer() local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer) local tint, tdim = getElementInterior(guard), getElementDimension(guard) if (int ~= tint) then setElementInterior(guard, int) end if (dim ~= tdim) then setElementDimension(guard, dim) end local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(guard) local dis = getDistanceBetweenPoints2D (x, y, tx, ty) setPedRotation(guard, findRotation(tx, ty, x, y)) if (dis > 2) then setPedControlState(guard, 'forwards', true) else setPedControlState(guard, 'forwards', false) end end function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end Server is the same.
  21. Not tested. Server: function follow (thePlayer) local x, y, z = getElementPosition(thePlayer) local guard = createPed (240, x + 2, y, z + 1) triggerClientEvent(thePlayer, 'moveGuard', guard) end addCommandHandler ("guard", follow) Client: local guard function moveGuard() guard = source addEventHandler('onClientPreRender', root, followPlayer) end addEvent("moveGuard",true) addEventHandler ("moveGuard", getRootElement(), moveGuard) function followPlayer() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(guard) local dis = getDistanceBetweenPoints2D (x, y, tx, ty) setPedRotation(guard, findRotation(tx, ty, x, y)) if (dis > 2) then setPedControlState(guard, 'forwards', true) else setPedControlState(guard, 'forwards', false) end end function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end
  22. Carpet? What do you mean? If you mean after fetching them, you have the content as a parameter. Use fileCreate, fileWrite and fileClose to store the file for the client.
  23. Actually, source should be the ped since he's triggering the event with the ped as the sourceElement. As for the code, it's totally messed up. You have the findRotation server-side which should be client-side. You need to use onClientRender, findRotation and set the control state.
  24. JR10

    Deadlist

    dxDrawText dxDrawRectangle dxDrawLine
×
×
  • Create New...