Jump to content

Peds problem


AjaxFTW

Recommended Posts

Posted

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?!

Posted

My problem not the weaponStat

my problem is making the ped Carry weapon i just want it carry weapon that's all

if any one can help please.

Posted

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) 

Posted

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) 

Posted

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

Posted

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.

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

Posted

Not sure why it does that.

But you can use onClientElementStreamIn clientsided where you can give the weapon with givePedWeapon and set the controlstate.

Post the code.

Posted

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.

Posted

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)  

Posted

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) 

Posted

... -.-

Just use the code from Karim.

If you want everyone to see the animation, delete the first player in triggerClientEvent.

Posted

Try my code first and tell me the result

i already removed it and tried many codes, can you come to my server and see?!

if possible.

btw I can't test it with you I am about to go offline

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

Posted
... -.-

Just use the code from Karim.

If you want everyone to see the animation, delete the first player in triggerClientEvent.

Do what Bonus told you to do

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