Jump to content

Problem in the code


sckatchof

Recommended Posts

hello,

why this code does not work !

WARNIG: TNS/Police/gate.lua:5: bad 'player' pointer @ 'getplayerteam'<1> 
WARNIG: TNS/Police/gate.lua:11: bad argument @ ''getplayerteam' 

local MarkerPolice = createMarker( 1588.4000244141, -1637, 11.39999961853, 'corona', 12.0, 0, 0, 255, 0) 
local Policegate1 = createObject(980, 1590.1999511719, -1638.4000244141, 15.199999809265, 0, 0, 0) 
  
function MarkerHit1 ( hitElement, matchingDimension ) 
    if ( getPlayerTeam(hitElement) and getPlayerTeam(hitElement) == getTeamFromName("Police") ) then 
        moveObject(Policegate1, 2000, 1598.1999511719, -1638.4000244141, 15.199999809265 ) 
    end 
end 
  
function MarkerLeave1( leaveElement, matchingDimension ) 
    if ( getPlayerTeam(leaveElement) and getPlayerTeam(leaveElement) == getTeamFromName("Police") ) then 
        moveObject(Policegate1, 2000, 1590.1999511719, -1638.4000244141, 15.199999809265 ) 
    end 
end 
addEventHandler( "onMarkerHit", MarkerPolice, MarkerHit1 ) 
addEventHandler( "onMarkerLeave", MarkerPolice, MarkerLeave1 ) 

Link to comment

First of all, are you sure the script is fixed already? Errors are saying different functions, which are basically already fixed in your script.

However, you had doublecheck on the team section. You don't need to check the team and the name in seperate.

When you check the name, it checks if the player is in the team anyways.

local MarkerPolice = createMarker( 1588.4000244141, -1637, 11.39999961853, 'corona', 12.0, 0, 0, 255, 0) 
local Policegate1 = createObject(980, 1590.1999511719, -1638.4000244141, 15.199999809265, 0, 0, 0) 
  
function MarkerHit1(hitElement, matchingDimension) 
    if getElementType(hitElement) == "player" then 
        if (getPlayerTeam(hitElement) == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1598.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
end 
  
function MarkerLeave1(leaveElement, matchingDimension) 
    if getElementType(hitElement) == "player" then 
        if (getPlayerTeam(leaveElement) == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1590.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
end 
addEventHandler("onMarkerHit", MarkerPolice, MarkerHit1) 
addEventHandler("onMarkerLeave", MarkerPolice, MarkerLeave1) 

Link to comment

* line 13 : hitElement should be leaveElement

  
 local MarkerPolice = createMarker( 1588.4000244141, -1637, 11.39999961853, 'corona', 12.0, 0, 0, 255, 0) 
local Policegate1 = createObject(980, 1590.1999511719, -1638.4000244141, 15.199999809265, 0, 0, 0) 
 addCommandHandler("1",function(plr) setElementPosition(plr,1588.4000244141+2, -1637, 11.39999961853 ) end ) 
  
function MarkerHit1(hitElement, matchingDimension) 
    if getElementType(hitElement) == "player" then 
     playerTeam = getPlayerTeam(hitElement) 
    if playerTeam then 
        if (playerTeam == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1598.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
    end 
end 
  
function MarkerLeave1(leaveElement, matchingDimension) 
    if getElementType(leaveElement) == "player" then 
     playerTeam = getPlayerTeam(leaveElement) 
    if playerTeam then 
        if (getPlayerTeam(leaveElement) == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1590.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
    end 
end 
addEventHandler("onMarkerHit", MarkerPolice, MarkerHit1) 
addEventHandler("onMarkerLeave", MarkerPolice, MarkerLeave1) 
  

Link to comment
* line 13 : hitElement should be leaveElement
  
 local MarkerPolice = createMarker( 1588.4000244141, -1637, 11.39999961853, 'corona', 12.0, 0, 0, 255, 0) 
local Policegate1 = createObject(980, 1590.1999511719, -1638.4000244141, 15.199999809265, 0, 0, 0) 
 addCommandHandler("1",function(plr) setElementPosition(plr,1588.4000244141+2, -1637, 11.39999961853 ) end ) 
  
function MarkerHit1(hitElement, matchingDimension) 
    if getElementType(hitElement) == "player" then 
     playerTeam = getPlayerTeam(hitElement) 
    if playerTeam then 
        if (playerTeam == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1598.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
    end 
end 
  
function MarkerLeave1(leaveElement, matchingDimension) 
    if getElementType(leaveElement) == "player" then 
     playerTeam = getPlayerTeam(leaveElement) 
    if playerTeam then 
        if (getPlayerTeam(leaveElement) == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1590.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
    end 
end 
addEventHandler("onMarkerHit", MarkerPolice, MarkerHit1) 
addEventHandler("onMarkerLeave", MarkerPolice, MarkerLeave1) 
  

thanksss it's work :)

Link to comment
  • 3 months later...
* line 13 : hitElement should be leaveElement
  
 local MarkerPolice = createMarker( 1588.4000244141, -1637, 11.39999961853, 'corona', 12.0, 0, 0, 255, 0) 
local Policegate1 = createObject(980, 1590.1999511719, -1638.4000244141, 15.199999809265, 0, 0, 0) 
 addCommandHandler("1",function(plr) setElementPosition(plr,1588.4000244141+2, -1637, 11.39999961853 ) end ) 
  
function MarkerHit1(hitElement, matchingDimension) 
    if getElementType(hitElement) == "player" then 
     playerTeam = getPlayerTeam(hitElement) 
    if playerTeam then 
        if (playerTeam == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1598.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
    end 
end 
  
function MarkerLeave1(leaveElement, matchingDimension) 
    if getElementType(leaveElement) == "player" then 
     playerTeam = getPlayerTeam(leaveElement) 
    if playerTeam then 
        if (getPlayerTeam(leaveElement) == getTeamFromName("Police")) then 
            moveObject(Policegate1, 2000, 1590.1999511719, -1638.4000244141, 15.199999809265) 
        end 
    end 
    end 
end 
addEventHandler("onMarkerHit", MarkerPolice, MarkerHit1) 
addEventHandler("onMarkerLeave", MarkerPolice, MarkerLeave1) 
  

thanksss it's work :)

Lol i find the same problem with the same script,

I had a topic on here opened today :shock::lol:

https://forum.multitheftauto.com/viewtopic.php?f=91&t=41715

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