Jump to content

Need one code (PEDS DEL)


Try

Recommended Posts

Posted

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
Posted

Hi Try,

Try ( :lol: ) 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

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

Posted

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.

Posted

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 ) 

Posted

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) 

Posted
ok but i don't need auto weapon i need this

Exemple:

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

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

Posted

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
Posted

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 ) 
  

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

Posted (edited)

Thanks now Work

and now the final i need one code like this

/peskin

for change all peds skin

Edited by Guest
  • Moderators
Posted

Yeah my bad sorry because I'm french so ammos = munitions in french and I began with munitions and I forgot it :roll:

Posted
Thanks now Work

and 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 

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