Try Posted February 26, 2011 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
Moderators Citizen Posted February 26, 2011 Moderators 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
proracer Posted February 26, 2011 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)
12p Posted February 26, 2011 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.
proracer Posted February 26, 2011 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.
Try Posted February 26, 2011 Author Posted February 26, 2011 ok but i don't need auto weapon i need this Exemple: /pedwepon
proracer Posted February 26, 2011 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 )
12p Posted February 27, 2011 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)
Castillo Posted February 27, 2011 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.
Moderators Citizen Posted February 27, 2011 Moderators Posted February 27, 2011 @Solidsnake That's why I stopped to reply
Try Posted February 27, 2011 Author Posted February 27, 2011 srry but the give weapon peds don't working always say Wrong Syntax
Moderators Citizen Posted February 27, 2011 Moderators 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
Try Posted February 27, 2011 Author 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?
Moderators Citizen Posted February 27, 2011 Moderators 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 )
Try Posted February 27, 2011 Author Posted February 27, 2011 Citizen thanks but its saing /wpeds [weaponID] [ammos]
Castillo Posted February 27, 2011 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 )
Try Posted February 27, 2011 Author 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
Moderators Citizen Posted February 27, 2011 Moderators 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
Castillo Posted February 27, 2011 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
12p Posted February 27, 2011 Posted February 27, 2011 (edited) EDIT: I said nothing. My fail ^^ Edited February 27, 2011 by Guest
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