-
Posts
7,337 -
Joined
-
Days Won
11
Everything posted by TAPL
-
This make no sense.
-
Your turn to try.
-
That's right @Chronic, but first parameter for event the onPlayerSpawn is position X not a player. function spawnArmas() giveWeapon(source, 24, 200) -- Desert Eagle giveWeapon(source, math.random(26,27), 200) -- Sawn ou Spaz giveWeapon(source, math.random(30,31), 200) -- M4 ou AK end addEventHandler("onPlayerSpawn", getRootElement(), spawnArmas)
-
function spawnArmas() giveWeapon(source, 24, 200) - Desert Eagle giveWeapon(source, math.random(26,27), 200) - Sawn ou Spaz giveWeapon(source, math.random(30,31), 200) - M4 ou AK end addEventHandler("onPlayerSpawn", getRootElement(), spawnArmas)
-
Well, what is x1, y1, x2, y2? https://wiki.multitheftauto.com/wiki/FindRotation math.deg and math.atan2 is lua math function, findRotation is useful function you don't need to know how and why it made like this just use it. The example already showed how it used. ped = createPed(0, getElementPosition(localPlayer)) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(ped) local dis = getDistanceBetweenPoints2D(x, y, tx, ty) if dis > 2 then setPedControlState(ped, "forwards", true) else setPedControlState(ped, "forwards", false) end setPedRotation(ped, findRotation(tx, ty, x, y)) end) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end Line 13 is used to make the ped face you, so when it move forwards it will follow you.
-
https://wiki.multitheftauto.com/wiki/FindRotation This function takes two sets of XY coordinates. It returns the direction from point A to point B. This can for example be used to make peds face a given point.
-
You missing bracket for addEventHandler (after end). You can find safezone on the community.
-
Try this and see if there any difference. addCommandHandler ("guard", function(player) local x, y, z = getElementPosition(player) Guard = exports["slothbot"]:spawnBot(x+2, y+2, z, 0, 240, 0, 0, nil, 0, "following", player) setTimer(function() exports["slothbot"]:setBotAttackEnabled(Guard, false) setElementData(Guard, "seestarget", true) end, 250, 1) end) i can't help you more as the script (slothbot) is long and modifying it require known the script logic and how it work and then making your own script will be better than modifying (slothbot). The example was there: https://forum.multitheftauto.com/viewtopic.php?f=91&t=67785
-
It should stop when it became near you.
-
Try to lower the distance checker, open slothbot > sbserver.lua > go to line 666 and search for this: if (fdist < 13) and (getElementData (ped, "follow_shooting") == true) then Change the distance from 13 to 2 and save the file and restart slothbot and your script and try, i hope it will work.
-
What you want the bot to do other than following you?
-
You have wrong argument at spawnBot. function guard(thePlayer) local x,y,z = getElementPosition(thePlayer) Guard = exports ["slothbot"]:spawnBot(x,y,z, 0, 240, 0, 0, nil, 0, "following", thePlayer) setTimer(function() exports ["slothbot"]:setBotAttackEnabled(Guard, false) end, 250, 1) end addCommandHandler ("guard", guard)
-
9999999999999999?
-
No need, the timer will execute only one times and it will destroyed automatically.
-
A single timer won't hurt, you just going do instead of this: exports.slothbot:setBotAttackEnabled(Guard, false) You will do this: setTimer(function() exports.slothbot:setBotAttackEnabled(Guard, false) end, 250, 1)
-
Change the event onClientPlayerJoin to onClientResourceStart and change the attachedTo argument to resourceRoot also do the same for the server side event.
-
-3555.6606445313 This is out side of gta sa map. Melee weapons does not work outside the range -3000 | 3000.
-
Wrong arguments, check the wiki. https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup Also does the event 'onZombieGetsKilled' even exist? https://wiki.multitheftauto.com/wiki/Slothman/Zombies The correct event is: onZombieWasted.
-
https://forum.multitheftauto.com/viewtopic.php?f=160&t=54318&start=30 ينقل الى قسم البرمجة
-
addEventHandler ("onClientGUIClick", guiRoot, function() if source == GUIEditor.button[1] then if not isElement(sound) then sound = playSound("sounds/vegas.mp3") setSoundVolume(sound, 1.0) end elseif source == GUIEditor.button[2] then stopSound(sound) end end)
-
addEventHandler ("onClientGUIClick", guiRoot, function() if source == GUIEditor.button[1] then sound = playSound("sounds/vegas.mp3") setSoundVolume(sound, 1.0) elseif source == GUIEditor.button[2] then stopSound(sound) end end)
-
local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } setTimer(function() outputChatBox(theMessages[math.random(#theMessages)], root, mRed, mGreen, mBlue, true) end, 1000 * 60 * 5, 0)
-
Because when you spawn the bot there is a timer (200 ms) in the script "slothbot'" that set its attack to true, so you will have to use a time bigger than 200 ms for the function setBotAttackEnabled.
