Jump to content

NickRosso

Members
  • Posts

    37
  • Joined

  • Last visited

NickRosso's Achievements

Rat

Rat (9/54)

0

Reputation

  1. Okay thanks, for the reply.
  2. I'm working with the pedastrions resource and i want to make two modifications. One. The citizens spawn when the script starts . But can't do cuz' they spawn where you entered the command.. Don't know Two: Want to set their health but did not found the script citizens.lua addCommandHandler("citizen", function(thePlayer, command, gender, skin) local x, y, z = getElementPosition(thePlayer) local int = getElementInterior(thePlayer) local ped if gender and skin then if gender == "male" or gender == "female" then ped = createPed(skin, x, y, z) if isElement(ped) == false then outputChatBox("Can't spawn a ped with this skin (an invalid skin)", thePlayer, 255, 0, 0) else setElementInterior(ped, int) setElementData(ped, "Gender", gender) setElementData(ped, "type", "Citizen") end else outputChatBox("Valid genders are female and male", thePlayer, 255, 0, 0) end elseif gender and not skin then if gender == "female" or gender == "male" then if gender == "male" then ped = createPed(7, x, y, z) setElementInterior(ped, int) setElementData(ped, "Gender", gender) setElementData(ped, "type", "Citizen") elseif gender == "female" then ped = createPed(226, x, y, z) setElementInterior(ped, int) setElementData(ped, "Gender", gender) setElementData(ped, "type", "Citizen") end else outputChatBox("Valid genders are female and male", thePlayer, 255, 0, 0) end else if math.random(0, 1) == 0 then ped = createPed(226, x, y, z) setElementInterior(ped, int) setElementData(ped, "Gender", "female") setElementData(ped, "type", "Citizen") else ped = createPed(7, x, y, z) setElementInterior(ped, int) setElementData(ped, "Gender", "male") setElementData(ped, "type", "Citizen") end end end ) addCommandHandler("despeds", function() for i, v in ipairs(getElementsByType("ped")) do destroyElement(v) end end ) addCommandHandler("onClientResourceStart", function(thePlayer, command) local x, y, z = getElementPosition(thePlayer) local int = getElementInterior(thePlayer) for i = 0, 200 do if math.random(0, 1) == 0 then local ped = createPed(226, x, y, z) setElementInterior(ped, int) setElementData(ped, "Gender", "female") setElementData(ped, "type", "Citizen") else local ped = createPed(7, x, y, z) setElementInterior(ped, int) setElementData(ped, "Gender", "male") setElementData(ped, "type", "Citizen") end end end ) local lastX = {} local lastY = {} local lastZ = {} local lastHealth = {} setTimer( function() for i, peds in ipairs(getElementsByType("ped")) do if getElementData(peds, "type") == "Citizen" then if getElementHealth(peds) > 0 then if getElementData(peds, "Gender") == "female" then if getElementData(peds, "Panic") == true then setPedAnimation(peds, "ped", "woman_runpanic") else setPedAnimation(peds, "ped", "woman_walksexy") end else if getElementData(peds, "Panic") == true then setPedAnimation(peds, "ped", "sprint_civi") else setPedAnimation(peds, "ped", "walk_gang1") end end end if getElementHealth(peds) > 0 and getElementData(peds, "Rotating") == false and isPedDead(peds) == false then if lastX[peds] == nil then local x, y, z = getElementPosition(peds) lastX[peds] = x lastY[peds] = y lastZ[peds] = z lastHealth[peds] = getElementHealth(peds) end local x, y, z = getElementPosition(peds) if lastHealth[peds] > getElementHealth(peds) then lastHealth[peds] = getElementHealth(peds) setElementData(peds, "Panic", true) setTimer( function() if isElement(peds) then setElementData(peds, "Panic", false) end end , 30000, 1) end local g = 0.5 if getElementData(peds, "Panic") == true then g = 0.25 end if getDistanceBetweenPoints3D(x, y, z, lastX[peds], lastY[peds], lastZ[peds]) < g then local success = false local rot = getPedRotation(peds) setElementData(peds, "Rotating", true) local module = "positive" local executed = 0 local rand = math.random(0, 1) if rand == 0 then module = "negative" end setTimer( function() if isElement(peds) == false then return end executed = executed + 1 local rot = getPedRotation(peds) if module == "positive" then setPedRotation(peds, rot + math.random(5, 10)) else setPedRotation(peds, rot - math.random(5, 10)) end if executed == 18 then setElementData(peds, "Rotating", false) end end , 50, 18) else lastX[peds] = x lastY[peds] = y lastZ[peds] = z local c = math.random(0, 1) for i, elements in ipairs(getElementsByType("player")) do local x, y, z = getElementPosition(peds) local rot = getPedRotation(peds) local mrot = rot + 90 mrot = math.rad(mrot) local jx = x + 1 * math.cos(mrot) local jy = y + 1 * math.sin(mrot) local ex, ey, ez = getElementPosition(elements) if getDistanceBetweenPoints3D(jx, jy, z, ex, ey, ez) < 1 then c = 0 setElementData(peds, "Rotating", true) local gender if getElementData(peds, "Gender") == "female" then gender = "Female" else gender = "Male" end if getElementData(peds, "Panic") ~= true then local message = math.random(0, 4) if message == 4 then outputChatBox("Ped ("..gender.."): #FFFFFFHi", getRootElement(), 0, 255, 0, true) elseif message == 3 then outputChatBox("Ped ("..gender.."): #FFFFFFHow are you?", getRootElement(), 0, 255, 0, true) elseif message == 2 then outputChatBox("Ped ("..gender.."): #FFFFFFI'm walking, lol", getRootElement(), 0, 255, 0, true) elseif message == 1 then outputChatBox("Ped ("..gender.."): #FFFFFFYou follow me!", getRootElement(), 0, 255, 0, true) elseif message == 0 then outputChatBox("Ped ("..gender.."): #FFFFFFHey, friend!", getRootElement(), 0, 255, 0, true) end end local rand = math.random(0, 1) local module = "positive" local executed = 0 if rand == 0 then module = "negative" end setTimer( function() if isElement(peds) == false then return end executed = executed + 1 local rot = getPedRotation(peds) if module == "positive" then setPedRotation(peds, rot + 10) else setPedRotation(peds, rot - 10) end if executed == 9 then setElementData(peds, "Rotating", false) end end , 50, 9) end end for i, elements in ipairs(getElementsByType("ped")) do if elements ~= peds then local x, y, z = getElementPosition(peds) local rot = getPedRotation(peds) local mrot = rot + 90 mrot = math.rad(mrot) local jx = x + 1 * math.cos(mrot) local jy = y + 1 * math.sin(mrot) local ex, ey, ez = getElementPosition(elements) if getDistanceBetweenPoints3D(jx, jy, z, ex, ey, ez) < 1 then c = 0 setElementData(peds, "Rotating", true) local rand = math.random(0, 1) local module = "positive" local executed = 0 if rand == 0 then module = "negative" end setTimer( function() if isElement(peds) == false then return end executed = executed + 1 local rot = getPedRotation(peds) if module == "positive" then setPedRotation(peds, rot + 10) else setPedRotation(peds, rot - 10) end if executed == 9 then setElementData(peds, "Rotating", false) end end , 50, 9) end end end for i, elements in ipairs(getElementsByType("vehicle")) do local x, y, z = getElementPosition(peds) local rot = getPedRotation(peds) local mrot = rot + 90 mrot = math.rad(mrot) local jx = x + 2.5 * math.cos(mrot) local jy = y + 2.5 * math.sin(mrot)
  3. local x = 1 -- it's local variable. (This variable exists only within this file.) So the global variable exists in another files if i create them here? Where else? If i create this one i can use x without setting the value in an other file? Just type x in the other file and it will know that is 1? OFF QUESTION: I can use the mulitple assigment here: x, y = 1, 2 print(x,y) But i can't use here. It's not possible? t = {a, b = 1, 4} print(t.a, t.b)
  4. I see. And the other statements are true anyway? EDIT: Two hours ago i would not have any idea what are you talking about. Now i just understand. It seems i started to learn
  5. I'm just a newcomer, and i'm watching many tutorials on lua.org but i don't understand one thing so far. if it's a local variable: local x = 1 end --this is the end of the variable local x = 2 -- so from now the x is 2? Then where is the end of the global variable? If there is no end of it, how to "destroy it" x = 1 -- how to destroy this? Thanks for any help Nick
  6. Thanks i missed this link. Will check it out now.
  7. I'll never learn this. No way. Browsing the wiki but can't figure it out. No problem i won't give up. Thanks.
  8. There we are. I started it. I want that if the resource starts everyone got a target. You have one target, and this can't be yourself. Then if everyone has a target, and a new player joins he got a target. It doesn't matter that he has the same target that somebody else, but want to limit this number. So 3 men could have the same target. And when somebody kills his target he gots the recently joined new player as a target. I'm stepping into a big task, but i belive that i can make it with help. I like to start things in the middle. So i started learning lua from here. I have this so far: Meta.xml "--" version="1.0" type="script" description="Target system"/> target.lua addEventHandler ( "onResourceStart", resourceRoot, function () for index, player in pairs(getElementsByType("player")) do while true do local randomTarget = getRandomPlayer ( ) if randomTarget ~= player then outputChatBox ("Your target is: " ..getPlayerName ( randomTarget ), player ) break end end end end ) ) Stuck at the beggining. Any tips? EDIT: So far made by Alpha
  9. It doesn't work. I have a newskin folder in resources in there are one tex foler. It's coontaining the 287.txt and 287.dff And there are two files that you've posted. And if i load it and enter doesn't change it.
  10. I'll try it tomorrow, thank you so much you helped me a lot. I'll post it in here if you don't mind (if it won't work)
  11. Thank you Solidsnake14, it seems, your are my guardian.
  12. In my head i was dreaming about that: You have a target to KILL, and you are a target too. So someone has to kill you too.
×
×
  • Create New...