Jump to content

Skin


joedajoester

Recommended Posts

for this, i need to getElementModel and then set the elementmodel and when unjailed to give back same clothes, so when jailed it changes skin and when unjailed changes the skin to the original the player had. Dont do it for me yet please, tell me where i am going wrong, i need to learn this :D Also 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 
   getElementModel ( thePlayer ) 
   setElementModel ( thePlayer, 4 ) 
   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 ) 
    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) 

Link to comment

You must save the skin before jail him, then load it.

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, 4 ) 
    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) 

Link to comment

First of all, that getElementModel has no localed name, and you haven't stored the skin ID anywhere.

Functions and such:

Get and save the original

local skin = getElementModel(player) 
setElementData(player, "originalskin", skin) 

Put the original

local skin = getElementData(player, "originalskin") 
setElementModel(player, skin) 

Link to comment

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...