Jump to content

[HELP]Fraction/Gate


ViRuZGamiing

Recommended Posts

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
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 by Guest
Link to comment

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

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
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

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
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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...