βurak Posted February 7, 2019 Share Posted February 7, 2019 (edited) hello I have a problem i create ped /boomer command following player but rejoin server ped wont move server function spawnBoomer(thePlayer) playerX, playerY, playerZ = getElementPosition(thePlayer) boomer = createPed(114, playerX + 5, playerY, playerZ) local bX, bY, bZ = getElementPosition(boomer) myBlip = createBlipAttachedTo(boomer, 23) exports.extra_health:setElementExtraHealth(boomer, 2000) function OnPedWasted () if ( isPedDead ( boomer) ) then x, y, z = getElementPosition(boomer) createExplosion(x, y, z, 11) destroyElement(boomer) destroyElement(myBlip) triggerClientEvent ( thePlayer, "pedWasted", thePlayer, x, y, z ) end end addEventHandler("onPedWasted", boomer, OnPedWasted ) function BoomerDirectionUpdate() local pX,pY,pZ = getElementPosition(thePlayer) local bX,bY,bZ = getElementPosition(boomer) if(not isPedDead(boomer)) then triggerClientEvent(thePlayer, "BoomerDirection", thePlayer, boomer, pX ,pY ,pZ ,bX ,bY ,bZ) end end setTimer(BoomerDirectionUpdate,50,0) function BoomerStartFollow() local pX,pY,pZ = getElementPosition(thePlayer) local bX,bY,bZ = getElementPosition(boomer) if(not isPedDead(boomer)) then triggerClientEvent(thePlayer, "BoomerStartRun", thePlayer, boomer, pX ,pY ,pZ ,bX ,bY ,bZ) end end setTimer(BoomerStartFollow,50,0) end addCommandHandler("boomer", spawnBoomer) function skinBoomer() txd = engineLoadTXD ("boomer.txd") engineImportTXD ( txd, 114 ) dff = engineLoadDFF ("boomer.dff") engineReplaceModel (dff, 114) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),skinBoomer) function boomerDeathExplode( x, y, z ) fxAddDebris(x, y, z, 255, 0, 0, 255, 0.1, 200) end addEvent( "pedWasted", true ) addEventHandler( "pedWasted", localPlayer, boomerDeathExplode) function BoomerDirectionHandler(boomer) local pX,pY,pZ = getElementPosition(localPlayer) local bX,bY,bZ = getElementPosition(boomer) local distance = getDistanceBetweenPoints3D(pX, pY, pZ, bX, bY, bZ) if(distance < 30) then intPedRot = -math.deg (math.atan2(pX - bX, pY - bY)) if intPedRot < 0 then intPedRot = intPedRot + 360 end; setElementRotation (boomer, 0, 0, intPedRot, 'default', true) end end addEvent("BoomerDirection", true) addEventHandler("BoomerDirection", localPlayer, BoomerDirectionHandler) function BoomerRunPunch(boomer) local pX,pY,pZ = getElementPosition(localPlayer) local bX,bY,bZ = getElementPosition(boomer) local distance = getDistanceBetweenPoints3D(pX, pY, pZ, bX, bY, bZ) if(distance < 50) then setPedControlState(boomer, "forwards", true) else setPedControlState(boomer, "forwards", false) end end addEvent("BoomerStartRun", true) addEventHandler("BoomerStartRun", localPlayer, BoomerRunPunch) client Edited February 7, 2019 by Burak5312 Link to comment
Z4Zy Posted February 7, 2019 Share Posted February 7, 2019 Hello @Burak5312 ! First, I thing it should better if you add following ped into a table giving unique variable as that ped created on server side. if boomer = your following ped, then if I command to spawn a follower, then 'boomer' refers to my follower. Not yours from then. so, it may get confused to the follower !! So, I suggest you to create a table and get the nick name / account name of the command user and store it in a table. Then under that account name variable, create the follower. [ These are told according to my opinion. ] 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