Price. Posted July 18, 2016 Share Posted July 18, 2016 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
Captain Cody Posted July 19, 2016 Share Posted July 19, 2016 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
Walid Posted July 19, 2016 Share Posted July 19, 2016 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). 2) And here you are checking if it's a guest account ??? it should be "if not isGuestAccount" . Link to comment
Captain Cody Posted July 19, 2016 Share Posted July 19, 2016 I wrote that at 12 PM forgive me. Link to comment
Price. Posted July 19, 2016 Author Share Posted July 19, 2016 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
Walid Posted July 19, 2016 Share Posted July 19, 2016 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
Price. Posted July 19, 2016 Author Share Posted July 19, 2016 when I get outside the col shape it refuses to get me inside again using that command Link to comment
Walid Posted July 20, 2016 Share Posted July 20, 2016 when I get outside the col shape it refuses to get me inside again using that command any solution? All what you need is: isElementWithinColShape () if the player is inside the colshape then return end that's all. Link to comment
Price. Posted July 20, 2016 Author Share Posted July 20, 2016 Thanks, its working perfectly now! Link to comment
Walid Posted July 20, 2016 Share Posted July 20, 2016 Thanks, its working perfectly now! Np Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now