Loading...   

  • This is an example of messing with the lockpick value of a door

Note:
In the case of the player.lua and the door objects, the quest script happens prior to the server processing the client click action.
Using the example below, this means if you click on an unlocked door, this code will lock the door BEFORE the server checks your click action.

  1. The client clicks on an unlocked door
  2. The client will receive the message 
    You clicked on door: 1
  3. The client will receive the message
    GetLockPick was: 0
  4. The script will set the lockpick value of the door to -1
  5. The client will receive the message
    GetLockPick is now: 65535
    (Yes this is a display bug)
  6. The client will receive the standard locked message from the server.
    1. If the client is not a GM, the door will be locked and not open.
    2. If the client is a GM, they will recevie the text about opening the door with their magical key and the door will open.

 

-- player.lua example of access and changing the lockpick value of a door.
function event_click_door(e)
    -- dump the door id into a local variable
    local door_id = e.door:GetDoorID();
    -- get the entity list and drop it in a local variable
    local entity_list = eq.get_entity_list();
    -- Give the player a message showing them the ID of the door clicked on
    e.self:Message(15,"You clicked on door: " .. door_id);
    -- find the door object and drop it into a local variable
    local door = entity_list:FindDoor(door_id);
    -- give the player a message on the lockpick value of the door
    e.self:Message(15,"GetLockPick was: " .. door:GetLockPick());
    -- check if the door's lockpick value is 0
    if (door:GetLockPick() == 0) then
        -- if the value was zero, set it to -1. This makes the door become locked and be unpickable
        door:SetLockPick(-1);
    else
        -- if the value was not zero, set it to 0. This makes the door no longer be locked.
        door:SetLockPick(0);
    end
    -- give the player a message with the door's new lockpick value.
    e.self:Message(15,"GetLockPick is now: " .. door:GetLockPick());
end