Vercetti1010 Posted March 28, 2008 Share Posted March 28, 2008 hello again. sorry to ask aa question again so soon, but this is bugign the hell out of me. this script is supposed to create a collision sphere serverside and initiate rockets at clientside that lock on to an intruder in a jetpack or flying vehicle that is not a hunter or a hydra. however, all it does is give me the chatbox messages. other than that nothing happens. there are no errors either. can someone point me to the right direction? SERVERSIDE: function samOn ( thePlayer ) deathSphere = createColSphere ( 188.28005981445, 1941.6798095703, 17.673742294312, 100 ) outputChatBox ( "You have activated the Area 69 SAM sites", thePlayer, 255, 0, 0 ) end function samOff ( thePlayer ) destroyElement ( deathSphere ) outputChatBox ( "You have disabled the Area 69 SAM sites", thePlayer, 255, 0, 0 ) end addCommandHandler ( "samon", samOn ) addCommandHandler ( "samoff", samOff ) CLIENTSIDE: function onClientColShapeHit ( thePlayer, playervehicle, id ) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) id = getVehicleID ( playervehicle ) if ( playervehicle ) then if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 441 or id == 501 or id == 465 ) then createProjectile ( getLocalPlayer(), 20, 15.58650970459, 1719.0345458984, 26.134944915771, 500, playervehicle ) createProjectile ( getLocalPlayer(), 20, 237.6640625, 1696.4927978516, 26.089979171753, 500, playervehicle ) createProjectile ( getLocalPlayer(), 20, 354.64459228516, 2028.2109375, 26.094778060913, 500, playervehicle ) createProjectile ( getLocalPlayer(), 20, 188.35180664063, 2081.2719726563, 26.120576858521, 500, playervehicle ) outputChatBox ( "Warning! SAM collision iminent!", thePlayer, 255, 0, 0 ) end else if ( doesPlayerHaveJetpack ( thePlayer ) ) then createProjectile ( getLocalPlayer(), 20, 15.58650970459, 1719.0345458984, 26.134944915771, 500, thePlayer ) createProjectile ( getLocalPlayer(), 20, 237.6640625, 1696.4927978516, 26.089979171753, 500, thePlayer ) createProjectile ( getLocalPlayer(), 20, 354.64459228516, 2028.2109375, 26.094778060913, 500, thePlayer ) createProjectile ( getLocalPlayer(), 20, 188.35180664063, 2081.2719726563, 26.120576858521, 500, thePlayer ) outputChatBox ( "Warning! SAM collision iminent!", thePlayer, 255, 0, 0 ) end end end addEventHandler ( "onClientColShapeHit", thePlayer, true ) XML: <meta> <info author="MasterOfPuppets" description="Intruders go Kaboom" version="1" type="script" /> <script src="sam.lua" type="client" /> <script src="samserver.lua" type="server" /> </meta> any help is very appreciated Link to comment
50p Posted March 29, 2008 Share Posted March 29, 2008 http://development.mtasa.com/index.php? ... olShapeHit Read parameters section and compare it to yours. Also, when they enter (hit) the colshape do a check it the player is local player. Link to comment
tma Posted March 29, 2008 Share Posted March 29, 2008 Not your problem but that great big if statement can be done neatly: if table.find({592,577,...,465},id) then Link to comment
Vercetti1010 Posted March 29, 2008 Author Share Posted March 29, 2008 http://development.mtasa.com/index.php?title=OnClientColShapeHitRead parameters section and compare it to yours. Also, when they enter (hit) the colshape do a check it the player is local player. it says addEventHandler ( "onClientColShapeHit", thePlayer, true ) that matches the thing. and the thing you said after that is gibberish to me. Link to comment
eAi Posted March 29, 2008 Share Posted March 29, 2008 The second argument of addEventHandler is the point in the element tree that the handler is placed. You'll capture events that come from child or parent elements of that element. The 'source' of the onClientColShapeHit event is the colshape, not the player. As such, attaching the event to the player will mean the event is never triggered as the player is not a colshape. Either do what 50p says and add a check in the function (and change thePlayer to the root element) or change thePlayer to your colshape. Link to comment
Vercetti1010 Posted March 29, 2008 Author Share Posted March 29, 2008 still doesnt work. and aslo, still no errors. function onClientColShapeHit ( target, playervehicle, id ) target = getLocalPlayer() playervehicle = getPlayerOccupiedVehicle ( target ) id = getVehicleID ( playervehicle ) if ( target ) then if ( playervehicle ) then if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 441 or id == 501 or id == 465 ) then createProjectile ( target, 20, 15.58650970459, 1719.0345458984, 26.134944915771, 500, playervehicle ) createProjectile ( target, 20, 237.6640625, 1696.4927978516, 26.089979171753, 500, playervehicle ) createProjectile ( target, 20, 354.64459228516, 2028.2109375, 26.094778060913, 500, playervehicle ) createProjectile ( target, 20, 188.35180664063, 2081.2719726563, 26.120576858521, 500, playervehicle ) outputChatBox ( "Warning! SAM collision iminent!", target, 255, 0, 0 ) end else if ( doesPlayerHaveJetpack ( target ) ) then createProjectile ( target, 20, 15.58650970459, 1719.0345458984, 26.134944915771, 500, target ) createProjectile ( target, 20, 237.6640625, 1696.4927978516, 26.089979171753, 500, target ) createProjectile ( target, 20, 354.64459228516, 2028.2109375, 26.094778060913, 500, target ) createProjectile ( target, 20, 188.35180664063, 2081.2719726563, 26.120576858521, 500, target ) outputChatBox ( "Warning! SAM collision iminent!", target, 255, 0, 0 ) end end end end addEventHandler ( "onClientColShapeHit", deathSphere, true ) Link to comment
50p Posted March 29, 2008 Share Posted March 29, 2008 In your case deathSphere is server-sided. Why don't you create the shape in client-side script? Link to comment
eAi Posted March 29, 2008 Share Posted March 29, 2008 The documentation for onClientColShapeHit says that the parameters passed are 'element theElement, bool matchingDimension', you're using 'target, playervehicle, id' for some reason... Link to comment
50p Posted March 29, 2008 Share Posted March 29, 2008 The documentation for onClientColShapeHit says that the parameters passed are 'element theElement, bool matchingDimension', you're using 'target, playervehicle, id' for some reason... I wanted to mention it in my first post, somehow I've forgotten. Anyway, Vercetti, try the example ( http://development.mtasa.com/index.php? ... olShapeHit ) and don't forget to create sphere on client's side. Link to comment
Vercetti1010 Posted March 30, 2008 Author Share Posted March 30, 2008 i think i kinda understand more about it now. but, i want to make the sams able to turn off and on. if i make that decision clientside then it will be up to the client to set up the colShpere, and im sure they dont want to get blown up when trying to intrude on the base lol. can you call something from another script in the resource? Link to comment
50p Posted March 30, 2008 Share Posted March 30, 2008 You could create the colshape server-sided and send it to client using triggerClientEvent. It could be bandwidth consuming. Link to comment
Mr.Hankey Posted March 30, 2008 Share Posted March 30, 2008 just add the command server-side and then pass a variable to the clients to set if it's enabled or not. That wouldn't be so bandwidth cosuming =) Link to comment
Ace_Gambit Posted March 30, 2008 Share Posted March 30, 2008 Yea, that's how I set up my SAM sites. The colshape is created server-side. That way I want to keep the server-script in control. Whenever "something" is entering the colshape the server performs multiple checks before it sends a request to the client to actually fire the rockets. As soon as the client is finished it sends a request back to the server notifying other clients can create projectiles now (just to make sure there aren't 100 clients creating projectiles at the same time). Here's a vid of the working SAM sites: Link to comment
Vercetti1010 Posted March 30, 2008 Author Share Posted March 30, 2008 still nothing happens and still no errors. I dont know what the deal is. please someone give me info that i understand, not insert varialbe into the root element and setnode mumbojumbo. just please help me in english. serverside function samOn ( thePlayer ) deathSphere = createColSphere ( 188.28005981445, 1941.6798095703, 17.673742294312, 100 ) outputChatBox ( "You have activated the Area 69 SAM sites", thePlayer, 255, 0, 0 ) end function samOff ( thePlayer ) destroyElement ( deathSphere ) outputChatBox ( "You have disabled the Area 69 SAM sites", thePlayer, 255, 0, 0 ) end addCommandHandler ( "samon", samOn ) addCommandHandler ( "samoff", samOff ) clientside function onClientColShapeHit ( deathSphere, true ) target = getLocalPlayer() playervehicle = getPlayerOccupiedVehicle ( target ) id = getVehicleID ( playervehicle ) if ( target ) then if ( playervehicle ) then if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 441 or id == 501 or id == 465 ) then createProjectile ( target, 20, 15.58650970459, 1719.0345458984, 26.134944915771, 500, playervehicle ) createProjectile ( target, 20, 237.6640625, 1696.4927978516, 26.089979171753, 500, playervehicle ) createProjectile ( target, 20, 354.64459228516, 2028.2109375, 26.094778060913, 500, playervehicle ) createProjectile ( target, 20, 188.35180664063, 2081.2719726563, 26.120576858521, 500, playervehicle ) outputChatBox ( "Warning! SAM collision iminent!", target, 255, 0, 0 ) end else if ( doesPlayerHaveJetpack ( target ) ) then createProjectile ( target, 20, 15.58650970459, 1719.0345458984, 26.134944915771, 500, target ) createProjectile ( target, 20, 237.6640625, 1696.4927978516, 26.089979171753, 500, target ) createProjectile ( target, 20, 354.64459228516, 2028.2109375, 26.094778060913, 500, target ) createProjectile ( target, 20, 188.35180664063, 2081.2719726563, 26.120576858521, 500, target ) outputChatBox ( "Warning! SAM collision iminent!", target, 255, 0, 0 ) end end end end Link to comment
eAi Posted March 31, 2008 Share Posted March 31, 2008 Saying what we're saying in 'mumbojumbo' is not likely to get us to help. Which bits specifically don't you understand, don't get us to rewrite everything we've written targeted at a 5 year old. Link to comment
Vercetti1010 Posted April 2, 2008 Author Share Posted April 2, 2008 just add the command server-side and then pass a variable to the clients to set if it's enabled or not. That wouldn't be so bandwidth cosuming =) im not calling you five year olds, im just saying that those words confuse me. all i am asking is to talk in simpler words Link to comment
Vercetti1010 Posted May 1, 2008 Author Share Posted May 1, 2008 i figured it out. the clientside was ok but the serverside was messed up. i mistakenly mixed the event handler with the functions. it works now Link to comment
[DooD]Heavyair Posted May 2, 2008 Share Posted May 2, 2008 any chance u could post the working script it sounds awesome Thanx for any reply and hope im not being to cheeky Link to comment
Vercetti1010 Posted May 3, 2008 Author Share Posted May 3, 2008 here it is. edit it to your use serverside local deathSphere = createColSphere ( X, Y, Z, Radius ) --Triggers rockets local warningSphere = createColSphere ( X, Y, Z, Radius ) --Triggers warning function enableSam ( thePlayer ) setElementPosition ( deathSphere, X, Y, Z ) setElementPosition ( warningSphere, X, Y, Z ) outputChatBox ( "You have enabled the SAM sites at (put place here)", thePlayer, 255, 0, 0 ) end function disableSam ( thePlayer ) setElementPosition ( deathSphere, 0, 0, -9999 ) setElementPosition ( warningSphere, 0, 0, -9999 ) outputChatBox ( "You have disabled the SAM sites at(place here)", thePlayer, 255, 0, 0 ) end function samSite ( thePlayer, matchingDimension ) veh = getPlayerOccupiedVehicle ( thePlayer ) id = getVehicleID ( veh ) if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 425 or id == 520 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then triggerClientEvent ( thePlayer, "onSamTrigger", getRootElement() ) outputChatBox ( "Surface to air missiles have been fired!", thePlayer, 255, 0, 0 ) end end function samWarn ( thePlayer, matchingDimension ) veh = getPlayerOccupiedVehicle ( thePlayer ) id = getVehicleID ( veh ) if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 425 or id == 520 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then outputChatBox ( "Warning! (place here) has SAM sites activated! Turn back!", thePlayer, 255, 0, 0 ) end end function jetpackTrigger ( thePlayer, matchingDimension ) if ( doesPlayerHaveJetPack ( thePlayer ) ) then outputChatBox ( "Warning! (place here) will kill you with telepathy if you go in with a jetpack!", thePlayer, 255, 0, 0 ) end end function jetpackWarn ( thePlayer, matchingDimension ) if ( doesPlayerHaveJetPack ( thePlayer ) ) then triggerClientEvent ( thePlayer, "onSamTrigger", getRootElement() ) outputChatBox ( "I wasn't lying about the telepathy death. Enjoy the fireworks!", thePlayer, 255, 0, 0 ) killPlayer ( thePlayer ) end end addCommandHandler ( "activatesam", enableSam ) addCommandHandler ( "deactivatesam", disableSam ) addEventHandler ( "onColShapeHit", deathSphere, samSite ) addEventHandler ( "onColShapeHit", warningSphere, samWarn ) addEventHandler ( "onColShapeHit", deathSphere, jetpackWarn ) addEventHandler ( "onColShapeHit", warningSphere, jetpackTrigger ) clientside: function samTrigger ( thePlayer ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) end addEvent ( "onSamTrigger", true ) addEventHandler ( "onSamTrigger", getRootElement(), samTrigger ) Link to comment
[DooD]Heavyair Posted May 4, 2008 Share Posted May 4, 2008 vercetti 10 10 u ROCK thank u so much Link to comment
50p Posted May 4, 2008 Share Posted May 4, 2008 Just a tip: make a for loop in clientside script. Link to comment
Vercetti1010 Posted May 5, 2008 Author Share Posted May 5, 2008 hmm, that sounds good, a loop. im guessing i can just have it do like a setTimer. how could i get that to stop so they arent constantly being shot at while in the server Link to comment
Ace_Gambit Posted May 5, 2008 Share Posted May 5, 2008 If you want to shoot at a player while he is in the death sphere simply toggle the sphere on and off (moving it from -9999 to XYZ back and forth) every x seconds. Since your script detects hit events the sam will fire every time the player is still in the death sphere area. Link to comment
[DooD]Heavyair Posted May 6, 2008 Share Posted May 6, 2008 sorry but i am really struggling to understand this scripting stuff im not sure where to set the coordinates for the position of the sam site i want to put it on the air craft carrier in easter bay but i dont seem to be getting anywhere could u possibly show me what i need to change sorry if im wasting your time and theres no need to reply if your busy as im sure ill figure it out eventualy thanx for the help so far vercetti 10 10 Link to comment
Vercetti1010 Posted May 6, 2008 Author Share Posted May 6, 2008 First what you need to do is set yourself as an admin on a test server run off your computer. then go to where you want the center of the spheres to be. open your admin control panel and take note of your X, Y, Z coordinates. the radius is measured in meters for colspheres. you kind of have to estimate how large the rocket field should be. if you make it too big, people just flying near the complex will be shot at. if you make it too small, people will be able to get in, so tinker around with the radius a bit. as for the warning sphere, make its radius bigger than the trigger sphere. set the XYZ coordinates the same though. as for the createProjectile's every createprojectile makes a rocket for one person in the intruding aircraft. so if you have a full maverick for instance, one createProjectile should make four rockets. you can add as many as you like as well as delete as many, but keep lag in mind when you add them. you dont want to overload the client. as for XYZ, what i did was i made three rockets fire from every sam site at area 51. but you can do things different. you can set the XYZ for the rockets wherever you like, maybe put three on every corner of the complex. record the XYZ of all four corners and add about 15 units to the Z position for each. then add about 5 Z units for every rocet above it. as for the commands activate sam and deactivate sam, leave deactivate sam to 0, 0, -9999. but put the xyz to activate sam to wherever your colSpheres are. this moves the colSphere to and from the area to simulate activation and deactivation, just in case you want to fly in. then just put the name of the place in and then your good. 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