Jump to content

Buffalo

Members
  • Posts

    283
  • Joined

  • Last visited

Everything posted by Buffalo

  1. Music plays when vehicle is moving: local sound setTimer(function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then local vx,vy,vz = getElementVelocity(vehicle) if vx+vy+vz == 0 then if sound then setSoundPaused(sound,true) end else if not sound then sound = playSound("sounds/sound.mp3") else setSoundPaused(sound,false) end end elseif sound then setSoundPaused(sound,true) end end,1000,0)
  2. Try this: bindKey("H", "down",function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getElementModel (vehicle) == 425 then if getElementData(vehicle,"AttachElements") then local hitElement = getElementData(vehicle,"AttachElements") if not isElement(hitElement) then return end triggerServerEvent("detachVehicle",hitElement,vehicle) setElementData(vehicle,"AttachElements",false,false) else local x, y, z = getElementPosition(vehicle) local dist = getElementDistanceFromCentreOfMassToBaseOfModel(vehicle) local offset = 2 local hit, _, _, _, hitElement = processLineOfSight(x, y, z-dist, x, y, z-dist-offset, false, true, false, false, false) if hit and getElementType(hitElement) == "vehicle" then outputChatBox("You attach "..getVehicleName(hitElement)) triggerServerEvent("attachVehicle", hitElement, vehicle) setElementData(vehicle,"AttachElements",hitElement,false) end end end end)
  3. Im using onClientChat for input detection. Theres a list of swear words: bWords = {["cfi"]=true,["msi"]=true} And check algorithm: function replaceBW(text,r,g,b) local changed = false local concat = split ( text, ' ' ) for i,v in ipairs(concat)do local testword = string.gsub(v,'%p','') --remove commas etc. if bWords[v] or bWords[string.lower(testword)] then concat[i] = string.rep('*',string.len(testword))..string.gsub(v,'%a','') changed = true end end if changed then cancelEvent() text = table.concat(concat,' ') outputChatBox(text,r,g,b,true) end end It's fast enough Words like CFIS will not be blocked tho cause of this check method simplicity and decency.
  4. Rename your function stopSound! You must use other names than MTA function names like my_stopSound
  5. Buffalo

    error

    Copy given code into your script. sx,sy = guiGetScreenSize() x,y = (sx/1280),(sy/768) function add (player) addEventHandler( "onClientRender", root, edit ) addEventHandler ( "onClientClick", root, join ) end marker = createMarker ( -2187.50439, 708.30951, 52.89063, "cylinder", 1.5, 255, 255, 255, 255 ) createBlipAttachedTo ( marker, 56 ) addEventHandler ( "onClientMarkerHit", marker, add ) function edit () showCursor(true,true) dxDrawRectangle(x*391, y*99, x*526, y*470, tocolor(0, 0, 0, 100), false) dxDrawRectangle(x*393, y*150, x*524, y*4, tocolor(255, 255, 255, 255), false) dxDrawRectangle(x*391, y*512, x*524, y*4, tocolor(255, 255, 255, 255), false) dxDrawText("Counter Strike", x*532, y*106, x*755, y*150, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Join", x*450, y*522, x*564, y*552, color, 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Close", x*756, y*522, x*870, y*552, color2, 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Counter Strike is an event that was meant\n as a mini game. \n In this event you will be in a team of two\n teams and there will be players with you in\n the same team and others in the other team.\n You and your team mates must eliminate all\n the other team players to win.\n All the winner team members will be given\n rewards.", 402, 163, 907, 506, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) if ( isMouseInPosition ( 450, 522, 564, 552 ) ) then color = 255,255,0,255 else color = 255,255,255,255 end if ( isMouseInPosition ( 450, 522, 870, 552 ) ) then color2 = 255,255,0,255 else color2 = 255,255,255,255 end end function join (button,state) if ( isMouseInPosition ( 450, 522, 870, 552 ) ) then if ( button == "left" and state == "up" ) then showCursor(false) removeEventHandler("onClientRender", player, edit) end end end function isMouseInPosition(a, b, c, d) if not isCursorShowing() then return end local x, y = getCursorPosition() x, y = x*sx, y*sy if x >= a and y >= b and x <= a+c and y <= b+d then return true end return false end
  6. Example resource of that https://community.multitheftauto.com/index.php?p= ... ls&id=4969
  7. Ipairs goes thru table containing number indexes in the row. Any other would be skipped. If your table is indexed number by number you should use ipairs. But if table contains number indexes 1,2,3,4,6 ipairs will stop at 4, then you must use pairs which is lil bit slower.
  8. You could try replace all textures which contains "*road*" using shaders. Not sure if it's smooth way.
  9. It's not about downloading, but using engine functions to load them. You need kinda wait some time for replace procedure to finish.
  10. This would make things worse. Loading may happen when you just roam your way around the city. Maybe mods should be loaded one by one with a timer, but needs testing.
  11. Ban Ungenerated Scripts CBB
  12. You should use specific video tags in the link (embed and autoplay): https://www.youtube.com/embed/IhchfhxvPKI?autoplay=1'
  13. For a free-fire zone local SafeA = createColRectangle ( 1607.28125, 1829.31506, 64, 64) function addRestriction(element) if getElementType(element) ~= 'player' then return end togglePlayerRestrictionless(element,false) setPedWeaponSlot(element,0) end addEventHandler("onColShapeHit", SafeA , addRestriction) function remRestriction(element) if getElementType(element) ~= 'player' then return end togglePlayerRestrictionless(element,true) end addEventHandler("onColShapeLeave", SafeA , remRestriction) function togglePlayerRestrictionless(player,toggle) toggleControl(player,'fire',toggle) toggleControl(player,'aim_weapon',toggle) toggleControl(player,'next_weapon',toggle) toggleControl(player,'previous_weapon',toggle) toggleControl(player,'vehicle_fire',toggle) toggleControl(player,'vehicle_secondary_fire',toggle) end
  14. There isn't. You must store current timestamp from like getRealTime().timestamp and compare it later after he joins. That'd be time in seconds.
  15. More infos? I take it's linux server. files @ linux.multitheftauto.com If youre hosting it somewhere you must ask them to update it for you.
  16. I am mostly using colshapes to limit some areas. createColRectangle createColCircle "onClientColShapeHit" "onClientColShapeLeave" But if you want to disable something in specific interiors then I'd edit interiors resource, add limitations for certain ones.
  17. you have lost this part from my snippet: end, 1800000, 1,source) (source element must be passed to timer)
  18. Buffalo

    dxDrawImage

    dx draw functions are very resource consuming, nothing you can do to avoid fps drop, except using smaller resolution and not using it to draw too much. thats limitations of current mta version.
  19. bindKey('fire','down',function() if getPlayerWeapon(localPlayer) == camera and getControlState('aim_weapon') then --bam photo end end)
  20. Also using a timer server sided you must pass argument to timer for player element, inside a timer it will loose source element as it's out of context. Added checks to fix if player left the server earlier. 30mins is too long, consider to make it 5mins at maximum or players will leave. setTimer(function(player) if isElement(player) then setElementInterior(player, 0, 1513.6809082031, -1698.1207275391, 14.046875) outputChatBox("Your time has been served. Behave well next time.", player, 0, 255, 0) end end, 1800000, 1,source)
  21. It runs smoothly! Running mysql,sendmail and 2 MTA servers. Both servers do not have any serious calculation scripts serverside, tho it has casual file reading scripts. With both servers filled with 50 and 30 slots, CPU goes round 42%. Definetely better than standart VPS shared among other clients. Prefer having whole dedicated space! One of the servers running on Kimsufi is on my sig.
  22. What did you choose? Im wondering about taking it too. It would hold 2 MTA servers. Woudn't it KS-2 SSD http://www.kimsufi.com/en/ The only thing is CPU, which could become bottleneck. But then again, its dedicated server. EDIT: Quite good performance for ATOM
  23. The point is, it will stay returning what it returns. Well loadstring loads a function and its arguements from string provided. Thats the scheme how its done Client (callServerFunction('checkACL',....)) -> server (check some things and let's return with callClientFunction('asnwerACL',....)) -> Client
  24. If you will be unsuccessful then its easier just to map the gates.
  25. function isPlayerStaff ( p ) will always return true You can not check this way, you must callServerFunction and then callback callClientFunction with an answer.
×
×
  • Create New...