Xwad Posted July 25, 2015 Posted July 25, 2015 hi! What funvtions need i use to make a script that disables the explosion demage on the rhino if a rhino shot it. I mean if i shoot the rhino with a rhino then the rhino will not demaged.
HUNGRY:3 Posted July 25, 2015 Posted July 25, 2015 just an example function noshootteam(attacker, target ) if isPedInVehicle(attacter) then if getElementData( attacker,"cop") == true then if getElementData( target,"cop") == true then outputChatBox ( "Don't Shoot Your TeamMates!",attacker, 255, 0, 0 ) cancelEvent() end end end end addEventHandler ( "onClientPlayerDamage", root, noshootteam )
Xwad Posted July 25, 2015 Author Posted July 25, 2015 Thanks. I tryed to make it but its not working:/ The debugscript said something problem with 'then' function teamkill(attacker, target ) if isPedInVehicle(attacter) then if getElementModel( attacker ) == 432) == true then if getElementModel( target ) == 432) == true then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) cancelEvent() end end end end addEventHandler ( "onClientVehicleDamage", root, teamkill )
Xwad Posted July 25, 2015 Author Posted July 25, 2015 Its not working:/ function teamkill(attacker, target ) if isPedInVehicle(attacter) then if (getElementModel ( attacker ) == 432) == true then if (getElementModel ( target ) == 432) == true then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) cancelEvent() end end end end addEventHandler ( "onClientVehicleDamage", root, teamkill )
novo Posted July 25, 2015 Posted July 25, 2015 It is not working because you are using onClientVehicleDamage's arguments in a wrong way. Either way, you are using attacter at isPedInVehicle - a non-defined variable. addEventHandler("onClientVehicleDamage", root, function(attacker) if getElementModel(source) ~= 432 then return end -- avoid this function from executing in case the vehicle that is being damaged is not a tank(?) if getElementModel(attacker) == 432 then -- in case attacker's model is equal to 432 if getVehicleController(attacker) == localPlayer then -- in case the attacker tank's driver is the localPlayer outputChatBox("Don't attack friendly tanks!", 255, 0, 0) -- a warning message is output end cancelEvent() end end )
Xwad Posted July 25, 2015 Author Posted July 25, 2015 its not working when i shoot the rhino with the rhino only if i hit it with the rhinos body
bosslorenz Posted July 26, 2015 Posted July 26, 2015 Try this one. I just searched some codes made by TAPL. addEventHandler("onClientVehicleDamage", root, function(attacker) if attacker and getElementType(attacker) == "player" then local driver = getVehicleController(source) if driver then local attackerTeam = getPlayerTeam(attacker) local driverTeam = getPlayerTeam(driver) if attackerTeam and driverTeam and attackerTeam == driverTeam then cancelEvent() end end end end)
HUNGRY:3 Posted July 26, 2015 Posted July 26, 2015 function teamkill(attacker, target ) if isPedInVehicle(attacter) then if (getElementModel ( attacker ) == 432) then if (getElementModel ( target ) == 432) then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) cancelEvent() end end end end addEventHandler ( "onVehicleDamage", root, teamkill ) If there is a error please post it
xeon17 Posted July 26, 2015 Posted July 26, 2015 function teamkill(attacker, target ) if isPedInVehicle(attacter) then if (getElementModel ( attacker ) == 432) then if (getElementModel ( target ) == 432) then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) cancelEvent() end end end end addEventHandler ( "onVehicleDamage", root, teamkill ) If there is a error please post it The event onVehicleDamage can't be canceled.
Xwad Posted July 26, 2015 Author Posted July 26, 2015 why? maybe we can make it with setElementHealth no?
HUNGRY:3 Posted July 26, 2015 Posted July 26, 2015 function teamkill(attacker, target ) if isPedInVehicle(attacter) then if (getElementModel ( attacker ) == 432) then if (getElementModel ( target ) == 432) then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) fixVehicle( target ) end end end end addEventHandler ( "onVehicleDamage", root, teamkill ) idk if it will work
xeon17 Posted July 26, 2015 Posted July 26, 2015 function teamkill(attacker, target ) if isPedInVehicle(attacter) then if (getElementModel ( attacker ) == 432) then if (getElementModel ( target ) == 432) then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) fixVehicle( target ) end end end end addEventHandler ( "onVehicleDamage", root, teamkill ) idk if it will work Of course it won't work because the event onVehicleDamage have only one argument which is loss. Stop trying to help peoples when you don't even know the basic things.
#meS Posted July 26, 2015 Posted July 26, 2015 function teamkill(attacker, target ) if isPedInVehicle(attacter) then if (getElementModel ( attacker ) == 432) then if (getElementModel ( target ) == 432) then outputChatBox ( "Don't attack friendly tanks!",attacker, 255, 0, 0 ) fixVehicle( target ) end end end end addEventHandler ( "onVehicleDamage", root, teamkill ) idk if it will work Of course it won't work because the event onVehicleDamage have only one argument which is loss. Stop trying to help peoples when you don't even know the basic things. Just saying that is mean the man is trying to help ... While you're just writing ...
Xwad Posted July 26, 2015 Author Posted July 26, 2015 So is it impossible to make that script? But thanks for your help! maybe with setElementHealth?
#meS Posted July 26, 2015 Posted July 26, 2015 So is it impossible to make that script? But thanks for your help! maybe with setElementHealth? Nothing is impossible maybe try onClientVehicleDamge? and remove attacker from the output line. I guess.
novo Posted July 26, 2015 Posted July 26, 2015 addEventHandler("onClientVehicleDamage", root, function(attacker) if getElementModel(source) ~= 432 then return end -- avoid this function from executing in case the vehicle that is being damaged is not a tank(?) if getElementModel(getPedOccupiedVehicle(attacker)) == 432 then -- in case attacker's model is equal to 432 if attacker == localPlayer then -- in case the attacker tank's driver is the localPlayer outputChatBox("Don't attack friendly tanks!", 255, 0, 0) -- a warning message is output end cancelEvent() end end ) What about this? You could've either way tried to modify the code on your own, lol.
Xwad Posted July 30, 2015 Author Posted July 30, 2015 not wroking:/ Maybe can it make by teams? i mean if there are 2 teams and the team mate shoots the teammate then he will not be demaged?
HUNGRY:3 Posted July 30, 2015 Posted July 30, 2015 addEventHandler("onResourceStart", resourceRoot, function() setTeamFriendlyFire(getTeamFromName("YOUR_TEAM_NAME"), false) end )
Moderators IIYAMA Posted July 31, 2015 Moderators Posted July 31, 2015 Tanks can't damage other tanks, only the fire of the explosion causes damage. (fire damage can't be detected well and most of the time there is no owner) That you guys haven't figure that out yet. O_o
Xwad Posted July 31, 2015 Author Posted July 31, 2015 But i made a script that makes possible that explosion can demage tanks..
Moderators IIYAMA Posted July 31, 2015 Moderators Posted July 31, 2015 But i made a script that makes possible that explosion can demage tanks.. Then you have to edit that one...
Xwad Posted July 31, 2015 Author Posted July 31, 2015 Here is the script but i dont know how to cancel the event when the rhino is shooting:/ cleint.lua addEventHandler ( "onClientExplosion", root, function ( x, y, z ) for i, v in ipairs ( getElementsByType ( "vehicle" ) ) do local vx, vy, vz = getElementPosition ( v ); if ( getDistanceBetweenPoints3D ( x, y, z, vx, vy, vz ) <= 20 and getElementModel ( v ) == 432 ) then triggerServerEvent ( "OnRhinoDamageFromExplosion", v, (20 / getDistanceBetweenPoints3D ( x, y, z, vx, vy, vz ))*13 ); end end end ) server.lua addEvent ( "OnRhinoDamageFromExplosion", true ); addEventHandler ( "OnRhinoDamageFromExplosion", root, function ( d ) setElementHealth ( source, getElementHealth ( source ) - d ); end );
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