ViRuZGamiing Posted December 29, 2012 Share Posted December 29, 2012 Helo Community, I want to add a Fraction. I mapped a Base and have the Gate script; local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) megusta = false addCommandHandler("gate", function () if (megusta == false) then moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 0 ) megusta = true elseif (megusta == true) then moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 0 ) megusta = false end end) How do I add a Fraction (example: Mafia) and let only them open the Gate with /gate command. Greetings Billy Link to comment
Bo7meeeD Posted December 29, 2012 Share Posted December 29, 2012 (edited) Helo Community,I want to add a Fraction. I mapped a Base and have the Gate script; local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) megusta = false addCommandHandler("gate", function () if (megusta == false) then moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 0 ) megusta = true elseif (megusta == true) then moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 0 ) megusta = false end end) How do I add a Fraction (example: Mafia) and let only them open the Gate with /gate command. Greetings Billy llocal gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) megusta = false addCommandHandler("gate", function () if ( getTeamName ( getPlayerTeam ( source ) ) == "Mafia" ) then if (megusta == false) then moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 0 ) megusta = true elseif (megusta == true) then moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 0 ) megusta = false else outputChatBox( "you're not in mafia team !", source, 0, 255, 0, true ) end end end) Edited December 29, 2012 by Guest Link to comment
TAPL Posted December 29, 2012 Share Posted December 29, 2012 You mean team? You can get the team name via these functions and check if the name was Mafia then open the gate. getPlayerTeam getTeamName playerSource: The player who triggered the command. If not triggered by a player (e.g. by admin), this will be false. playerSource is who you will get his team name. https://wiki.multitheftauto.com/wiki/AddCommandHandler EDIT: @SOSO, hitPlayer is not defined anywhere. Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 Already thanks for Helping; but can I have a Script that makes me a "team" ? Example: I start Resource "Team" and Mafia, Police, ... show up in Scoreboard Like in most of the RP Server Link to comment
TAPL Posted December 29, 2012 Share Posted December 29, 2012 createTeam setPlayerTeam Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 @TAPL this is Client Sided I think?! @SOSO Already thanks Link to comment
Bo7meeeD Posted December 29, 2012 Share Posted December 29, 2012 (edited) @TAPL this is Client Sided I think?!@SOSO Already thanks you're welcome Edited December 30, 2012 by Guest Link to comment
TAPL Posted December 29, 2012 Share Posted December 29, 2012 Server Side And this a fix for SOSO code: local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) megusta = false addCommandHandler("gate", function (source) -- i define source here (this needed for server side only) if ( getTeamName ( getPlayerTeam ( source ) ) == "Mafia" ) then if (megusta == false) then moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 0 ) megusta = true elseif (megusta == true) then moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 0 ) megusta = false else outputChatBox( "you're not in mafia team !", source, 0, 255, 0, true ) end end end) Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 I made this: function gimmeATeam ( source, joinMP, MP ) local newTeam = createTeam ( MP ) if newTeam then setPlayerTeam ( source, newTeam ) end end addCommandHandler("joinMP", gimmeATeam) MP = Militairy Police I think when i type ingame /koinMP that i'm in MP, am I right? Link to comment
Bo7meeeD Posted December 29, 2012 Share Posted December 29, 2012 I made this: function gimmeATeam ( source, joinMP, MP ) local newTeam = createTeam ( MP ) if newTeam then setPlayerTeam ( source, newTeam ) end end addCommandHandler("joinMP", gimmeATeam) MP = Militairy Police I think when i type ingame /koinMP that i'm in MP, am I right? function gimmeATeam ( source, joinMP, MP ) local newTeam = createTeam ( "MP" , 255, 0 , 0 ) if newTeam then setPlayerTeam ( source, newTeam ) end end addCommandHandler("joinMP", gimmeATeam) Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 Almost the same only forgot the color, Thanks Link to comment
Bo7meeeD Posted December 29, 2012 Share Posted December 29, 2012 Almost the same only forgot the color,Thanks you're welcome Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 I now added, when /joinMP you'll see in chat Welcome in the Militairy Army! function gimmeATeam ( source, joinMP, MP ) local newTeam = createTeam ( "MP" , 255, 0 , 0 ) if newTeam then setPlayerTeam ( source, newTeam ) outputChatBox ("welcome in the Militairy Army!" ,255, 0 , 0 ) end end addCommandHandler("joinMP", gimmeATeam) The Problem: Before i wrote /joinMP, MP isn't vissable in the Scoreboard, I think the createTeam need to be onResourceStart instead of onCommand Link to comment
Bo7meeeD Posted December 29, 2012 Share Posted December 29, 2012 I now added, when /joinMP you'll see in chat Welcome in the Militairy Army! function gimmeATeam ( source, joinMP, MP ) local newTeam = createTeam ( "MP" , 255, 0 , 0 ) if newTeam then setPlayerTeam ( source, newTeam ) outputChatBox ("welcome in the Militairy Army!" ,255, 0 , 0 ) end end addCommandHandler("joinMP", gimmeATeam) The Problem: Before i wrote /joinMP, MP isn't vissable in the Scoreboard, I think the createTeam need to be onResourceStart instead of onCommand addEventHandler("onResourceStart",resourceRoot, function () newTeam = createTeam ( "MP" , 255, 0 , 0 ) end ) function gimmeATeam ( source, joinMP, MP ) if newTeam then setPlayerTeam ( source, newTeam ) outputChatBox ("welcome in the Militairy Army!" , source,255, 0 , 0 ) end end addCommandHandler("joinMP", gimmeATeam) Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 Can I add: if (getPlayerSkin(playerSource) == 164) then outputChatBox("You are already in the Militairy Police!", playerSource) else setPlayerSkin(playerSource, 164) end end When i write /joinMP i'm in MP and then my skin changes to skinId 164 Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 Correct me when i'm wrong: addEventHandler("onResourceStart",resourceRoot, function () newTeam = createTeam ( "MP" , 255, 0 , 0 ) end ) function gimmeATeam ( source, joinMP, MP ) if newTeam then setPlayerTeam ( source, newTeam ) outputChatBox ("welcome in the Militairy Army!" , source,255, 0 , 0 ) setPlayerSkin(playerSource, 164) else getPlayerTeam ( source, MP ) outputChatBox("You are already in the Militairy Police!", playerSource) end end addCommandHandler("joinMP", gimmeATeam) Link to comment
Jaysds1 Posted December 29, 2012 Share Posted December 29, 2012 try this: local newTeam = nil --make this variable global in this script only addEventHandler("onResourceStart",resourceRoot,function () newTeam = createTeam ( "MP" , 255, 0 , 0 ) --creates team end) addCommandHandler("joinMP", function(source) if not newTeam then outputChatBox("Team couldn't be created!") return end --if the team wasn't created, then tell them and stop the script if getPlayerTeam(source) == newTeam then --if the player is on the team outputChatBox("You are already on the team!") --tell them that they are on the team else setPlayerTeam(source,newTeam) --put them on the team setElementModel(source,164) --change their skin outputChatBox("You are now on the Military team!") --then tell them they're on the team end end) Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 It works, can I add weapon also with Skin and Team chance? Link to comment
ViRuZGamiing Posted December 29, 2012 Author Share Posted December 29, 2012 Weapons added, problem solved 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