Jump to content

pearlyhell

Members
  • Posts

    7
  • Joined

  • Last visited

Details

  • Gang
    Groove

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

pearlyhell's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. thank you all for help. i added setElementData to the functions 'elementHitSafeZone' and 'elementLeaveSafeZone' , shown in first code then, with the hint of NssoR, i created a clientside file, which is shown in second code now it functions perfectly. thanks for all replies if anyone interested in full code im putting serverside file too (third code) setElementData ( theElement, "inSafezone", true ) function donthurtme ( attacker, weapon, bodypart ) if ( getElementData ( getLocalPlayer(), "inSafezone" ) == true ) then cancelEvent() end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), donthurtme ) local safeZonesTable = { { x = 1578.2421875, y = 1801.248046875, z = 10.8203125, width = 58, depth = 61, height = 100 }, { x = 1996.958984375, y = -1450.9560546875, z = 13.5546875, width = 100, depth = 55, height = 100 }, { x = -2740.775390625, y = 577.9326171875, z = 14.5546875, width = 150, depth = 100, height = 100 } -- you can add the coords for new safe zones, theese three are the main hospitals. } local controls = { "fire", "next_weapon", "previous_weapon", "aim_weapon", "sprint" } -- you can edit the controls you want to disable addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, zone in ipairs ( safeZonesTable ) do local safeZone = createColCuboid ( zone.x, zone.y, zone.z - 30, zone.width, zone.depth, zone.height ) createRadarArea ( zone.x, zone.y, zone.width, zone.depth, 0, 200, 0, 50 ) addEventHandler ( "onColShapeHit", safeZone, elementHitSafeZone ) addEventHandler ( "onColShapeLeave", safeZone, elementLeaveSafeZone ) end end ) function elementHitSafeZone ( theElement, mDim ) if isElement ( theElement ) then if ( getElementType ( theElement ) == "player" ) then for _, control in ipairs ( controls ) do toggleControl ( theElement, control, false ) setPlayerWeaponSlot ( theElement, 0 ) end exports.GTWtopbar:dm ( "You entered the safezone.", theElement, 200, 50, 50 ) -- simply change 'exports.GTWtopbar:dm' to 'outputChatBox' for using it on chatbox setElementData ( theElement, "inSafezone", true ) elseif ( getElementType ( theElement ) == "vehicle" ) then local thePlayer = getVehicleController ( theElement ) for _, control in ipairs ( controls ) do toggleControl ( thePlayer, control, false ) setPlayerWeaponSlot ( thePlayer, 0 ) end if ( thePlayer ) then exports.GTWtopbar:dm ( "You can't drive vehicles inside the safezone", thePlayer, 200, 50, 50 ) end exports.GTWvehicleshop:saveAndRemoveVehicle ( theElement, true ) -- edit or simply change it with the function destroyElement(theElement) for using it on a freeroam server etc setElementData ( theElement, "inSafezone", true ) end end end function elementLeaveSafeZone ( theElement, mDim ) if ( isElement ( theElement ) and getElementType ( theElement ) == "player" ) then for _, control in ipairs ( controls ) do toggleControl ( theElement, control, true ) end exports.GTWtopbar:dm ( "You left the safe zone.", theElement, 200, 50, 50 ) setElementData ( theElement, "inSafezone", nil ) end end have a good day.
  2. thanks, works fine. but as i said before, how can i make people inside zone invincible ? player stands outside and shoots the one who is inside.
  3. thanks for all your help, everything works fine, just you forgot toggleControl's firs argument should be theElement added and it worked well, thanks. one more question, how can i make people inside zone invincible ?
  4. thanks for all your help, i will be appreciated. waiting.
  5. thanks for reply, im new at scripting and didnt know onPlayerDamage and onPedWasted, i will replace them. but i dont think my problem is related with theese functions. when i enter my safezone, it sets my weapon to fist, so there seems no problem with entering. but after a few seconds it says 'you left the safezone' , which is the real problem. it toggles my controls back to true and acts like i left the zone, but im still in the zone.
  6. first of all its my firs topic in forums. I'm having problem with my safezone script which i wrote all of it (nearly, took hints from wiki) the problem is, when i enter the zone, it says 'you entered safezone' , but after a few seconds, 'you left the safezone' text appears. I couldnt solve the problem with my knowledge so im looking for help. only problem is; it says i left safezone after a few seconds, other functions working fine. clientside: safezones = { {1578.2421875, 1801.248046875, 10.8203125, 58, 61, 100}, {1996.958984375, -1450.9560546875, 13.5546875, 100, 55, 100}, {-2740.775390625, 577.9326171875, 14.5546875, 150, 100, 100}, } function createthings () for i, v in ipairs (safezones) do x, y, z, w, d, h = unpack(v) safezone = createColCuboid(x, y, z - 30, w, d, h) radar = createRadarArea(x, y, w, d, 0, 200, 0, 50) addEventHandler("onClientColShapeHit", safezone, hit) addEventHandler("onClientColShapeLeave", safezone, Leave) end end addEventHandler("onClientResourceStart", resourceRoot, createthings) function no() cancelEvent () end function disableproof() removeEventHandler ("onPlayerDamage",localPlayer,no) end function hit(element) if source == safezone then setPedWeaponSlot (element,0) if (getElementType (element) == "vehicle") then exports.GTWvehicleshop:saveAndRemoveVehicle(element,true) exports.GTWtopbar:dm("You can't drive vehicle inside safezone",200,50,50) toggleControl ("next_weapon",false) toggleControl ("previous_weapon",false) toggleControl ("fire",false) addEventHandler ("onPlayerDamage",localPlayer,no) addEventHandler("onPedWasted", localPlayer, disableproof) elseif (getElementType (element) == "player") then exports.GTWtopbar:dm("You entered the safezone, all weapons are forbidden.",200,50,50) toggleControl ("next_weapon",false) toggleControl ("previous_weapon",false) toggleControl ("fire",false) addEventHandler ("onPlayerDamage",localPlayer,no) addEventHandler("onPedWasted", localPlayer, disableproof) end end end function Leave(element) if source == safezone then exports.GTWtopbar:dm("You left the safezone.",200,50,50) toggleControl ("next_weapon",true) toggleControl ("previous_weapon",true) toggleControl ("fire",true) removeEventHandler ("onPlayerDamage",localPlayer,no) end end
  7. nice vehicle system. i changed some parts for my server (deleted fix and rotate) but its not saving upgrades still good work gj
×
×
  • Create New...