Jump to content

Whats wrong with this ?


tim260

Recommended Posts

can somebody say whats wrong with this ?

local militaryMarker = createMarker(1552.33, -1605.37, 12.5, 'cylinder', 2.0, 0, 0, 255, 150 ) 
        local account = getAccountName(getPlayerAccount(player)) 
function militaryMarkerHit ( hitElement, matchingDimension ) 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Military")) then 
            setElementModel(player, 286) 
            giveWeapon ( player, 31, 80000 ) 
            outputChatBox("You are now working as military", player, 0, 255, 0, false) 
            else 
            outputChatBox("You must be in the military group to use this command!", player, 255, 0, 0, false) 
        end 
    end 
  
addEventHandler( "onMarkerHit", militaryMarker , militaryMarkerHit ) 

Ps: i get an error when walking in to the marker

Link to comment
local militaryMarker = createMarker(1552.33, -1605.37, 12.5, 'cylinder', 2.0, 0, 0, 255, 150 ) 
function militaryMarkerHit ( player, matchingDimension ) 
if ( getElementType(player) == "player") then 
        local account = getAccountName(getPlayerAccount(player)) 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Military")) then 
            setElementModel(player, 286) 
            giveWeapon ( player, 31, 80000 ) 
            outputChatBox("You are now working as military", player, 0, 255, 0, false) 
            else 
            outputChatBox("You must be in the military group to use this command!", player, 255, 0, 0, false) 
        end 
    end 
end 
addEventHandler( "onMarkerHit", militaryMarker , militaryMarkerHit ) 

Link to comment
local militaryMarker = createMarker(1552.33, -1605.37, 12.5, 'cylinder', 2.0, 0, 0, 255, 150 ) 
function militaryMarkerHit ( player, matchingDimension ) 
if ( getElementType(player) == "player") then 
        local account = getAccountName(getPlayerAccount(player)) 
        if isObjectInACLGroup("user." .. account, aclGetGroup("Military")) then 
            setElementModel(player, 286) 
            giveWeapon ( player, 31, 80000 ) 
            outputChatBox("You are now working as military", player, 0, 255, 0, false) 
            else 
            outputChatBox("You must be in the military group to use this command!", player, 255, 0, 0, false) 
        end 
    end 
end 
addEventHandler( "onMarkerHit", militaryMarker , militaryMarkerHit ) 

2 errors @ getplayeraccount and @ getaccountname

EDIT : thats only when i start it, when i walk in the marker i get : attempt to concatenate upvalue "account" < a boolean valeu>

Edited by Guest
Link to comment

1. you must get account inside the militaryMarkerHit function

2. "hitElement" is the element that hit the marker. "player" is probably nil.

3. you should check if element is a player and he has an account

local militaryMarker = createMarker(1552.33, -1605.37, 12.5, 'cylinder', 2.0, 0, 0, 255, 150 ) 
  
function militaryMarkerHit(hitElement, matchingDimension) 
  if getElementType(hitElement) == "player" then 
    local account = getAccountName(getPlayerAccount(hitElement)) 
    if account and isObjectInACLGroup("user." .. account, aclGetGroup("Military")) then 
      setElementModel(hitElement, 286) 
      giveWeapon(hitElement, 31, 80000) 
      outputChatBox("You are now working as military", hitElement, 0, 255, 0, false) 
    else 
      outputChatBox("You must be in the military group to use this command!", hitElement, 255, 0, 0, false) 
    end 
  end 
end 
  
addEventHandler("onMarkerHit", militaryMarker, militaryMarkerHit) 

Link to comment
1. you must get account inside the militaryMarkerHit function

2. "hitElement" is the element that hit the marker. "player" is probably nil.

3. you should check if element is a player and he has an account

local militaryMarker = createMarker(1552.33, -1605.37, 12.5, 'cylinder', 2.0, 0, 0, 255, 150 ) 
  
function militaryMarkerHit(hitElement, matchingDimension) 
  if getElementType(hitElement) == "player" then 
    local account = getAccountName(getPlayerAccount(hitElement)) 
    if account and isObjectInACLGroup("user." .. account, aclGetGroup("Military")) then 
      setElementModel(hitElement, 286) 
      giveWeapon(hitElement, 31, 80000) 
      outputChatBox("You are now working as military", hitElement, 0, 255, 0, false) 
    else 
      outputChatBox("You must be in the military group to use this command!", hitElement, 255, 0, 0, false) 
    end 
  end 
end 
  
addEventHandler("onMarkerHit", militaryMarker, militaryMarkerHit) 

Thanks mate it works !

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