Jump to content

Peds problem


AjaxFTW

Recommended Posts

Guys, I'am used MTA client side function for creating ped with weapon and shooting but didn't work IDK why!!

function cmdArmedPed( command ) 
    local x, y, z = getElementPosition(localPlayer) -- Get your position 
    local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby 
    givePedWeapon(thePed, 31, 5000, true) -- Give him 5000 rounds of M4 
    setControlState(thePed, "fire", true) -- Make him shoot continuously 
end 
addCommandHandler("armedped", cmdArmedPed) 

Any Help?!

Link to comment

Here's the exact same problem:

https://bugs.multitheftauto.com/view.php?id=8966

Try to use setTimer to give the weapon.

function cmdArmedPed( command ) 
    local x, y, z = getElementPosition(localPlayer) -- Get your position 
    local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby 
    setTimer ( function ( ped )  
        givePedWeapon( ped, 31, 5000, true) -- Give him 5000 rounds of M4 
        setControlState( ped, "fire", true) -- Make him shoot continuously 
    end, 100, 1, thePed ) 
end 
addCommandHandler("armedped", cmdArmedPed) 

Link to comment

try that

function cmdArmedPed(player,_) 
    local x, y, z = getElementPosition(player) -- Get your position 
    local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby 
    setTimer ( function ( ped ) 
        giveWeapon( ped, 31, 5000, true) -- Give him 5000 rounds of M4 
        setControlState( ped, "fire", true) -- Make him shoot continuously 
    end, 100, 1, thePed ) 
end 
addCommandHandler("armedped", cmdArmedPed) 

Link to comment

It's working and all players see it but only when Ped create

i mean if the player not in the area and i'am used the command then he come to the area to look at ped he see ped but don't see the weapon

also if i used the command again and he is next to me he can see it with weapon, so what i need is making it working with all players just when resourceStart, and not important if it will be server or client the important is make weapon visible for all.

Link to comment
I'm pretty sure setControlState is for player only.

You have to use setPedControlState.

You can create the Ped, give him Weapon and trigger the ped to client, where you can use setPedControlState

Yes I was about to point that, it will return with error ,I just edited his first code that he was using it on.

Link to comment

also i used that as client side

addEventHandler( "onClientResourceStart", getRootElement( ),  
   function ( ) 
       local ped5 = createPed (280, 1554.4716796875, -1673.5078125, 16.1953125, 90) 
       setTimer ( function ( ped5 ) 
        givePedWeapon( ped5, 31, 5000, true) -- Give him 5000 rounds of M4 
        end, 100, 1, ped5 ) 
        end) 

but still have same the problem is being weapon not visible for the other players until they near by the ped when resource start.

Link to comment

I made the trigger for you, It should works 100%

--Server side

function cmdArmedPed(player,_) 
    local x, y, z = getElementPosition(player)  
    local thePed = createPed(0, x + 1, y, z)  
    setTimer ( function ( ped ) 
        giveWeapon( ped, 31, 5000, true)  
         -- Make him shoot continuously 
        triggerClientEvent(player,"onPedShoot",player,ped) 
    end, 100, 1, thePed ) 
end 
addCommandHandler("armedped", cmdArmedPed) 

--Client side

addEvent("onPedShoot",true) 
addEventHandler("onPedShoot",root, 
function (ped) 
setPedControlState( ped, "fire", true) 
end)  

Link to comment

that my last one used and not working too

function cmdArmedPed(player,_) 
    local x, y, z = getElementPosition(player) -- Get your position 
    local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby 
    setTimer ( function ( ped ) 
        giveWeapon( ped, 31, 5000, true) -- Give him 5000 rounds of M4 
        setControlState( ped, "fire", true) -- Make him shoot continuously 
    end, 100, 1, thePed ) 
end 
addCommandHandler("armedped", cmdArmedPed) 

Link to comment
I made the trigger for you, It should works 100%

--Server side

function cmdArmedPed(player,_) 
    local x, y, z = getElementPosition(player)  
    local thePed = createPed(0, x + 1, y, z)  
    setTimer ( function ( ped ) 
        giveWeapon( ped, 31, 5000, true)  
         -- Make him shoot continuously 
        triggerClientEvent(player,"onPedShoot",player,ped) 
    end, 100, 1, thePed ) 
end 
addCommandHandler("armedped", cmdArmedPed) 

--Client side

addEvent("onPedShoot",true) 
addEventHandler("onPedShoot",root, 
function (ped) 
setPedControlState( ped, "fire", true) 
end)  

Your Trigger working 100% but still the problem weapon and fire not visible for other players, only me who's can see because i'am near by the ped.

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