jkub Posted November 29, 2009 Share Posted November 29, 2009 Ive seen the paintball script and another similar small script that adds explosions to wherever you shoot. I wanted to make somthing similar that allows you to shoot white orbs and when shot at vehicles or players it will stick to them. Later on you can use a command or other method of input to detonate the orb ( explosion ). I successfully did that with help of references of other great scripts. There is a limit of how many orbs can be deployed at once I have it set to 20. Whenever anyone types the special command to detonate the orbs It will detonate every single orb that has been deployed even if that person has not deployed any orbs theirselves. So basicly I will have people running around detonating other peoples orbs. I dont want that, I want it to where they detonate their OWN orbs. I have no clue how to do this with multiple elements in a table since there will be multiple orbs. I thought of client explosions but then that would just be for one person and it would defeat the whole purpose of everying being able to be affected by the explosion Here is some of my code Server addEvent ( "clientFire", true ) addEventHandler ( "clientFire", getRootElement(), function ( x, y, z, hitElement, weapon, size, expType ) if ballCount < 20 then beacons[ballCount] = {} beacons[ballCount].ball = createMarker ( x, y, z, "corona", size, 255, 255, 255, 255, getRootElement() ) local x, y, z = getElementPosition ( beacons[ballCount].ball ) if hitElement then if getElementType ( hitElement ) == "vehicle" or getElementType ( hitElement ) == "player" then attachElements ( beacons[ballCount].ball, hitElement, 0, 0, 0 ) end end explosionNumber = tonumber(expType) ballCount = ballCount + 1 elseif ballCount == 20 then playSoundFrontEnd ( client, 41 ) outputChatBox ( "Hax limit reached: Explode your current Hax", client, 255, 0, 0 ) end end ) addCommandHandler ( "det", function ( player, cmd ) if beacons then for k,v in pairs ( beacons ) do local x, y, z = getElementPosition ( beacons[k].ball ) createExplosion ( x, y, z, explosionNumber, player ) destroyElement ( beacons[k].ball ) beacons[k] = {} ballCount = 0 end end end Can I please get some help with this Link to comment
robhol Posted November 29, 2009 Share Posted November 29, 2009 setElementData on the markers, with the player name or element or whatever. When one player triggers the detonation, check the player for every orb/sticky bomb and see if it's the one who triggered the command. Link to comment
jkub Posted November 29, 2009 Author Share Posted November 29, 2009 I used this to set the element data setElementData ( beacons[ballCount].ball, "owner", getPlayerName(client) ) and later on in the detonation function I try to use this to retrieve it local ownerName = getElementData ( beacons, "owner" ) The setelement data works fine ( no errors ) but getELementData line returns a bad argument every time any suggestions? EDIT: I just now tried out "beacons[k].ball" and it returns no errors and it does actually explode but I do not have anyone else in my server to test it with to make sure... Does it look right? Link to comment
robhol Posted November 30, 2009 Share Posted November 30, 2009 I haven't got time to look through the code itself at the moment, but if it does explode and there is an IF around the function call that detonates them; bully for you, you've probably made it. To test, you can change it to use player names, and then change your nick for testing purposes. Obviously you should stick with elements, after you're sure it works. Link to comment
jkub Posted November 30, 2009 Author Share Posted November 30, 2009 I was finallly able to test this with another couple of players in my server using the name method and it did work for each person BUT I beilive my current problem may be a sync problem. At first when you just start using the script it shoots out only 1 marker for each shot you fired but as you go on it will sometimes shoot out 2 at a time for each shot. For each extra marker that comes out ( for example you shoot once and 2 comes out ) when you detonate it only one of them will explode leaving another marker permenently stuck. I beilive I didn't intend on this and see no suspected code capeable of this in my script. I do know that I am creating all those markers server side though and that may be adding to the problem. Can making the markers client fix that entire problem? Link to comment
jkub Posted December 2, 2009 Author Share Posted December 2, 2009 Ya I changed it up yesterday to where the markers where the markers were client side. Of course that does lead to many client>server interactions. I hope it does not end up like it was when I had like 6 people playing with it there were stuck markers everywhere. Is there any way to get the position of the end of the players gun barrel when he is pointing it? 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