Deep thinker Posted November 20, 2016 Share Posted November 20, 2016 hello,today i needed a script which enables the friendlyfire between two teams among like 7 teams in the scoreboard but i didn't know what to type in the script or what functions or events should i use , i wish if someone gives me an example to make this script, thank you , Link to comment
iPrestege Posted November 20, 2016 Share Posted November 20, 2016 Use the following : addEventHandler ( 'onClientPlayerDamage' ) getElementType getPlayerTeam getTeamFromName cancelEvent 1 Link to comment
Deep thinker Posted November 20, 2016 Author Share Posted November 20, 2016 actually i want you to explain something and tide the functions and events as i say in the following sentences,I want check if the player who is shooting for example in "Team 1" and the anther one in "Team 2" if the both tried to kill each others they fail. Link to comment
iPrestege Posted November 20, 2016 Share Posted November 20, 2016 Use as i said and use attacker from onClientPlayerDamage event i can't give an example in the moment i'm posting from my phone. Link to comment
Deep thinker Posted November 20, 2016 Author Share Posted November 20, 2016 what does getElementType Used for? Link to comment
iPrestege Posted November 20, 2016 Share Posted November 20, 2016 to check that the attacker is a player. Link to comment
Deep thinker Posted November 20, 2016 Author Share Posted November 20, 2016 i am confused and i don't know to add after "getElementType ( Player,.......)" Link to comment
iPrestege Posted November 20, 2016 Share Posted November 20, 2016 Do it like this : if getElementType ( YourAttacker ) == 'player' then Link to comment
Deep thinker Posted November 20, 2016 Author Share Posted November 20, 2016 check this i have thought in anther idea for me ,i have created teams which can't be able to get killed but i will use this 17 minutes ago, iPrestege said: Do it like this : if getElementType ( YourAttacker ) == 'player' then again here i just wanted to make these people unable to get killed local team = getTeamFromName (getLocalPlayer()) addEventHandler ( 'onClientPlayerDamage',root, function () if ( team == "Unemployed" ) or ( team == "Off Duty Workers" ) or ( team == "Civilian" ) or ( team == "Emergency" ) then if getElementData ( Player, "team" ) then cancelEvent() end end end ) is it right,i don't have a virtual machine to test it? and i don't know how to make one i have the program but i didn't get it Link to comment
iPrestege Posted November 20, 2016 Share Posted November 20, 2016 addEventHandler ( 'onClientPlayerDamage',localPlayer, function ( aAttacker ) if ( aAttacker and getElementType ( aAttacker ) == 'player' and aAttacker ~= source ) then local aLocalTeam = getPlayerTeam ( source ) local aAttackerTeam = getPlayerTeam ( aAttacker ) if ( aLocalTeam and aAttackerTeam ) then if ( aLocalTeam == getTeamFromName ( 'TeamOne' ) and aAttackerTeam == getTeamFromName ( 'TeamTwo' ) ) then cancelEvent ( ) end end end end ) Try this and replace 'TeamOne' and 'TeamTwo', With your teams. 1 Link to comment
Deep thinker Posted November 21, 2016 Author Share Posted November 21, 2016 21 hours ago, iPrestege said: addEventHandler ( 'onClientPlayerDamage',localPlayer, function ( aAttacker ) if ( aAttacker and getElementType ( aAttacker ) == 'player' and aAttacker ~= source ) then local aLocalTeam = getPlayerTeam ( source ) local aAttackerTeam = getPlayerTeam ( aAttacker ) if ( aLocalTeam and aAttackerTeam ) then if ( aLocalTeam == getTeamFromName ( 'TeamOne' ) and aAttackerTeam == getTeamFromName ( 'TeamTwo' ) ) then cancelEvent ( ) end end end end ) Try this and replace 'TeamOne' and 'TeamTwo', With your teams. what about my code is it correct ( the point of the script that i made is to make these teams can't be killed by others ) is it correct in any kind of ways? and i will test your code.thank you 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