mint3d Posted October 15, 2013 Share Posted October 15, 2013 So a lot of people have been asking for roleplay to make a Pet system where it opens a gui and you buy a dog and it spawns a dog that follows you. Is It possible? or even make it a ped that follows you and i could add skin mods Link to comment
pa3ck Posted October 15, 2013 Share Posted October 15, 2013 I've seen such thing, so yes, it is. Link to comment
mint3d Posted October 15, 2013 Author Share Posted October 15, 2013 local gMe = getLocalPlayer() addEvent("doPedJump", true) addEvent("doPedEnter", true) addEvent("doPedExitVeh", true) addEventHandler("doPedJump", getLocalPlayer(), function(p, boolean) setPedControlState(p, "jump", boolean) end) addEventHandler("doPedEnter", getLocalPlayer(), function(p, boolean) setPedControlState(p, "enter_passenger", boolean) end) addEventHandler("doPedExitVeh", getLocalPlayer(), function(p, boolean) setPedControlState(p, "enter_exit", boolean) end) local pedTarget = {} local pedTimer = {} local pedShooting = {} local function doPedAttackOtherPlayer(ped) if(isTimer(pedTimer[ped])) or (isPedInVehicle(ped)) then killTimer(pedTimer[ped]) end if(isElement(ped)) then pedTimer[ped] = setTimer(function() if(isElement(ped)) then local target = pedTarget[ped] if(target) then local x, y, z = getElementPosition(ped) local x2, y2, z2 = getElementPosition(target) if(isLineOfSightClear(x, y, z, x2, y2, z2, true, false, false, false, false, false)) then if(getElementHealth(target) > 1) then if(pedShooting[ped] ~= true) then setPedControlState(ped, "fire", true) pedShooting[ped] = true else local x1, y1, z1 = getElementPosition(ped) local x2, y2, z2 = getElementPosition(target) local rot = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi rot = rot-90 setPedRotation(ped, rot) setPedAimTarget(ped, x2, y2, z2) end else killTimer(pedTimer[ped]) pedShooting[ped] = false setPedControlState(ped, "fire", false) end else killTimer(pedTimer[ped]) pedShooting[ped] = false setPedControlState(ped, "fire", false) end end else killTimer(pedTimer[ped]) end end, 500, -1) else killTimer(pedTimer[ped]) end end addEventHandler("onClientPedDamage", getRootElement(), function(attacker) if(getElementData(source, "Dog") == true) then if(attacker) and (isElement(attacker)) then if(getElementType(attacker) == "player") or (getElementType(attacker) == "vehicle") then pedTarget[source] = attacker doPedAttackOtherPlayer(source) end end end end) addEventHandler("onClientRender", getRootElement(), function() for index, p in pairs(getElementsByType("ped", getRootElement(), true)) do if(getElementData(p, "Dog") == true) then local owner = getElementData(p, "besitzer") if(owner) then local x, y, z = getElementPosition(p) local x2, y2, z2 = getElementPosition(gMe) if(isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) then local sx, sy = getScreenFromWorldPosition(x, y, z+1) if(sx) and (sy) then end end end end end end end) local ped = {} local stat = {} local firetimer = {} local timer = {} local jx, jy, jz = {}, {}, {} local pedSayTimer = {} local function doPedSaySomething(ped) if(isTimer(pedSayTimer[ped])) then killTimer(pedSayTimer[ped]) end if(isElement(ped)) then local message = say_messages[math.random(1, #say_messages)] local x, y, z = getElementPosition(ped) local col = createColSphere(x, y, z, 10) for index, p in ipairs( getElementsWithinColShape(col, "player") ) do local x2, y2, z2 = getElementPosition ( p ) local distance = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) local rgb = 15 * distance - 125 local rgb = math.abs ( rgb - 255 ) + 125 end destroyElement(col) pedSayTimer[ped] = setTimer(doPedSaySomething, 10000+math.random(5000, 60000), 1, ped) end end local function functionscheck() for index, p in next, ped do if(isElement(p)) then local player = getPlayerFromName(getElementData(p, "besitzer")) if(player) and (ped[player]) then if(isElement(p)) and (ablauf[player] == true) then if not(stat[p]) then stat[p] = {} timer[p] = {} end local owner = player if(owner) then local x, y, z = getElementPosition(owner) local x2, y2, z2 = getElementPosition(p) if(getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) > 3) then -- SPRINT CHECK -- stat[p]["running"] = true if(getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) > 10) then if(stat[p]["jumping"] ~= true) and (stat[p]["inveh"] ~= true) then setPedAnimation(p, "ped" , "sprint_civi", -1, true, true, false) -- Sprintet end else if(stat[p]["jumping"] ~= true) and (stat[p]["inveh"] ~= true) then setPedAnimation(p, "ped" , "JOG_maleA", -1, true, true, false) -- Joggt end end -- ROTATION -- local x1, y1 = getElementPosition(p) local x2, y2 = getElementPosition(owner) local rot = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi rot = rot-90 setPedRotation(p, rot) -- CAR -- local inveh = false if(isPedInVehicle(player)) then inveh = true end if(inveh == true) and (getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 4) then if(stat[p]["inveh"] ~= true) and (stat[p]["enterveh"] ~= true) then stat[p]["enterveh"] = true setPedAnimation(p) triggerClientEvent(getRootElement(), "doPedEnter", player, p, true) setTimer(function() local occupants = getVehicleOccupants(getPedOccupiedVehicle(player)) for i = 1, getVehicleMaxPassengers(getPedOccupiedVehicle(player)), 1 do if not(occupants[i]) then warpPedIntoVehicle(p, getPedOccupiedVehicle(player), i) stat[p]["inveh"] = true break; end end stat[p]["enterveh"] = false end, 2000, 1) end else if(stat[p]["inveh"] == true) and (stat[p]["enterveh"] == false) and(isPedInVehicle(player) == false) then -- er ist nicht im auto aber ich bin es stat[p]["enterveh"] = true triggerClientEvent(getRootElement(), "doPedExitVeh", player, p, true) setTimer(function() removePedFromVehicle(p) stat[p]["enterveh"] = false stat[p]["inveh"] = false end, 1000, 1) end end -- JUMP CHECK -- if(inveh == false) then if((z-z2) > 0.-- s8) --> and (getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 4) and (stat[p]["jumping"] ~= true) then -- er ist oben stat[p]["jumping"] = true setPedAnimation(p) triggerClientEvent(getRootElement(), "doPedJump", player, p, true) if(isTimer(timer[p]["jump"])) then killTimer(timer[p]["jump"]) end timer[p]["jump"] = setTimer(function() stat[p]["jumping"] = false triggerClientEvent(getRootElement(), "doPedJump", player, p, false) end, 800, 1) end end else if (stat[p]["running"] == true)then stat[p]["running"] = false setPedAnimation(p) end end else destroyElement(p) end end end else if(isElement(p)) then destroyElement(p) end p = nil end end end setTimer(functionscheck, 200, -1) addCommandHandler("follower", function(p) if(ablauf[p] == true) then return end ablauf[p] = true local x, y, z = getElementPosition(p) ped[p] = createPed(164, x, y+1, z) setElementData(ped[p], "besitzer", getPlayerName(p)) setElementData(ped[p], "Dog", true) setTimer(giveWeapon, 1000, 1, ped[p], 27, 99999, true) setPedStat (ped[p], 72, 999) setPedStat (ped[p], 76, 999) setPedStat (ped[p], 74, 999) --addEventHandler("onClientPedDamage", ped, on_damage_check) pedSayTimer[ped[p]] = setTimer(doPedSaySomething, 5000, 1, ped[p]) addEventHandler("onPedWasted", ped[p], function() local ped = source setTimer(destroyElement, 1000, 1, ped) ablauf[p] = false end) end) I found this but i would need to change the command /follower to a GUI How would i do this? Link to comment
isa_Khamdan Posted October 15, 2013 Share Posted October 15, 2013 *bump* You can create a bot using a script that can be found on the community then you replace the model of the skin used for the bot with a dog , cat skin or anything you want. Link to comment
mint3d Posted October 15, 2013 Author Share Posted October 15, 2013 But i want it to be on a GUI so that you actually pick like Cat Dog 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