Jump to content

Pedmaker


shaio

Recommended Posts

I made this script not to long ago, cuz I wanted to make strippers in the strip club. My original plan was just to make a function with two values. player and cmd, but then I wanted to make it more expendable. So I added more options :) Now honestly I have no idea what is wrong with this script, but it's givin the console errors like there's no tomorrow.. So, help meh out doods.

function makePed(player,cmd,id,animGroup,anim,frozen,times) 
        local x,y,z = getElementPosition(player) 
        local rx,ry,rz = getElementRotation(player) 
        local dim = getElementDimension(player) 
        local int = getElementInterior(player) 
        ped = createPed(id,x,y,z) 
        setElementDimension(ped,dim) 
        setElementInterior(ped,int) 
        if not frozen then 
            setElementFrozen(ped,true) 
        else 
            if frozen == "false" then 
                setElementFrozen(ped,false) 
            elseif frozen == "true" then 
                setElementFrozen(ped,true) 
            end 
        end 
        setElementRotation(ped,rx,ry,rz) 
        setTimer(function() 
            setPedAnimation(ped,animGroup,anim) 
        end,times,0) 
        for _,s in ipairs(getElementsByType("player")) do 
            outputChatBox(getPlayerName(player).." has created a ped at X:"..x.." Y:"..y.." Z:"..z,s,0,255,255) 
            outputChatBox("Ped Info: ID: "..id.." Animation: "..animGroup.."/"..anim,s,0,255,255) 
        end 
end 
addCommandHandler("ped",makePed) 
  
function clearPed(player,cmd) 
    for _,v in ipairs(getElementsByType("player")) do 
        outputChatBox(getPlayerName(player).." has cleared all peds!",v,0,255,255) 
    end 
    for _,ped in ipairs(getElementsByType("ped")) do 
        destroyElement(ped) 
    end 
end 
addCommandHandler("clearpeds",clearPed) 

Link to comment

Also when you are using arguments I would suggest you to add some condition to detect if player filled all necessary arguments and if not, output some syntax. Also check if arguments which need to be numbers are actually numbers and convert them using tonumber function, like Donut. mentioned before. You'll also prevent errors when you don't fill arguments properly.

Link to comment

so like this?

function makePed(player,cmd,id,animGroup,anim,frozen,times) 
        local x,y,z = getElementPosition(player) 
        local rx,ry,rz = getElementRotation(player) 
        local dim = getElementDimension(player) 
        local int = getElementInterior(player) 
        if not id then 
            outputChatBox("Syntax: /ped (id) (animationGroup) (animation) (frozen=true/false) (time)",player,0,255,255) 
        else 
            ped = createPed(tonumber(id),x,y,z) 
            setElementDimension(ped,dim) 
            setElementInterior(ped,int) 
        end 
        if not frozen then 
            setElementFrozen(ped,true) 
        else 
            if frozen == "false" then 
                setElementFrozen(ped,false) 
            elseif frozen == "true" then 
                setElementFrozen(ped,true) 
            end 
        end 
        setElementRotation(ped,rx,ry,rz) 
        if animGroup then 
            if anim then 
                if times then 
                setTimer(function() 
                    setPedAnimation(ped,animGroup,anim) 
                end,times,0) 
            end 
        end 
        for _,s in ipairs(getElementsByType("player")) do 
            outputChatBox(getPlayerName(player).." has created a ped at X:"..x.." Y:"..y.." Z:"..z,s,0,255,255) 
            outputChatBox("Ped Info: ID: "..id.." Animation: "..animGroup.."/"..anim,s,0,255,255) 
        end 
end 
addCommandHandler("ped",makePed) 
  
function clearPed(player,cmd) 
    for _,v in ipairs(getElementsByType("player")) do 
        outputChatBox(getPlayerName(player).." has cleared all peds!",v,0,255,255) 
    end 
    for _,ped in ipairs(getElementsByType("ped")) do 
        destroyElement(ped) 
    end 
end 
addCommandHandler("clearpeds",clearPed) 

Link to comment

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