Try Posted February 26, 2011 Share Posted February 26, 2011 Hellloo Guys I want one code for del all peds (all the peds dead or live) My code for peds is this if it help addCommandHandler ("createped", function (player) local x,y,z = getElementPosition (player) ped = createPed (165,x,y,z) end) Can you help me? Thanks Link to comment
Moderators Citizen Posted February 26, 2011 Moderators Share Posted February 26, 2011 Hi Try, Try ( ) this: function delAllPeds(thePlayer, comandName) local peds = 0 for k,i in ipairs ( getElementsByType( "ped" ) )do destroyElement( i ) peds = peds+1 end outputChatBox( peds.." were destroyed !", thePlayer ) end addCommandHandler( "delpeds", delAllPeds, false, false ) It should work Link to comment
Try Posted February 26, 2011 Author Share Posted February 26, 2011 And How can i give it one Gun Link to comment
CowTurbo Posted February 26, 2011 Share Posted February 26, 2011 giveWeapon Press on it. Link to comment
Try Posted February 26, 2011 Author Share Posted February 26, 2011 Sorry i don't understand Link to comment
proracer Posted February 26, 2011 Share Posted February 26, 2011 addCommandHandler ("createped", function (player) local x,y,z = getElementPosition (player) ped = createPed (165,x,y,z) giveWeapon(ped, 31, 100) -- it will give ped an M4 with 100 ammo end) Link to comment
12p Posted February 26, 2011 Share Posted February 26, 2011 You forgot something, proracer. addCommandHandler ("createped", function (player) local x,y,z = getElementPosition (player) ped = createPed (165,x,y,z) giveWeapon(ped, 31, 100, true) -- it will give ped an M4 with 100 ammo[b] AND WILL SET THE SLOT TO THAT WEAPON[/b] end) Otherwise it shouldn't work as well as Try wants. Link to comment
proracer Posted February 26, 2011 Share Posted February 26, 2011 Okay, I'm sorry because I never work in these kind of areas (creating peds) as I'm in Race area of scripting. Link to comment
Try Posted February 26, 2011 Author Share Posted February 26, 2011 ok but i don't need auto weapon i need this Exemple: /pedwepon Link to comment
proracer Posted February 26, 2011 Share Posted February 26, 2011 Try this: function onGivePedWeapon ( ped, weaponid, amount ) if ped and weaponid then if amount then giveWeapon ( ped, weaponid, amount ) else outputChatBox ( "Wrong syntax.", source, 255, 0, 0 ) end else outputChatBox ( "Wrong Syntax.", source, 255, 0, 0 ) end end addCommandHandler ( "givepedwp", onGivePedWeapon ) Link to comment
12p Posted February 27, 2011 Share Posted February 27, 2011 There's no need to use 2 if's, and if I'm right that won't work. This is the fixed code and with less lines and less weight function onGivePedWeapon ( pl, _, pedID, weap, ammo ) if pedID and weapon and amount then if getElementByID ( pedID ) then giveWeapon ( getElementByID ( pedID ), weap, ammo, true ) else outputChatBox ( "No ped has this ID", pl, 255, 0, 0 ) end else outputChatBox ( "Wrong Syntax!", pl, 255, 0, 0 ) end end addCommandHandler ( "givepedwp", onGivePedWeapon ) And use this new code for to create peds, otherwise the other one won't work. addCommandHandler ("createped", function ( pl, _, id) if not id then outputChatBox ( "The ped needs an ID to be spawned!", pl, 255, 0, 0 ) return end local x, y, z = getElementPosition (player) ped = createPed ( 165,x, y, z ) setElementID ( ped, id ) giveWeapon(ped, 31, 100, true) end) Link to comment
Castillo Posted February 27, 2011 Share Posted February 27, 2011 ok but i don't need auto weapon i need thisExemple: /pedwepon Excuse me? even if they helped you, why you ask it like that? you could try to make it yourself first, and if you can't then ask it nicely. Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 @Solidsnake That's why I stopped to reply Link to comment
Try Posted February 27, 2011 Author Share Posted February 27, 2011 srry but the give weapon peds don't working always say Wrong Syntax Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 You have to specify the ID of your ped, then the ID of the weapon and the munitions Exemple: /createped ped1 /givepedwp ped1 24 500 Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 You'r welcome Link to comment
Try Posted February 27, 2011 Author Share Posted February 27, 2011 butttt i remeber one think its not possible to do this? *************CHAT*********** Me! : /wpeds 31 100 ****************************** And the code give the weapon for all the peds not only for one? Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 hum if you want to give weapon for only one ped, you have to use /givepedwp thePed theWeapon theAmmos and if you want to give a weapon to all peds, try this: function giveWeaponPeds( thePlayer, commandName, weapon, ammo ) if (weapon and munitions) then for k,i in ipairs ( getElementsByType( "ped" ) )do giveWeapon ( i, weapon, ammo, true ) end else outputChatBox("/wpeds [weaponID] [ammos]", thePlayer ) end end addCommandHandler( "wpeds", giveWeaponPeds, false, false ) Link to comment
Try Posted February 27, 2011 Author Share Posted February 27, 2011 Citizen thanks but its saing /wpeds [weaponID] [ammos] Link to comment
Castillo Posted February 27, 2011 Share Posted February 27, 2011 function giveWeaponPeds( thePlayer, commandName, weapon, ammo ) if (weapon and ammo) then for k,i in ipairs ( getElementsByType( "ped" ) )do giveWeapon ( i, weapon, ammo, true ) end else outputChatBox("/wpeds [weaponID] [ammos]", thePlayer ) end end addCommandHandler( "wpeds", giveWeaponPeds, false, false ) Link to comment
Try Posted February 27, 2011 Author Share Posted February 27, 2011 (edited) Thanks now Work and now the final i need one code like this /peskin for change all peds skin Edited February 27, 2011 by Guest Link to comment
Moderators Citizen Posted February 27, 2011 Moderators Share Posted February 27, 2011 Yeah my bad sorry because I'm french so ammos = munitions in french and I began with munitions and I forgot it Link to comment
Castillo Posted February 27, 2011 Share Posted February 27, 2011 Thanks now Workand now the final i need one code like this /peskin for change all peds skin Please, i ask to everyone to stop giving him the code, you must do this yourself. use setElementModel Link to comment
12p Posted February 27, 2011 Share Posted February 27, 2011 (edited) EDIT: I said nothing. My fail ^^ Edited February 27, 2011 by Guest 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