Jump to content

Problem with Gates


BabY

Recommended Posts

Hey all, Long time no posing... but Now I Need some help ::)

So.. I Making a gate to Open for any one in the team "Special Force" .. It's working well, but here comes the Problem,

The gates are shown ONLY for the localPlayer who entered the marker...

I tried to add an event of the gate being opened, then trigger it in a sever-side script, but still fail

Client Side :

enterGates = false --global function 
function stuff () --create objects and markers 
object1 = createObject ( 988, 138.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
object2 = createObject ( 988, 131.9423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
Marker1 = createMarker ( 135.48503112793, 2038.0122070313, 16.815912246704, "cylinder", 8, 255, 255, 255, 50) 
Marker2 = createMarker ( 135.48503112793, 2021.5325927734, 16.815912246704, "cylinder", 8, 255, 255, 255, 50) 
  
addEventHandler("onClientMarkerHit", Marker1, function(Player)  if Player == getLocalPlayer() then  
      enterGates() --trigger the enterGates function when localPlayer enters the marker 
end end ) end 
addEventHandler("onClientResourceStart", resourceRoot, stuff) --trigger the stuff function to load markers & objects 
  
function enterGates (player) 
  if source == Marker1 then 
    local getTeam = getPlayerTeam" class="kw2">getPlayerTeam(getLocalPlayer()) 
     if ( getTeam ) then 
     local teamName = getTeamName(getTeam) 
     if (teamName) == "Special Force" 
     then 
      moveObject ( object1, 10000, 144.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
      moveObject ( object2, 10000, 126.3423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
      end 
      end 
  end 
endaddEvent("enteringGates", true) --creating the event of opening gates 
addEventHandler("enteringGates", getRootElement(), enterGates) 
  

Server-side :

function theGates ( playerSource ) 
    triggerClientEvent ( "enteringGates", getRootElement()) 
end 

Hope you help fast, I'm now not so noob in scripting.. so you can kinda trust me ;)

Link to comment

why you are making it client side? it will work server side it only moves for the cient thats why other players dont see it make your script server sided and if you must make it client side then triggerServerEvent that moves the gate that way the players can see it.

and dont double post.

Link to comment

Okay, I Changed the script file into server-sided script.. but there was another problem, I actually don't know whats the main issue for it...

function stuff () 
object1 = createObject ( 988, 138.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
object2 = createObject ( 988, 131.9423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
Marker1 = createMarker ( 135.48503112793, 2038.0122070313, 16.815912246704, "cylinder", 8, 255, 255, 255, 50) 
Marker2 = createMarker ( 135.48503112793, 2021.5325927734, 16.815912246704, "cylinder", 8, 255, 255, 255, 50) 
end 
addEventHandler("onMarkerHit", Marker1, function() 
    enterGates() 
end ) 
addEventHandler("onResourceStart", resourceRoot, stuff) 
  
function enterGates(thePlayer, matchingDimension) 
  if source == Marker1 then 
  if isElementWithinMarker (thePlayer, Marker1) then 
    local getTeam = getPlayerTeam" class="kw2">getPlayerTeam(getLocalPlayer()) 
     if ( getTeam ) then 
     local teamName = getTeamName(getTeam) 
     if (teamName) == "Special Force" 
     then 
      moveObject ( object1, 10000, 144.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
      moveObject ( object2, 10000, 126.3423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
      end 
      end 
  end 
  end 
end 

Debugscripter always tell me that the event "addEventHandler" in line 7 always have "Bad argument" ..

so Whats the problem here ?

Link to comment
addEventHandler("onMarkerHit", Marker1, function() 
    enterGates() 
end ) 
  
function enterGates(thePlayer, matchingDimension) 
  if source == Marker1 then 
  if isElementWithinMarker (thePlayer, Marker1) then 
    local getTeam = getPlayerTeam1(getLocalPlayer()) 
     if ( getTeam ) then 
     local teamName = getTeamName(getTeam) 
     if (teamName) == "Special Force" 
     then 
      moveObject ( object1, 10000, 144.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
      moveObject ( object2, 10000, 126.3423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
      end 
      end 
  end 
  end 
end 
  

enterGates function is a function you called when the player hits Marker1 so the source isnt the marker the the params are

thePlayer matchingDimension are wrong thats not the function in the onMarkerHit event thats another function you called enterGates function should be added to onMarkerHit event like this

function stuff () 
object1 = createObject ( 988, 138.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
object2 = createObject ( 988, 131.9423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
Marker1 = createMarker ( 135.48503112793, 2038.0122070313, 16.815912246704, "cylinder", 8, 255, 255, 255, 50) 
Marker2 = createMarker ( 135.48503112793, 2021.5325927734, 16.815912246704, "cylinder", 8, 255, 255, 255, 50) 
end 
addEventHandler("onResourceStart", resourceRoot, stuff) 
  
function enterGates(thePlayer, matchingDimension) 
  if source == Marker1 then 
  if isElementWithinMarker (thePlayer, Marker1) then 
    local getTeam = getPlayerTeam1(getLocalPlayer()) 
     if ( getTeam ) then 
     local teamName = getTeamName(getTeam) 
     if (teamName) == "Special Force" 
     then 
      moveObject ( object1, 10000, 144.6767578125, 2029.4296875, 18.25, 0, 0, 180 ) 
      moveObject ( object2, 10000, 126.3423828125, 2029.4296875, 18.25, 0, 0, 180 ) 
      end 
      end 
  end 
  end 
end 
addEventHandler("onMarkerHit", Marker1, enterGates) 
  

dont forget to remove the "1" at each getPlayerTeam function.

Link to comment
  • 2 weeks later...

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...