AjaxFTW Posted February 3, 2016 Share Posted February 3, 2016 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
Bonus Posted February 3, 2016 Share Posted February 3, 2016 Use setPedControlState instead https://wiki.multitheftauto.com/wiki/SetPedControlState Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 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. Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 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
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 yea Working!! thank you too much brother Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 BUt it's client side there's any way to be used as server side and make all players see it? Link to comment
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 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
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 @Kariim as server side or client side?! and will be visible for all? Link to comment
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 @Kariim as server side or client side?!and will be visible for all? server sided yes Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 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 Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 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
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 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
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 @Bouns I used Trigger but whole script didn't work it was 100% Bugged. Link to comment
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 @Bouns I used Trigger but whole script didn't work it was 100% Bugged. Post it Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 i already removed it and tried many codes, can you come to my server and see?! if possible. Link to comment
Bonus Posted February 3, 2016 Share Posted February 3, 2016 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. Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 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
Bonus Posted February 3, 2016 Share Posted February 3, 2016 Show your new serversided code. Link to comment
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 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
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 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
Bonus Posted February 3, 2016 Share Posted February 3, 2016 ... -.- Just use the code from Karim. If you want everyone to see the animation, delete the first player in triggerClientEvent. Link to comment
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 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 Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 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
KariiiM Posted February 3, 2016 Share Posted February 3, 2016 ... -.-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 Link to comment
AjaxFTW Posted February 3, 2016 Author Share Posted February 3, 2016 when i did, the players told me that they see ped just moving, can't see ped have any weapon. 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