Advertisement
Guest User

Single Player Mode

a guest
Oct 14th, 2022
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. require("pack")
  2.  
  3. sp = {
  4.     state=true,
  5.     allow_party_members=true
  6. }
  7. sp.state = true
  8.  
  9. windower.raw_register_event('incoming chunk', function (id, original, modified, injected, blocked)
  10.     if sp.state and (id == 0x00D or id == 0x00E) then
  11.         local player_id = modified:unpack('I',5)
  12.         if player_id == player.id then return end
  13.         local in_party = false
  14.         for i,v in pairs(alliance[1]) do
  15.             if type(i) == 'number' and i >= 1 and i <= 6 and v.mob and v.mob.id == player_id then
  16.                 in_party = true
  17.             end
  18.         end
  19.         if in_party and sp.allow_party_members then
  20.         elseif in_party and not sp.allow_party_members or -- party members blocked
  21.                 not in_party and id == 0x00D then -- player not in your party
  22.             local current_value = string.byte(string.sub(modified,0x23,0x23))
  23.             local new_value = current_value % 8 + math.floor(current_value / 16)*16 + 8
  24.  
  25.             return string.sub(modified,1,0x22)..string.char(new_value)..string.sub(modified,0x24)
  26.         end
  27.     end
  28. end)
  29.  
  30. register_unhandled_command(function (...)
  31.     local commands = split((...)," ")
  32.     if commands[1] and commands[1] == 'sp' then
  33.         if commands[2] and (commands[2] == 'on' or commands[2] == 'true') then
  34.             sp.state = true
  35.         elseif commands[2] and (commands[2] == 'off' or commands[2] == 'false') then
  36.             sp.state = false
  37.         else
  38.             sp.state = not sp.state
  39.         end
  40.         print("single_player : "..tostring(sp.state))
  41.         return true
  42.     end
  43. end)
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement