Jump to content

More help needed


maky55

Recommended Posts

Hello again :D.

Still newbie at this script thing. In the wiki tutorial, it showed how you can type /createvehicle 456 and it would create that vehicle for you. I've tried to edit this so that only people with Moderator, Super Moderator or Admins can do this, but I'm stuck. This is what i've got so far:

function createVehicleForPlayer(thePlayer, command, vehicleModel) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        if ( isPlayerInGroup ( thePlayer ) ) then 
            local x,y,z = getElementPosition(thePlayer) 
            x = x + 5 
            local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) 
            if (createdVehicle == false) then 
            outputChatBox("Lol. Aint this a bitch? The vehicle isn't there..",thePlayer) 
        end 
    end  
end 
addCommandHandler("createvehicle", createVehicleForPlayer) 
  
function isPlayerInGroup ( thePlayer ) 
    local accountName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) or isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Super Moderator" ) ) or isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Moderator" ) ) ) then 
        return true 
    else 
        return false 
    end 
end 

and this is the debug message it's giving me:

ERROR: Loading script failed: [gameplay]\VehicleSpawn\Script.lua:22: 'end' expected (to close 'function' at line 1) near ''

If someone could explain what the error is telling me that would help :D. Thanks again!

Link to comment
You have a missing end in the "createVehicleForPlayer" function.

I figured out where the missing end was!

  
function createVehicleForPlayer(thePlayer, command, vehicleModel) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        if ( isPlayerInGroup ( thePlayer ) ) then 
            local x,y,z = getElementPosition(thePlayer) 
            x = x + 5 
            local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) 
            if (createdVehicle == false) then 
            outputChatBox("Lol. Aint this a bitch? The vehicle isn't there..",thePlayer) 
            end 
        end  
    end 
end 
addCommandHandler("createvehicle", createVehicleForPlayer) 
  
function isPlayerInGroup ( thePlayer ) 
    local accountName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) or isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Super Moderator" ) ) or isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Moderator" ) ) ) then 
        return true 
    else 
        return false 
    end 
end 
  

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