Jump to content

Only alloud to enter team once. Help?


Recommended Posts

Hi,

I made a script where you enter the marker and it sets your team, puts you in a police skin and gives you weapons. but you can keep going back and getting more weapons :\ I need a way so you can only go as get weapons once until you leave the team, when they are removed.

This is what i got so far

local Police = createTeam("Police", 0, 0, 255)   -- this will create the team everytime the  
  
script starts 
local teamMarker = createMarker(1553.33, -1677.37, 15.382, 'cylinder', 1.0, 0, 0, 255, 150 ) 
  
function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        setPlayerTeam ( hitElement, Police) 
    setPlayerSkin( hitElement, 280) 
    giveWeapon ( hitElement, 3, 1, true ) 
    giveWeapon ( hitElement, 22, 148, true ) 
    giveWeapon ( hitElement, 29, 64, true ) 
    giveWeapon ( hitElement, 25, 10, true ) 
  end 
end 
addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit )  

Any ideas? Thanks

Link to comment

local Police = createTeam("Police", 0, 0, 255)

local teamMarker = createMarker(1553.33, -1677.37, 15.382, 'cylinder', 1.0, 0, 0, 255, 150 )

  
function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        if getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam (hitElement) == Police then 
            outputChatBox("You are already in this team", thePlayer) 
        else 
            setPlayerTeam" class="kw6">setPlayerTeam ( hitElement, Police) 
            setPlayerSkin( hitElement, 280) 
            giveWeapon ( hitElement, 3, 1, true ) 
            giveWeapon ( hitElement, 22, 148, true ) 
            giveWeapon ( hitElement, 29, 64, true ) 
            giveWeapon ( hitElement, 25, 10, true ) 
        end 
  end 
end 
addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit )  

Edited by Guest
Link to comment

you can check if the players team is the same as the team element saved on your "Police" variable

local Police = createTeam("Police", 0, 0, 255)   -- this will create the team everytime the  
  
--script starts 
local teamMarker = createMarker(1553.33, -1677.37, 15.382, 'cylinder', 1.0, 0, 0, 255, 150 ) 
  
function teamMarkerHit( hitElement, matchingDimension ) 
  if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
    if not getPlayerTeam(hitElement) == Police then 
      setPlayerTeam ( hitElement, Police) 
      setPlayerSkin( hitElement, 280) 
      giveWeapon ( hitElement, 3, 1, true ) 
      giveWeapon ( hitElement, 22, 148, true ) 
      giveWeapon ( hitElement, 29, 64, true ) 
      giveWeapon ( hitElement, 25, 10, true ) 
    end 
  end 
end 
addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit )  

Link to comment
local Police = createTeam("Police", 0, 0, 255)

local teamMarker = createMarker(1553.33, -1677.37, 15.382, 'cylinder', 1.0, 0, 0, 255, 150 )

  
function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        if getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam (hitElement) == Police then 
            outputChatBox("You are already in this team", thePlayer) 
        else 
            setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam ( hitElement, Police) 
            setPlayerSkin( hitElement, 280) 
            giveWeapon ( hitElement, 3, 1, true ) 
            giveWeapon ( hitElement, 22, 148, true ) 
            giveWeapon ( hitElement, 29, 64, true ) 
            giveWeapon ( hitElement, 25, 10, true ) 
        end 
  end 
end 
addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit )  
 

This doesnt seem to be working, i get an error on my server window saying : Then expected near kw2

Please help?

Link to comment

this is a forum Lua highlighter bug with get/setPlayerTeam() functions.

and dont just blindly copy everything, at least try to understand how things work.

function teamMarkerHit( hitElement, matchingDimension ) 
    if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then 
        if getPlayerTeam (hitElement) == Police then 
            outputChatBox("You are already in this team", hitElement) 
        else 
            setPlayerTeam ( hitElement, Police) 
            setPlayerSkin( hitElement, 280) 
            giveWeapon ( hitElement, 3, 1, true ) 
            giveWeapon ( hitElement, 22, 148, true ) 
            giveWeapon ( hitElement, 29, 64, true ) 
            giveWeapon ( hitElement, 25, 10, true ) 
        end 
  end 
end 
addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit ) 

also its not thePlayer, but hitElement on line 4.

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