JR10 Posted November 24, 2011 Share Posted November 24, 2011 Yes, use destroyElement. Link to comment
joedajoester Posted November 24, 2011 Author Share Posted November 24, 2011 I tried it and error: bad argument @ destroyElement I copied the last line in script and changed respawn to destroyElement Link to comment
Castillo Posted November 24, 2011 Share Posted November 24, 2011 (edited) function getPlayerFromPartOfName(playerPart) local pl = getPlayerFromName(playerPart) if isElement(pl) then return pl else for i,v in ipairs (getElementsByType ("player")) do if (string.find(getPlayerName(v),playerPart)) then return v end end end end function Jail (player, command, name) if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(player)), aclGetGroup ( "Admin" ) ) then local thePlayer = getPlayerFromPartOfName(name) if not thePlayer then return end if getElementData( thePlayer, "isJailed") then outputChatBox("This player is already in jail.",player,255,0,0) return end setElementData(thePlayer, "jailSkin", getElementModel ( thePlayer )) setElementModel ( thePlayer, 22 ) setElementPosition ( thePlayer, 52, 2483, 21 ) takeAllWeapons ( getRootElement() ) setElementData ( thePlayer, "isJailed", true ) outputChatBox (name.." has been jailed", getRootElement(), 255, 0, 0, true ) else outputChatBox ("You cannot use this command!", player, 255, 0, 0, true ) end end addCommandHandler("jail",Jail) function Unjail (player, command, name) if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(player)), aclGetGroup ( "Admin" ) ) then local thePlayer = getPlayerFromPartOfName(name) if not thePlayer then return end if not getElementData( thePlayer, "isJailed") then outputChatBox("This player is not in jail.",player,255,0,0) return end setElementPosition ( thePlayer, 72, 2484, 16.3 ) setElementModel ( thePlayer, tonumber(getElementData(thePlayer,"jailSkin"))) setElementData ( thePlayer, "isJailed", false ) outputChatBox (name.." has been unjailed. Be good now, "..name, getRootElement(), 0, 255, 0, true ) else outputChatBox ("You cannot unjail yourself!", player, 255, 0, 0, true ) end end addCommandHandler("unjail",Unjail) ped1inside = createPed ( 71, 69, 2503, 17) setPedRotation (ped1inside, 180) function respawn() local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) setTimer(createPed, 60000, 1, 71, x,y,z,rz) if isElement(ped1inside) then destroyElement(ped1inside) end end addEventHandler("onPedWasted",ped1inside,respawn) Edited November 24, 2011 by Guest Link to comment
joedajoester Posted November 24, 2011 Author Share Posted November 24, 2011 bad element pointer @ getElementPosition when i shoot the ped he dissapears and doesnt spawn back Link to comment
Castillo Posted November 24, 2011 Share Posted November 24, 2011 Uh, my bad, I was destroying it before create new, copy my code again. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now