TheBulletSponge Posted October 18, 2010 Share Posted October 18, 2010 (edited) Hi all and thanks for reading Hopefuly an easy question. I am trying to make some screenshots for a little project but I need a few peds stood around.I have tried adapting the community scripts but I am having no luck. All I want is to make a command that allows me to spawn a PED with the skin of my choice in the place where my player is currently standing and facing the same direction as the player. No need for it to move or anything just need it to stand there. Only important things are that it faces the same way as I am when I use the command and the ability to choose what skin it spawns with. EDIT: So far I can make the peds spawn with my choice of skin but they always face the same direction no matter what I do? the only real change I have made to the script is taking the follow player function out of MAKEPED.LUA from the PEDS resource ::: THIS BIT addEventHandler( "onClientRender", getRootElement(), function( ) if myPeds then for k, ped in pairs( myPeds ) do if ped then local x, y, z = getElementPosition( plr ); local px, py, pz = getElementPosition( ped ); local distance = getDistanceBetweenPoints3D( x, y, z, px, py, pz ) if distance < 3.5 then setPedControlState( ped, "aim_weapon", true ); setPedControlState( ped, "fire", false ); setPedControlState( ped, "fire", true ); setPedControlState( ped, "forwards", false ); if ( isPedDucked( plr ) ~= isPedDucked( ped ) ) then setPedControlState( ped, "crouch", isPedDucked( getLocalPlayer( ) )); --setPedControlState( myPed, "crouch", true ); return end else setPedControlState( ped, "forwards", true ); if distance < 6.0 then if isPedDucked( plr ) ~= isPedDucked( ped ) then setPedControlState( ped, "crouch", false ); setPedControlState( ped, "crouch", true ); setPedControlState( ped, "walk", false ); setPedControlState( ped, "sprint", false ); return else setPedControlState( ped, "walk", true ); setPedControlState( ped, "sprint", false ); end elseif distance < 10.0 then setPedControlState( ped, "walk", false ); setPedControlState( ped, "sprint", true ); else setPedControlState( ped, "walk", false ); setPedControlState( ped, "sprint", true ); end local X, Y = 0, 0; X = math.abs( x - px ); Y = math.abs( y - py ); faceMe = math.deg( math.atan2( Y , X ) ); --faceMe = ( 360 - math.deg ( math.atan2 ( ( px - x ), ( py - y ) ) ) ) % 360 if ( x >= px ) and ( y > py ) then -- north-east faceMe = 90 - faceMe elseif ( x <= px ) and ( y > py ) then -- north-west faceMe = 270 + faceMe elseif ( x >= px ) and ( y <= py ) then -- south-east faceMe = 90 + faceMe elseif ( x < px ) and ( y <= py ) then -- south-west faceMe = 270 - faceMe end --guiSetText( label, tostring( faceMe ) ); setPedRotation( ped, faceMe ); setPedLookAt( ped, x, y, z + .5 ); end end end end end ) Thank you for any replies. This is resource I have tried adapting https://community.multitheftauto.com/index.php?p=resources&s=details&id=285 and this https://community.multitheftauto.com/index.php?p=resources&s=details&id=234 Edited October 18, 2010 by Guest Link to comment
Castillo Posted October 18, 2010 Share Posted October 18, 2010 try this, i've made it quickly may have a error with rotation. function makeAPed(thePlayer,command,skin) local x,y,z = getElementPosition(thePlayer) local x2,y2,z2 = getElementRotation(thePlayer) local myped = createPed(tostring(skin),x,y,z,x2,y2,z2) end addCommandHandler("createped",makeAPed) Link to comment
TheBulletSponge Posted October 18, 2010 Author Share Posted October 18, 2010 Thank you SolidSnake. I tried something similar myself but I get no errors with DEBUGSCRIPT 3 and I get no PED either. This is the FUNCTION? from the resource PEDS that I think makes the PED for me. addCommandHandler( "ped", function( plr, cmd, id ) if not id then return end local x, y, z = getElementPosition( plr ); local r = getElementPosition ( getElementRotation ( plr ) ); x = x + math.cos( math.rad( getPedRotation( plr ) ) ) * 2; y = y - math.sin( math.rad( getPedRotation( plr ) ) ) * 2; local ped = createPed( tonumber( id ), x, y, z, r ); if ped then if not playerPeds[ plr ] then playerPeds[ plr ] = { }; table.insert( playerPeds[ plr ], ped ); else table.insert( playerPeds[ plr ], ped ); end triggerClientEvent( plr, "pedCreated", plr, ped ); end end ) what I cant figure out is what this bit does. local x, y, z = getElementPosition( plr ); x = x + math.cos( math.rad( getPedRotation( plr ) ) ) * 2; y = y - math.sin( math.rad( getPedRotation( plr ) ) ) * 2; local ped = createPed( tonumber( id ), x, y, z ); But if I remove it the PEDS spawn underground. I thought this was the bit that sets the rotation but I guess I was wrong. I also found this but not sure if it is the problem _setPedRotation = setPedRotation function setPedRotation( ped, rot ) return _setPedRotation( ped, 360 - rot ); end EDIT ::: Gettin somewhere function makeAPed(thePlayer,command,skin) local x,y,z = getElementPosition ( getLocalPlayer ( thePlayer ) ) local x2,y2,z2 = getElementRotation ( getLocalPlayer ( thePlayer ) ) local myped = createPed(tostring(skin),x,y,z,x2,y2,z2) end addCommandHandler("createped",makeAPed) This creates a PED but I cant set skin and the rotation is always the same no matter which way player is facing when command is used Link to comment
Castillo Posted October 18, 2010 Share Posted October 18, 2010 you can set skin by /createped 113 that will make a mafia boss skin, about rotation i never used it b4 so dunno how it works with peds. Link to comment
Remi-X Posted October 18, 2010 Share Posted October 18, 2010 WHUTTEFUK? Using serverside function handlers while using the getLocalPlayer function too? Wtf, what do you want to use, a client or serverside script? Tell me what you want, and I could easily help you. Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 and what is this? getLocalPlayer() have no arguments getLocalPlayer(thePlayer) Link to comment
Castillo Posted October 18, 2010 Share Posted October 18, 2010 uhm i didn't made that getLocalPlayer( thePlayer ) lol, i made it to be used server sided. Link to comment
TheBulletSponge Posted October 18, 2010 Author Share Posted October 18, 2010 the getLocalPlayer I added as it didnt seem to work without. I just checked and the META file is setting it as client side script. Should I change it to server side script and then I dont need to use getLocalPlayer. I added it because no ped spawned and I didnt realize should be server side script. Remi-X : all I want to do is put a few Peds with different skins in a few places facing different directions to make a Screenshot with. The peds dont need to do anything but stand there. I need to be able to walk to a position and type command, Then a ped spawns with the skin I choose in the same place I am standing or very near and most important must be facing saming direction as my player when I type the command. I need to make some screenshots of A Family Photo, A Car Accident with police and ambulance crew attending , A Bank Robbery and A police Raid Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 if this is only for screenshot use my simple code i was using on own server to create brainless peds: peds = { } function cpp(src, cmd, id) local xx, yy, zz = getElementPosition(src) local rot = getPedRotation(src) count = count+1 peds[count] = createPed (tonumber(id), xx, yy, zz+3) setPedRotation(peds[count], rot) end addCommandHandler("cpp", cpp) Link to comment
TheBulletSponge Posted October 18, 2010 Author Share Posted October 18, 2010 (edited) You guys are AMAZING!!!! varez thank you very much! I had to add count = 0 to the top of the script but it works perfectly now. I am a very happy man :) EDIT :: sorry varez Edited October 18, 2010 by Guest Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 forgot about that, just copied part of script w/out thinking ;p ps. ahh, and dont write me as "Varez", dont use capitals Link to comment
CowTurbo Posted October 18, 2010 Share Posted October 18, 2010 varez, what you have that "varez" and "Varez" why you dont want capital? Link to comment
dzek (varez) Posted October 18, 2010 Share Posted October 18, 2010 idk, its just looking ugly with capitals Link to comment
50p Posted October 19, 2010 Share Posted October 19, 2010 The peds resource was made as an example to show how to make a ped, give him weapon and make them follow you. TheBulletSponge, the bit that you didn't understand is server-side and it's responsible for creating ped next to you. Client-side script is responsible for making peds look at you and follow you. The code that calculates the facing angle and sets ped to look at you is between lines 40-59 in your first post. If you don't want ped to follow you just comment the line where you see setPedControlState. Link to comment
TheBulletSponge Posted October 19, 2010 Author Share Posted October 19, 2010 Sweet.. Thanky you very much 50p. Going to try an animation next. Wish me luck lol EDIT :: OMG just looked at your signature what the hell connection have you got? Link to comment
Gtakiki Posted March 23, 2014 Share Posted March 23, 2014 Hi all! Help me pls! I want to be just stroll and Ped but not me stony! Sorry for my bad English! 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