Jump to content

Mr.Loki

Members
  • Posts

    667
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Mr.Loki

  1. Try this: function ammoRender () local total = getPedTotalAmmo( localPlayer ) local clip = getPedAmmoInClip( localPlayer ) dxDrawText(clip..' | '..(total-clip), 1600/oX*x, 100/oY*y, _, _, _, 2/oX*x, "pricedown", "left", "top") end addEventHandler("onClientRender", root, ammoRender)
  2. Oh my bad... I forgot that triggers for everyone who is streamed in. function check(attacker, weapon) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if theVehicle and source == theVehicle then local id = getElementModel ( theVehicle ) if id == 520 and explosiveWeaponIDS[weapon] then triggerServerEvent ( "onVehicleKill", localPlayer, attacker, weapon ) end end end addEventHandler ( "onClientVehicleDamage", root, check )
  3. Try this -- client explosiveWeaponIDS = { [ 51 ] = true, [ 19 ] = true, [ 50 ] = true, } function check(attacker, weapon) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if theVehicle then local id = getElementModel ( theVehicle ) if id == 520 and explosiveWeaponIDS[weapon] then triggerServerEvent ( "onVehicleKill", localPlayer, attacker, weapon ) end end end addEventHandler ( "onClientVehicleDamage", root, check ) -- server function killPlaya(attacker,weapon) local hisVehicle = getPedOccupiedVehicle(source) killPed(source, attacker, weapon) blowVehicle(hisVehicle) end addEvent( "onVehicleKill", true ) addEventHandler( "onVehicleKill", root, killPlaya )
  4. That's because the elementData for "Heroin" is a number and you are checking if it's true or false. You should just use: if oldHeroinCount > 0 then
  5. Since you're using slothbot you would need to use the onBotFindEnemy event to set the target.
  6. You set the localPlayer as the source of the event.
  7. The OOP function are very easy to learn. instead of setElementHealth(element,#) it would just be element:setHealth(#) setElementPosition(element,pos) >> element:setPosition(pos) setVehicleColor(vehicle,color) >> vehicle:setColor(color) do you see the pattern? instead of set"Element"Position we just move the element to the front of the function and add a colon Element:setPosition(...) Since we did this we no longer need to define the element within the function because the function is now directly attacked to that element. Also most function on the wiki shows their OOP method right under the function. Another way to look at OOP is every element in the server is a table. Every element has their own set of function and variables. Some elements even have the same function like setPosition, setRotation etc... The pest thing about using OOP for me is that each element has variables Lets say you want to set the health of a player to 50 the normal way of doing it would be setElementHealth(player,50) Now in OOP you can use the setHealth method: player:setHealth(50) OR you can use variables like ".health". While some variables are read only most of them you can change. so setting the player's health to 50 would be as easy as doing this: player.health = 50 Using player.health would return the player's current health. player.position wourld return rotation etc...
  8. How are we supposed to help you if you don't give us enough information on your problem.
  9. You may need to select a target serverside then pass that target to the clients so the bot will shoot at the same target for everyone.
  10. Mr.Loki

    Help/Ayuda SQL

    You can create database files using this function making use of the databaseType argument setting it to "sqlite". dbConnect. A great site for learning sql here.
  11. Mr.Loki

    Fix a script..

    I know what you meant and i gave you my answer and it's still the same. There is no need to remove the event and command handlers. You can simply use function checks.
  12. function function_name(command) if command == "say" then --code end end addEventHandler("onPlayerCommand", root, function_name)
  13. Mr.Loki

    Fix a script..

    Then just add the commands don't put it in a timer. function name(player) if getElementDimension(player) == 0 then -- only execute if the player's dimension is 0 --code end end addCommandHandler("usemedkit", name) -- or function name(player) if getElementDimension(player) ~= 336 then -- only execute if the player's dimension is not 336 --code end end addCommandHandler("usemedkit", name)
  14. Mr.Loki

    Fix a script..

    Why do you have that inside of a timer? This is what you're doing function usethemedkit() --code end addCommandHandler("usemedkit", usethemedkit) addCommandHandler("usemedkit", usethemedkit) addCommandHandler("usemedkit", usethemedkit)........ and it will keep adding command handlers to the same functions over and over if you want to disable a function in a dimension just check the player's dimension when they use the command.
  15. onPlayerDamage is a server event so you have to use onClientPlayerDamage -- client function check( attacker, weapon ) if getElementType ( attacker ) == "vehicle" and weapon == 49 then -- check if attacker was vehicle and damage type was Rammed (49). triggerServerEvent ( "onVehicleKill", source, getVehicleController( attacker ) ) -- trigger the kill event sending the player that was hit as the source and the attacker (vehicle) controller. end end addEventHandler("onClientPlayerDamage", root, check) -- server function killPlayer(attacker) killPed(source, attacker, 49) --we use the source which is the localPlayer that was rammed -- the attacker is the vehicle's controller -- and we set the weeapon to 49 which is the damage type of being rammed end addEvent( "onVehicleKill", true ) addEventHandler( "onVehicleKill", root, killPlayer )
  16. OK so after many requests from people asking me to install discord bots to their servers I have decided to make the simplest tutorial on setting up a bot for your servers. [NOTE]: THIS IS A VPS TUTORIAL. IF YOUR SERVER ISN'T RUNNING ON A VPS THIS WILL NOT WORK FOR YOU UNLESS YOU UNDERSTAND HOW NODE.JS WORKS. Part 1: Bot creation Part 2: Files Configuration Part 3: SSH commands That should be all now go have fun annoying players in your server. Some feedback would be appreciated Good luck
  17. addEventHandler( "onClientVehicleDamage", root, function( att, dtype ) if att and att.target and att.target == localPlayer then if source.controller == localPlayer and localPlayer.vehicle.model == 520 then local chance = math.random(100) <= 90 and true or false if chance and dtype == 20 then blowVehicle( localPlayer.vehicle ) -- you might not want to use this if you want to see who killed the player end end end end ) Just an idea (Not tested)
  18. You should be fine using onClientColShapeHit. It is used for physical stuff in the server (that you can see) players, objects, vehices etc... Also it is worded as "Hit" for a reason. You don't hit your desk by putting your hand inside of it.
  19. This isn't the whole code... how can we work with this? Also.. why do you have a timer inside of a render function?
  20. local sellMarker = createMarker( -1545.0999755859, 126.80000305176, 2.5, "cylinder", 22, 255, 0, 0, 120) local myBlip = createBlip( -1545.0999755859, 126.80000305176, 3.5999999046326, 55, 1.5, 255, 0, 255, player ) function sellVehicle(player) if (getElementType(player) == "player") then if (not getPedOccupiedVehicle(player)) then outputChatBox("You need to be in a Vehicle to sell it.", player, 255, 0, 0) return end local vehicle = getPedOccupiedVehicle(player) local prices = math.random(4000, 10000) givePlayerMoney(player, prices) outputChatBox("You have sold the "..getVehicleName(vehicle).. " for "..prices.."!", player, 0, 255, 0 ) setVehicleLocked ( vehicle, true ) removePlayerFromVehicle ( player ) setTimer(function(veh) respawnVehicle(veh) setVehicleLocked(veh,false) end,5000,1,vehicle) end end end addEventHandler("onMarkerHit",sellMarker, sellVehicle, carRespawn)
  21. Create a table with with spawn points then just spawn the forms randomly with it.
  22. Mr.Loki

    setElementData

    You need to read and modify the data before overwriting it getElementData Modify the table and add new stuff Then setData
  23. Try this local size = 1 local img = point(100,-1) local rot = 0 function createIMG(dt) local x,y,z = getElementPosition( localPlayer ) local rx = math.sin(rot)*size local rz = math.cos(rot)*size dxDrawMaterialLine3D( x-rx, y, 1+z-rz, x+rx, y, 1+z+rz, img, size*2, -1, x, y+1, 1+z ) rot = rot +(.01*dt/17) end addEventHandler("onClientPreRender", root, createIMG)
×
×
  • Create New...