Jump to content

Ped


joedajoester

Recommended Posts

Posted

Hi, i need a ped to be invincible so no one can kill it. The freeze function sucks severely.

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)                     
setElementFrozen (ped1inside, false ) 
setPedRotation (ped1inside, 180) 

Posted

Is an exported function from Benxamix's resource, so you have to use it like this:

exports[resourceName]:setElementInvulnerable(element, boolean) 

The resourceName is the name of the resource which has the function: setElementInvulnerable.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
OMG this still doesnt work..

/run exports[invincibleped]:setElementInvulnerable(ped1inside, true)

Wrong.

/run exports["invincibleped"]:setElementInvulnerable(ped1inside, true) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Check the resource name, it must be the same, upper case, lower case.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

lol, ya, use:

  
function respawn() 
if (getElementModel(localplayer) == THEMODELID) then 
x,y,z = getElementPosition(localplayer) 
rot = getElementRotation(localplayer) 
setTimer(createPed,60000,1,THEMODELID,x,y,z,rot) 
end 
end 
addEventHandler("onClientPedWasted",getRootElement(),respawn) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

this doesnt work i get no error

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() 
if (getElementModel(localplayer) == 71) then 
x,y,z = getElementPosition(localplayer) 
rot = getElementRotation(localplayer) 
setTimer(createPed, 60000, 1, 71, 69, 2503, 17, 180) 
end 
end 
addEventHandler("onClientPedWasted",getRootElement(),respawn) 

Posted

onClientPedWasted is client side.

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) 
end 
addEventHandler("onPedWasted",ped1inside,respawn) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...