Jump to content

Output problem


Price.

Recommended Posts

so I'm making a simple command but I guess I complicated it the way I made it, Im making a check if the player is an admin and if he is a player then he setPos to certain location, if he is not then output "you cannot use this command ", and if he is in a vehicle return false with output

outputs are all mixed sometimes and I can't get all to work at the right situation

    function staffcommand (player, command) 
  local account = getPlayerAccount(player) 
  local x, y, z = getElementPosition(player) 
  if account and not isGuestAccount(account) then 
     local accName = getAccountName(account) 
  if  ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then 
    if player and isElement(player) and (getElementType(player) == "player") then 
   setElementPosition ( player, 3749.9094238281, -194.06666564941, 5.3276481628418 ) 
   end 
     else  
 outputChatBox("Only staff can use this command.", player, 255, 0, 0) 
   end 
   end 
    
    if player and isElement(player) and (getElementType(player) == "player") then 
  if (isPedInVehicle(player) and getPedOccupiedVehicle (player)) then 
    return  outputChatBox("You cannot use this command inside a vehicle.", player, 255, 0, 0, true) 
   end 
   end 
   end 
   addCommandHandler("staffland", staffcommand) 

Link to comment
        function staffcommand (player, command) 
        if getElementType(player) == "player" then 
        if (isPedInVehicle(player) and getPedOccupiedVehicle (player)) then 
            return  outputChatBox("You cannot use this command inside a vehicle.", player, 255, 0, 0, true) 
        end 
            local account = getPlayerAccount(player) 
        if isGuestAccount(account) then 
            local accName = getAccountName(account) 
        if  ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then 
            setElementPosition ( player, 3749.9094238281, -194.06666564941, 5.3276481628418 ) 
        else 
            outputChatBox("Only staff can use this command.", player, 255, 0, 0) 
              end 
          end 
      end 
  end 
        
       addCommandHandler("staffland", staffcommand) 

Link to comment

Here is all what you need

function staffcommand (player, command) 
    if player and isElement(player) and getElementType(player) == "player" then  
        if (isPedInVehicle(player) then 
            return  outputChatBox("You cannot use this command inside a vehicle.", player, 255, 0, 0, true) 
        end 
        local account = getPlayerAccount(player) 
            if account and not isGuestAccount(account) then 
                local accName = getAccountName(account) 
                if  ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then 
                    setElementPosition ( player, 3749.9094238281, -194.06666564941, 5.3276481628418 ) 
                else 
                    outputChatBox("Only staff can use this command.", player, 255, 0, 0) 
                end  
            end 
        end 
    end 
end 
addCommandHandler("staffland", staffcommand) 

@CodyL :

1) You already checked if the player is inside a vehicle or not (using isPedInVehicle) so you don't need to use (getPedOccupiedVehicle).

077ef71bf3.png

2) And here you are checking if it's a guest account ??? it should be "if not isGuestAccount" .

895b819c1e.png

Link to comment

alright now I'm trying a last thing but idk what's wrong lel, I'm trying to do if he got to the island using /staffland command then he can no longer use it inside the COLshape of the land, I made the checks and all but I can still teleport when I'm inside

   function staffcommand (player, command) 
  local account = getPlayerAccount(player) 
  local x, y, z = getElementPosition(player) 
  if account and not isGuestAccount(account) then 
     local accName = getAccountName(account) 
  if not (isPedInVehicle(player) and  getPedOccupiedVehicle (player)) then 
  if  ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then 
    if player and isElement(player) and (getElementType(player) == "player") then 
  
   setElementPosition ( player, 3749.9094238281, -194.06666564941, 5.3276481628418 ) 
   end 
      else  
 outputChatBox("Only staff can use this command.", player, 255, 0, 0) 
   end 
   end 
    if player and isElement(player) and (getElementType(player) == "player") then 
  if isPedInVehicle(player) and getPedOccupiedVehicle (player) then 
      outputChatBox("You cannot use this command inside a vehicle.", player, 255, 0, 0, true) 
   end 
   end 
   end 
   end 
if player and isElement(player) and (getElementType(player) == "player") then 
   local account = getPlayerAccount(player) 
  local x, y, z = getElementPosition(player) 
  if account and not isGuestAccount(account) then 
     local accName = getAccountName(account) 
   local detection = isElementWithinColShape ( player, islandCOL ) 
    if  ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then 
 local detection = detection and getElementDimension( player ) == getElementDimension( islandCOL ) 
if  isElementWithinColShape ( player, islandCOL ) == true then 
    removeCommandHandler ( "staffland" ) 
 outputChatBox("You are already in the staff island.", player, 255, 0, 0, true) 
 end 
 end 
 end 
 end 
   addCommandHandler("staffland", staffcommand) 
   

any help?

Link to comment
local teleported = false 
  
function staffcommand (player, command) 
    if player and isElement(player) and getElementType(player) == "player" then 
        if (isPedInVehicle(player) then 
            return  outputChatBox("You cannot use this command inside a vehicle.", player, 255, 0, 0, true) 
        end 
        if teleported then  
            return  outputChatBox("You can't use this Command when you are inside the land", player, 255, 0, 0, true) 
        end 
        local account = getPlayerAccount(player) 
            if account and not isGuestAccount(account) then 
                local accName = getAccountName(account) 
                if  ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then 
                    setElementPosition ( player, 3749.9094238281, -194.06666564941, 5.3276481628418 ) 
                    teleported = true 
                else 
                    outputChatBox("Only staff can use this command.", player, 255, 0, 0) 
                end 
            end 
        end 
    end 
end 
addCommandHandler("staffland", staffcommand) 
  

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