BabY Posted June 12, 2011 Share Posted June 12, 2011 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
BabY Posted June 12, 2011 Author Share Posted June 12, 2011 Line 15 in C-side is : local getTeam = getPlayerTeam(getLocalPlayer()) Idk what is this class stuff Link to comment
JR10 Posted June 12, 2011 Share Posted June 12, 2011 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
Jaysds1 Posted June 13, 2011 Share Posted June 13, 2011 same I don't know what it the class about but I know how to make scripts. And JR10 is right. Link to comment
karlis Posted June 13, 2011 Share Posted June 13, 2011 the class stuff is just lua highlighter bug, theres no errors like that in original poster side. Link to comment
BabY Posted June 13, 2011 Author Share Posted June 13, 2011 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
JR10 Posted June 13, 2011 Share Posted June 13, 2011 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
BabY Posted June 23, 2011 Author Share Posted June 23, 2011 Ok, solved. Thanks for helping. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now