OutPut Posted February 26, 2017 Share Posted February 26, 2017 How can I do that ? 0:10 Link to comment
Reinhard Posted February 26, 2017 Share Posted February 26, 2017 (edited) function command() for i,v in ipairs(getElementsByType("ped")) do setPedAnimation( v, "", "") end end addCommandHandler("action", command) if u want all peds to do an anim u could do smth like this. *this is just an example* Edited February 26, 2017 by Reinhard Link to comment
Fist Posted February 26, 2017 Share Posted February 26, 2017 (edited) 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 February 26, 2017 by Fist Link to comment
Fist Posted February 26, 2017 Share Posted February 26, 2017 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) 1 Link to comment
OutPut Posted February 26, 2017 Author Share Posted February 26, 2017 (edited) 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) Where did I make a mistake? pedAnim = { {"ped","WALK_fatold"}, } Edited February 26, 2017 by OutPut Link to comment
Fist Posted February 26, 2017 Share Posted February 26, 2017 1 hour ago, OutPut said: Thanks <3 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
OutPut Posted February 26, 2017 Author Share Posted February 26, 2017 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
Fist Posted February 26, 2017 Share Posted February 26, 2017 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 1 Link to comment
OutPut Posted February 26, 2017 Author Share Posted February 26, 2017 9 minutes ago, Fist said: Did you even read comments on code? replace your pedAnim table with this pedAnim = { {"fatwalk","ped","WALK_fatold"} } then do /action fatwalk Thanks mate Link to comment
OutPut Posted February 26, 2017 Author Share Posted February 26, 2017 How can I do that ? 1:03 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