Jump to content

[Help]Ped Set Animation


OutPut

Recommended Posts

spawn as many peds as u want and create command handler /action which will select all those selected peds and put any animation u want to.

to spawn ped with this code do /actio (anim name) you'll have to add your own animations into table and peds itself in ped table.

I'm not sure or it works, but should. Haven't tested. But if it doesn't just quote me i'll fix it.

-- all server code
peds = {
  {name,rot,x,y,z}, -- here add as many peds as you want in any location as you please. example: {ped1,120,-22122,2355,52}
}

pedAnim = {
  {"dead","cs_dead_guy"}, -- "command to call animation (can be any)","animation name itself (has to be 100% correct or else it won't work"
}

function pedArmy()
  for _,v in ipairs(peds) do
    local name,rot,x,y,z = unpack(v);
  	name = createPed(rot, x, y, z) -- this will make peds from table.
  end
end
addCommandHandler("spawnpeds",pedArmy) -- this will spawn all peds from table with /spawnpeds

function doAnim(source,command)
  if (command) then
  	  for _,v in ipairs(pedAnim) do
      	local animName,actualAnimName = unpack(v);
      	if (command == animName) then
            for _,p in ipairs(peds) do
          		local pName = unpack(p);
        		setPedAnimation(pName,"ped",actualAnimName)
          	end
        end
      end
  end
end
addCommandHandler("action",doAnim) -- to call any animation from table do /action (animation name which you named in pedAnim table)

 

Edited by Fist
Link to comment

i tested code, did quite some mistakes.

Here is working version

-- all server code
peds = {
  {120,-234.089,-1662.847,2.476}, -- here add as many peds as you want in any location as you please. example: {120,-22122,2355,52}
}

pedAnim = {
  {"dead","wuzi","cs_dead_guy"}, -- "command to call animation (can be any)","animation blocks name","animation name itself (has to be 100% correct or else it won't work"
}

function pedArmy()
  for _,v in ipairs(peds) do
    local rot,x,y,z = unpack(v);
  	createPed(rot, x, y, z) -- this will make peds from table.
  end
end
addCommandHandler("spawnpeds",pedArmy) -- this will spawn all peds from table with /spawnpeds

function doAnim(source,cmd,anim)
  if (anim) then
  	  for _,v in ipairs(pedAnim) do
      	local animName,animBlock,actualAnimName = unpack(v);
      	if (tostring(anim) == animName) then
            for _,p in ipairs(getElementsByType("ped")) do
        		  setPedAnimation(p,animBlock,actualAnimName)
          	end
        end
      end
  end
end
addCommandHandler("action",doAnim) -- to call any animation from table do /action (animation name which you named in pedAnim table)

 

  • Like 1
Link to comment
6 minutes ago, Fist said:

i tested code, did quite some mistakes.

Here is working version


-- all server code
peds = {
  {120,-234.089,-1662.847,2.476}, -- here add as many peds as you want in any location as you please. example: {120,-22122,2355,52}
}

pedAnim = {
  {"dead","wuzi","cs_dead_guy"}, -- "command to call animation (can be any)","animation blocks name","animation name itself (has to be 100% correct or else it won't work"
}

function pedArmy()
  for _,v in ipairs(peds) do
    local rot,x,y,z = unpack(v);
  	createPed(rot, x, y, z) -- this will make peds from table.
  end
end
addCommandHandler("spawnpeds",pedArmy) -- this will spawn all peds from table with /spawnpeds

function doAnim(source,cmd,anim)
  if (anim) then
  	  for _,v in ipairs(pedAnim) do
      	local animName,animBlock,actualAnimName = unpack(v);
      	if (tostring(anim) == animName) then
            for _,p in ipairs(getElementsByType("ped")) do
        		  setPedAnimation(p,animBlock,actualAnimName)
          	end
        end
      end
  end
end
addCommandHandler("action",doAnim) -- to call any animation from table do /action (animation name which you named in pedAnim table)

 

Thanks <3

13 minutes ago, Fist said:

i tested code, did quite some mistakes.

Here is working version


-- all server code
peds = {
  {120,-234.089,-1662.847,2.476}, -- here add as many peds as you want in any location as you please. example: {120,-22122,2355,52}
}

pedAnim = {
  {"dead","wuzi","cs_dead_guy"}, -- "command to call animation (can be any)","animation blocks name","animation name itself (has to be 100% correct or else it won't work"
}

function pedArmy()
  for _,v in ipairs(peds) do
    local rot,x,y,z = unpack(v);
  	createPed(rot, x, y, z) -- this will make peds from table.
  end
end
addCommandHandler("spawnpeds",pedArmy) -- this will spawn all peds from table with /spawnpeds

function doAnim(source,cmd,anim)
  if (anim) then
  	  for _,v in ipairs(pedAnim) do
      	local animName,animBlock,actualAnimName = unpack(v);
      	if (tostring(anim) == animName) then
            for _,p in ipairs(getElementsByType("ped")) do
        		  setPedAnimation(p,animBlock,actualAnimName)
          	end
        end
      end
  end
end
addCommandHandler("action",doAnim) -- to call any animation from table do /action (animation name which you named in pedAnim table)

 

n3jhdgve.png

gdu5srzq.png

Where did I make a mistake?

 

pedAnim = {
  {"ped","WALK_fatold"},
}
 

Edited by OutPut
Link to comment
1 hour ago, OutPut said:

Thanks <3

n3jhdgve.png

gdu5srzq.png

Where did I make a mistake?

 

pedAnim = {
  {"ped","WALK_fatold"},
}
 

you have to give a command name for ped {"COMMANDNAME TO CALL ANIMATION","ped","WALK_fatold"), then just do /action "name which u chosed"

Link to comment
2 minutes ago, Fist said:

you have to give a command name for ped {"COMMANDNAME TO CALL ANIMATION","ped","WALK_fatold"), then just do /action "name which u chosed"

-- all server code
peds = {
  {0}, -- here add as many peds as you want in any location as you please. example: {120,-22122,2355,52}
}

pedAnim = {
  {"WALK_fatold"}, -- "command to call animation (can be any)","animation blocks name","animation name itself (has to be 100% correct or else it won't work"
}

function pedArmy()
  for _,v in ipairs(peds) do
    local rot,x,y,z = unpack(v);
  	createPed(rot, 164, 2508, 16) -- this will make peds from table.
  end
end
addCommandHandler("spawnpeds",pedArmy) -- this will spawn all peds from table with /spawnpeds

function doAnim(source,cmd,anim)
  if (anim) then
  	  for _,v in ipairs(pedAnim) do
      	local animName,animBlock,actualAnimName = unpack(v);
      	if (tostring(anim) == animName) then
            for _,p in ipairs(getElementsByType("ped")) do
        		  setPedAnimation(p,animBlock,actualAnimName)
          	end
        end
      end
  end
end
addCommandHandler("action",doAnim) -- to call any animation from table do /action (animation name which you named in pedAnim table)

I did /action

Link to comment
3 minutes ago, OutPut said:

-- all server code
peds = {
  {0}, -- here add as many peds as you want in any location as you please. example: {120,-22122,2355,52}
}

pedAnim = {
  {"WALK_fatold"}, -- "command to call animation (can be any)","animation blocks name","animation name itself (has to be 100% correct or else it won't work"
}

function pedArmy()
  for _,v in ipairs(peds) do
    local rot,x,y,z = unpack(v);
  	createPed(rot, 164, 2508, 16) -- this will make peds from table.
  end
end
addCommandHandler("spawnpeds",pedArmy) -- this will spawn all peds from table with /spawnpeds

function doAnim(source,cmd,anim)
  if (anim) then
  	  for _,v in ipairs(pedAnim) do
      	local animName,animBlock,actualAnimName = unpack(v);
      	if (tostring(anim) == animName) then
            for _,p in ipairs(getElementsByType("ped")) do
        		  setPedAnimation(p,animBlock,actualAnimName)
          	end
        end
      end
  end
end
addCommandHandler("action",doAnim) -- to call any animation from table do /action (animation name which you named in pedAnim table)

I did /action

Did you even read comments on code? 

replace your pedAnim table with this

pedAnim = {
  {"fatwalk","ped","WALK_fatold"}
 }

then do /action fatwalk

  • Like 1
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...