Jump to content

create onMarkerHit,PlayerInVehicle,return end function?


Adde

Recommended Posts

I´m trying to create a function that stop players that´s in a vehicle from using 6 markers but I can´t complete it. I don´t know exactly how to do it, but I can imagine about how it should be and I don´t know how to make a table or something so it happends to all markers. I searched and searched for answears but couldn´t find any or understand. Here is markers, eventhandler and function from the script.

marker1 = createMarker (-1616.25,684.86,6.18,"cylinder",1.5,0,60,200,100) 
marker2 = createMarker (-1569.64,670.04,6.18,"cylinder",1.5,0,60,200,100) 
marker3 = createMarker (-1296,442.03,6.18,"cylinder",1.5,0,60,200,100) 
marker4 = createMarker (-1539.93,484.16,6.17,"cylinder",1.5,0,60,200,100) 
marker5 = createMarker (227.69,1921.02,16.5,"cylinder",1.5,0,60,200,100) 
marker6 = createMarker (-72.36,2048.72,17.40,"cylinder",1.5,0,60,200,100) 
  
addEventHandler ( "onMarkerHit", marker1, spawninTeam1 ) 
addEventHandler ( "onMarkerHit", marker2, spawninTeam1 ) 
  
addEventHandler ( "onMarkerHit", marker3, spawninTeam2 ) 
addEventHandler ( "onMarkerHit", marker4, spawninTeam2 ) 
  
addEventHandler ( "onMarkerHit", marker5, spawninTeam3 ) 
addEventHandler ( "onMarkerHit", marker6, spawninTeam3 ) 
  
==something like== 
function VehicleMarkerHit() 
if (isPedInVehicle(player)) then return end 
addEvent(joinTeam, false) 
addEventHandler("onMarkerHit", marker, VehicleMarkerHit 

I will be very thankfull for answears :)

Link to comment

If i'm right then this how your code should look like :

addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then  
            if isPlayerInVehicle( hitElement ) then 
                return  
            else 
                if ( source == marker1 ) then 
                    spawnPlayer( hitElement, x, y, z ) 
                elseif ( source == marker2 ) then 
                    spawnPlayer( hitElement, x, y, z ) 
                elseif ( source == marker3 ) then 
                    spawnPlayer( hitElement, x, y, z ) 
                elseif ( source == marker4 ) then 
                    spawnPlayer( hitElement, x, y, z ) 
                elseif ( source == marker5 ) then 
                    spawnPlayer( hitElement, x, y, z ) 
                elseif ( source == marker6 ) then 
                    spawnPlayer( hitElement, x, y, z ) 
                end 
            end 
        end 
    end 
) 

Link to comment
addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then  
            if not isPlayerInVehicle( hitElement ) then 
                if ( source == marker1 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker2 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker3 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker4 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker5 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker6 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                end 
            end 
        end 
    end 
) 

Link to comment

You're Welcome.

@ #The_Pain

In You're Code "return" return for what

@ Adde

Just Remove This Fucking Line or Send Me Full Script "PM" .

  
function VehicleMarkerHit() 
if (isPedInVehicle(player)) then return end 
addEvent(joinTeam, false) 
addEventHandler("onMarkerHit", marker, VehicleMarkerHit 

Edited by Guest
Link to comment

addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then  
            if not isPedInVehicle( hitElement ) then 
                if ( source == marker1 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker2 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker3 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker4 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker5 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                elseif ( source == marker6 ) then 
                    setElementPosition( hitElement, x, y, z ) 
                end 
            end 
        end 
    end 
) 
Link to comment
Can You Post the script so we can help you ?
marker1 = createMarker (-1616.25,684.86,6.18,"cylinder",1.5,0,60,200,100) 
marker2 = createMarker (-1569.64,670.04,6.18,"cylinder",1.5,0,60,200,100) 
marker3 = createMarker (-1296,442.03,6.18,"cylinder",1.5,0,60,200,100) 
marker4 = createMarker (-1539.93,484.16,6.17,"cylinder",1.5,0,60,200,100) 
marker5 = createMarker (227.69,1921.02,16.5,"cylinder",1.5,0,60,200,100) 
marker6 = createMarker (-72.36,2048.72,17.40,"cylinder",1.5,0,60,200,100) 
  
Blip1 = createBlip (-1616.25,684.86,6.18,59,2,255,0,0,255) 
Blip2 = createBlip (-1569.64,670.04,6.18,59,2,255,0,0,255) 
Blip3 = createBlip (-1296,442.03,6.18, 59,2,255,0,0,255) 
Blip4 = createBlip (-1539.93,484.16,6.17,59,2,255,0,0,255) 
Blip5 = createBlip (227.69,1921.02,16.5,59,2,255,0,0,255) 
Blip6 = createBlip (-72.36,2048.72,17.40,59,2,255,0,0,255) 
  
player = source 
  
function teams() 
  
        Staff = createTeam ( "Staff", 255, 128, 0 ) 
        SWAT = createTeam ( "SWAT", 100, 100, 100 ) 
        Military = createTeam ( "Military", 0, 204, 0 ) 
        Army = createTeam ( "Army", 59, 166, 109 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), teams ) 
  
function onPlayerSpawn (player) 
  setPlayerTeam ( source, Army ) 
  spawnPlayer ( source, 235.4085, 1911.13, 18 ) 
  givePlayerMoney ( source, 2000 ) 
  setPedArmor ( source, 60 ) 
  setElementModel( source, 179 ) 
  setPlayerNametagColor ( source, 59, 166, 109 ) 
 fadeCamera ( source, true, 3 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerSpawn ) 
  
function spawninSWAT (player, OnPlayerMarkerHit ) 
 setPlayerTeam ( player, SWAT ) 
   setPedArmor ( player, 50 ) 
   setElementModel( player, 285 ) 
   setPlayerNametagColor ( player, 100, 100, 100 ) 
        outputChatBox ( "New member in SWAT team", source, 0, 255, 255 ) 
end 
addEvent("setSWAT", true) 
addEventHandler ( "onMarkerHit", marker1, spawninSWAT ) 
addEventHandler ( "onMarkerHit", marker2, spawninSWAT ) 
  
function spawninMilitary (player, commandName ) 
 setPlayerTeam ( player, Military ) 
   setPedArmor ( player, 60 ) 
   setElementModel( player, 287 ) 
   setPlayerNametagColor ( player, 0, 204, 0 ) 
        outputChatBox ( "New member in Military team", source, 0, 255, 255 ) 
end 
addEvent("setMilitary", true) 
addEventHandler ( "onMarkerHit", marker3, spawninMilitary ) 
addEventHandler ( "onMarkerHit", marker4, spawninMilitary ) 
  
function spawninArmy (player, commandName ) 
 setPlayerTeam ( player, Army ) 
   setPedArmor ( player, 60 ) 
   setElementModel( player, 179 ) 
   setPlayerNametagColor ( player, 59, 166, 109 ) 
        outputChatBox ( "New member in Army team", source, 0, 255, 255 ) 
end 
addEvent("setArmy", true) 
addEventHandler ( "onMarkerHit", marker5, spawninArmy ) 
addEventHandler ( "onMarkerHit", marker6, spawninArmy ) 
  
function spawninStaff (player, commandName ) 
local accName1 = getAccountName ( getPlayerAccount ( player ) ) 
    if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Owner" ) ) or hasObjectPermissionTo( player, 'function.kickPlayer', false ) then 
  setPlayerTeam ( player, Staff ) 
  setPedArmor ( player, 100 ) 
  setElementModel ( player, 217 ) 
  setPlayerNametagColor ( player, 255, 128, 0 ) 
    end 
end 
addCommandHandler ( "Staff", spawninStaff ) 
  
addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then 
            if not isPlayerInVehicle( hitElement ) then 
                if ( source == marker1 ) then 
                    setElementPosition( hitElement, -1616.25,684.86,7.18 ) 
                elseif ( source == marker2 ) then 
                    setElementPosition( hitElement, -1569.64,670.04,7.18 ) 
                elseif ( source == marker3 ) then 
                    setElementPosition( hitElement, -1296,442.03,7.18 ) 
                elseif ( source == marker4 ) then 
                    setElementPosition( hitElement, -1539.93,484.16,7.17 ) 
                elseif ( source == marker5 ) then 
                    setElementPosition( hitElement, 227.69,1921.02,17.5 ) 
                elseif ( source == marker6 ) then 
                    setElementPosition( hitElement, -72.36,2048.72,18.40 ) 
                end 
            end 
        end 
    end 
) 

Link to comment
marker1 = createMarker (-1616.25,684.86,6.18,"cylinder",1.5,0,60,200,100) 
marker2 = createMarker (-1569.64,670.04,6.18,"cylinder",1.5,0,60,200,100) 
marker3 = createMarker (-1296,442.03,6.18,"cylinder",1.5,0,60,200,100) 
marker4 = createMarker (-1539.93,484.16,6.17,"cylinder",1.5,0,60,200,100) 
marker5 = createMarker (227.69,1921.02,16.5,"cylinder",1.5,0,60,200,100) 
marker6 = createMarker (-72.36,2048.72,17.40,"cylinder",1.5,0,60,200,100) 
Blip1 = createBlip (-1616.25,684.86,6.18,59,2,255,0,0,255) 
Blip2 = createBlip (-1569.64,670.04,6.18,59,2,255,0,0,255) 
Blip3 = createBlip (-1296,442.03,6.18, 59,2,255,0,0,255) 
Blip4 = createBlip (-1539.93,484.16,6.17,59,2,255,0,0,255) 
Blip5 = createBlip (227.69,1921.02,16.5,59,2,255,0,0,255) 
Blip6 = createBlip (-72.36,2048.72,17.40,59,2,255,0,0,255) 
Staff = createTeam ( "Staff", 255, 128, 0 ) 
SWAT = createTeam ( "SWAT", 100, 100, 100 ) 
Military = createTeam ( "Military", 0, 204, 0 ) 
Army = createTeam ( "Army", 59, 166, 109 ) 
  
function onPlayerSpawn (player) 
  setPlayerTeam ( player, Army ) 
  spawnPlayer ( player, 235.4085, 1911.13, 18 ) 
  givePlayerMoney ( player, 2000 ) 
  setPedArmor ( player, 60 ) 
  setElementModel( player, 179 ) 
  setPlayerNametagColor ( player, 59, 166, 109 ) 
 fadeCamera ( player, true, 3 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerSpawn ) 
  
function spawninSWAT (player) 
 setPlayerTeam ( player, SWAT ) 
   setPedArmor ( player, 50 ) 
   setElementModel( player, 285 ) 
   setPlayerNametagColor ( player, 100, 100, 100 ) 
        outputChatBox ( "New member in SWAT team", player, 0, 255, 255 ) 
end 
addEvent("setSWAT", true) 
addEventHandler ( "onMarkerHit", marker1, spawninSWAT ) 
addEventHandler ( "onMarkerHit", marker2, spawninSWAT ) 
  
function spawninMilitary (player) 
 setPlayerTeam ( player, Military ) 
   setPedArmor ( player, 60 ) 
   setElementModel( player, 287 ) 
   setPlayerNametagColor ( player, 0, 204, 0 ) 
        outputChatBox ( "New member in Military team", player, 0, 255, 255 ) 
end 
addEvent("setMilitary", true) 
addEventHandler ( "onMarkerHit", marker3, spawninMilitary ) 
addEventHandler ( "onMarkerHit", marker4, spawninMilitary ) 
  
function spawninArmy (player) 
 setPlayerTeam ( player, Army ) 
   setPedArmor ( player, 60 ) 
   setElementModel( player, 179 ) 
   setPlayerNametagColor ( player, 59, 166, 109 ) 
        outputChatBox ( "New member in Army team", player, 0, 255, 255 ) 
end 
addEvent("setArmy", true) 
addEventHandler ( "onMarkerHit", marker5, spawninArmy ) 
addEventHandler ( "onMarkerHit", marker6, spawninArmy ) 
  
function spawninStaff (player) 
local accName1 = getAccountName ( getPlayerAccount ( player ) ) 
    if accName1 then 
    if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Owner" ) ) or hasObjectPermissionTo( player, 'function.kickPlayer', false ) then 
  setPlayerTeam ( player, Staff ) 
  setPedArmor ( player, 100 ) 
  setElementModel ( player, 217 ) 
  setPlayerNametagColor ( player, 255, 128, 0 ) 
    end 
end 
addCommandHandler ( "Staff", spawninStaff ) 
  
addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then 
            if not isPlayerInVehicle( hitElement ) then 
                if ( player == marker1 ) then 
                    setElementPosition( hitElement, -1616.25,684.86,7.18 ) 
                elseif ( player == marker2 ) then 
                    setElementPosition( hitElement, -1569.64,670.04,7.18 ) 
                elseif ( player == marker3 ) then 
                    setElementPosition( hitElement, -1296,442.03,7.18 ) 
                elseif ( player == marker4 ) then 
                    setElementPosition( hitElement, -1539.93,484.16,7.17 ) 
                elseif ( player == marker5 ) then 
                    setElementPosition( hitElement, 227.69,1921.02,17.5 ) 
                elseif ( player == marker6 ) then 
                    setElementPosition( hitElement, -72.36,2048.72,18.40 ) 
                end 
            end 
        end 
    end) 
end 

Link to comment
marker1 = createMarker (-1616.25,684.86,6.18,"cylinder",1.5,0,60,200,100) 
marker2 = createMarker (-1569.64,670.04,6.18,"cylinder",1.5,0,60,200,100) 
marker3 = createMarker (-1296,442.03,6.18,"cylinder",1.5,0,60,200,100) 
marker4 = createMarker (-1539.93,484.16,6.17,"cylinder",1.5,0,60,200,100) 
marker5 = createMarker (227.69,1921.02,16.5,"cylinder",1.5,0,60,200,100) 
marker6 = createMarker (-72.36,2048.72,17.40,"cylinder",1.5,0,60,200,100) 
Blip1 = createBlip (-1616.25,684.86,6.18,59,2,255,0,0,255) 
Blip2 = createBlip (-1569.64,670.04,6.18,59,2,255,0,0,255) 
Blip3 = createBlip (-1296,442.03,6.18, 59,2,255,0,0,255) 
Blip4 = createBlip (-1539.93,484.16,6.17,59,2,255,0,0,255) 
Blip5 = createBlip (227.69,1921.02,16.5,59,2,255,0,0,255) 
Blip6 = createBlip (-72.36,2048.72,17.40,59,2,255,0,0,255) 
Staff = createTeam ( "Staff", 255, 128, 0 ) 
SWAT = createTeam ( "SWAT", 100, 100, 100 ) 
Military = createTeam ( "Military", 0, 204, 0 ) 
Army = createTeam ( "Army", 59, 166, 109 ) 
   
addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then 
            if not isPlayerInVehicle( hitElement ) then 
                if ( source == marker1 ) or ( source == marker2 ) then 
                    setPlayerTeam ( hitElement, SWAT ) 
                    setPedArmor ( hitElement, 50 ) 
                    setElementModel( hitElement, 285 ) 
                    setPlayerNametagColor ( hitElement, 100, 100, 100 ) 
                    outputChatBox ( "New member in SWAT team", hitElement, 0, 255, 255 ) 
                    setElementPosition( hitElement, -1616.25,684.86,7.18 ) 
                elseif ( source == marker3 ) or ( source == marker4 ) then 
                    setElementPosition( hitElement, -1296,442.03,7.18 ) 
                    setPlayerTeam ( hitElement, Military ) 
                    setPedArmor ( hitElement, 60 ) 
                    setElementModel( hitElement, 287 ) 
                    setPlayerNametagColor ( hitElement, 0, 204, 0 ) 
                    outputChatBox ( "New member in Military team", hitElement, 0, 255, 255 ) 
                elseif ( player == marker5 ) or ( source == marker6 then 
                    setElementPosition( hitElement, 227.69,1921.02,17.5 ) 
                    setPlayerTeam ( player, Army ) 
                    setPedArmor ( player, 60 ) 
                    setElementModel( player, 179 ) 
                    setPlayerNametagColor ( player, 59, 166, 109 ) 
                    outputChatBox ( "New member in Army team", player, 0, 255, 255 ) 
                end 
            end 
        end 
    end 
end 

Link to comment
marker1 = createMarker (-1616.25,684.86,6.18,"cylinder",1.5,0,60,200,100) 
marker2 = createMarker (-1569.64,670.04,6.18,"cylinder",1.5,0,60,200,100) 
marker3 = createMarker (-1296,442.03,6.18,"cylinder",1.5,0,60,200,100) 
marker4 = createMarker (-1539.93,484.16,6.17,"cylinder",1.5,0,60,200,100) 
marker5 = createMarker (227.69,1921.02,16.5,"cylinder",1.5,0,60,200,100) 
marker6 = createMarker (-72.36,2048.72,17.40,"cylinder",1.5,0,60,200,100) 
Blip1 = createBlip (-1616.25,684.86,6.18,59,2,255,0,0,255) 
Blip2 = createBlip (-1569.64,670.04,6.18,59,2,255,0,0,255) 
Blip3 = createBlip (-1296,442.03,6.18, 59,2,255,0,0,255) 
Blip4 = createBlip (-1539.93,484.16,6.17,59,2,255,0,0,255) 
Blip5 = createBlip (227.69,1921.02,16.5,59,2,255,0,0,255) 
Blip6 = createBlip (-72.36,2048.72,17.40,59,2,255,0,0,255) 
Staff = createTeam ( "Staff", 255, 128, 0 ) 
SWAT = createTeam ( "SWAT", 100, 100, 100 ) 
Military = createTeam ( "Military", 0, 204, 0 ) 
Army = createTeam ( "Army", 59, 166, 109 ) 
   
addEventHandler( "onMarkerHit", root, 
    function ( hitElement ) 
        if getElementType( hitElement ) == "player" then 
            if not isPlayerInVehicle( hitElement ) then 
                if ( source == marker1 ) or ( source == marker2 ) then 
                    setPlayerTeam ( hitElement, SWAT ) 
                    setPedArmor ( hitElement, 50 ) 
                    setElementModel( hitElement, 285 ) 
                    setPlayerNametagColor ( hitElement, 100, 100, 100 ) 
                    outputChatBox ( "New member in SWAT team", hitElement, 0, 255, 255 ) 
                    setElementPosition( hitElement, -1616.25,684.86,7.18 ) 
                elseif ( source == marker3 ) or ( source == marker4 ) then 
                    setElementPosition( hitElement, -1296,442.03,7.18 ) 
                    setPlayerTeam ( hitElement, Military ) 
                    setPedArmor ( hitElement, 60 ) 
                    setElementModel( hitElement, 287 ) 
                    setPlayerNametagColor ( hitElement, 0, 204, 0 ) 
                    outputChatBox ( "New member in Military team", hitElement, 0, 255, 255 ) 
                    elseif ( player == marker5 ) or ( source == marker6 )then 
                    setElementPosition( hitElement, 227.69,1921.02,17.5 ) 
                    setPlayerTeam ( player, Army ) 
                    setPedArmor ( player, 60 ) 
                    setElementModel( player, 179 ) 
                    setPlayerNametagColor ( player, 59, 166, 109 ) 
                    outputChatBox ( "New member in Army team", player, 0, 255, 255 ) 
                end 
            end 
        end 
    end) 

Link to comment

I talked with a friend and it was just that easy to do:

function spawninSWAT (player, OnPlayerMarkerHit ) 
if isPedInVehicle(player) then return end 
 setPlayerTeam ( player, SWAT ) 
   setPedArmor ( player, 50 ) 
   setElementModel( player, 285 ) 
   setPlayerNametagColor ( player, 100, 100, 100 ) 
        outputChatBox ( "New member in SWAT team", source, 0, 255, 255 ) 
end 
addEvent("setSWAT", true) 
addEventHandler ( "onMarkerHit", marker1, spawninSWAT ) 
addEventHandler ( "onMarkerHit", marker2, spawninSWAT ) 
  

But thx anyway guys :)

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