Jump to content

[HELP] Event not added Client side


KraZ

Recommended Posts

addEvent("displayTimer", true) 
addEventHandler("displayTimer", root, 
function() 
     addEventHandler("onClientRender", root, draw) 
     if isTimer(timer) then killTimer(timer) end 
     timer = setTimer(function() 
          removeEventHandler("onClientRender", root, draw) 
          triggerServerEvent("warp", localPlayer) 
     end,10000,1) 
end) 
  
function draw() 
  if isTimer(timer) then 
          local timeLeft = (getTimerDetails(timer) / 1000) 
          dxDrawText("To leave this area!",557.0,318.0,872.0,368.0,tocolor(255,0,0,255),2.0,"default","left","top",false,false,false) 
          dxDrawText(tostring(timeLeft),630.0,277.0,690.0,324.0,tocolor(255,0,0,255),3.0,"default","left","top",false,false,false) 
          dxDrawText("You have: ",546.0,224.0,725.0,271.0,tocolor(255,0,0,255),4.0,"default","left","top",false,false,false) 
     end 
end 

Link to comment

Meta:

  
  
  
--SERVER SIDE-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  
  
  
radar = createRadarArea(2418.4255371094, -1735,121.6306152344,100,0,150,0,153) 
setElementData(radar,"zombieProof",true) 
staffZone = createColRectangle (2418.4255371094, -1735,121.6306152344,100) 
  
addEventHandler("onColShapeHit", staffZone, 
function(h) 
    if not isElement(h) then return end 
    if getElementData(h,"zombie") then killPed(h) end 
end) 
  
function enterArea(thePlayer) 
     local posX, posY = getElementPosition(thePlayer) 
     local inArea = isInsideRadarArea(radar, posX, posY) 
     if (inArea) then 
          if hasObjectPermissionTo ( thePlayer, "command.slap", false ) then 
            outputChatBox("Welcome to the StaffZone", thePlayer, 0, 255, 0, true) 
          else 
            triggerClientEvent ( "displayTimer", getRootElement()) 
          end 
     end 
end 
addEventHandler("onColShapeHit", staffZone, enterArea) 
  
function warp(thePlayer) 
     local posX, posY = getElementPosition(thePlayer) 
     local inArea = isInsideRadarArea(radar, posX, posY) 
     if (inArea) then 
          if hasObjectPermissionTo ( thePlayer, "command.slap", false ) then 
            outputChatBox("Welcome to the StaffZone", thePlayer, 0, 255, 0, true) 
          else 
            outputChatBox("You are not allowed in this area, Sorry...", thePlayer, 255, 0, 0, true) 
            outputChatBox("You have been warped.", thePlayer, 255, 0, 0, true) 
            if true then setElementPosition(thePlayer, 2341.2072753906, -1658.8668212891, 13.379216194153) 
            end 
          end 
     end 
end 
addEvent("warp", true) 
addEventHandler("warp", getRootElement(), warp) 

Link to comment

Tested and working.

-- Server Side --

radar = createRadarArea(2418.4255371094, -1735,121.6306152344,100,0,150,0,153) 
setElementData(radar,"zombieProof",true) 
staffZone = createColRectangle (2418.4255371094, -1735,121.6306152344,100) 
  
addEventHandler("onColShapeHit", staffZone, 
function(h) 
    if not isElement(h) then return end 
    if getElementData(h,"zombie") then killPed(h) end 
end) 
  
function enterArea(thePlayer) 
     local posX, posY = getElementPosition(thePlayer) 
     local inArea = isInsideRadarArea(radar, posX, posY) 
     if (inArea) then 
          if hasObjectPermissionTo(thePlayer, "command.slap", false) then 
               outputChatBox("Welcome to the StaffZone", thePlayer, 0, 255, 0, true) 
          else 
               triggerClientEvent(thePlayer, "displayTimer", thePlayer) 
          end 
     end 
end 
addEventHandler("onColShapeHit", staffZone, enterArea) 
  
function warp() 
     local posX, posY = getElementPosition(source) 
     local inArea = isInsideRadarArea(radar, posX, posY) 
     if (inArea) then 
          if hasObjectPermissionTo(source, "command.slap", false) then 
               outputChatBox("Welcome to the StaffZone", source, 0, 255, 0, true) 
          else 
               outputChatBox("You are not allowed in this area, Sorry...", source, 255, 0, 0, true) 
               outputChatBox("You have been warped.", source, 255, 0, 0, true) 
               setElementPosition(source, 2341.2072753906, -1658.8668212891, 13.379216194153) 
          end 
     end 
end 
addEvent("warp", true) 
addEventHandler("warp", root, warp) 

-- Client Side --

addEvent("displayTimer", true) 
addEventHandler("displayTimer", root, 
function() 
     addEventHandler("onClientRender", root, draw) 
     if isTimer(timer) then killTimer(timer) end 
     timer = setTimer(function() 
          removeEventHandler("onClientRender", root, draw) 
          triggerServerEvent("warp", localPlayer) 
     end,10000,1) 
end) 
  
function draw() 
  if isTimer(timer) then 
          local timeLeft = math.ceil(getTimerDetails(timer) / 1000) 
          dxDrawText("To leave this area!",557.0,318.0,872.0,368.0,tocolor(255,0,0,255),2.0,"default","left","top",false,false,false) 
          dxDrawText(tostring(timeLeft),630.0,277.0,690.0,324.0,tocolor(255,0,0,255),3.0,"default","left","top",false,false,false) 
          dxDrawText("You have: ",546.0,224.0,725.0,271.0,tocolor(255,0,0,255),4.0,"default","left","top",false,false,false) 
     end 
end 

-- meta.xml --

    

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...