-- name: No BLJs -- description: Edit of Sunk's 'BLJ Anywhere' .lua script to have the exact opposite effect and prevent BLJs altogether. local cmdName = "no-blj" local cmdPrefix = "\\#3B80F7\\No BLJs: \\#ffffff\\" local cmdNameStyled = "\\#EBDD1E\\/"..cmdName.."\\#ffffff\\" local onTxt = "\\#22E02E\\on\\#ffffff\\" local offTxt = "\\#E63929\\off\\#ffffff\\" local helpTxt = "["..onTxt.."|"..offTxt.."] turn "..cmdNameStyled.." "..onTxt.." or "..offTxt.."" local function get_state_as_text(overrideState) local checkVal = false if(overrideState~=nil)then checkVal = overrideState else checkVal = gGlobalSyncTable.bljDisabled end if(checkVal)then return onTxt else return offTxt end end local function packet_receive_process(packet) if(packet.sig=="alert_bljDisabled")then djui_chat_message_create(""..cmdPrefix..""..cmdNameStyled.." is now "..get_state_as_text(packet.immediateState).."!") end end local function no_blj_command(msg) if(msg=="on" or msg=="off") then if(msg=="on") then gGlobalSyncTable.bljDisabled = true else gGlobalSyncTable.bljDisabled = false end -- using the concept of immediateState in the case that the packet receiver has not yet received the packet of the gGlobalSyncTable.bljDisabled state changing -- i don't know if this is actually ever possible by this point (should be since its async right?) but if it truly isn't possible then please reach out to me -- so i can remove immediateState local packet = {sig="alert_bljDisabled", immediateState=gGlobalSyncTable.bljDisabled} network_send(true,packet) packet_receive_process(packet) -- the sender of a packet does not receive the packets they send, so a response must be faked, but if one has a packet receive hook then it is as trivial as calling the method associated with that hook ASAP else djui_chat_message_create(""..cmdPrefix..""..helpTxt.." (Current Value: "..get_state_as_text(nil)..")") end end local function blj_preventor(m) if ((m.action == ACT_LONG_JUMP or m.action == ACT_LONG_JUMP_LAND or m.action == ACT_LONG_JUMP_LAND_STOP) and m.forwardVel < -15 and gGlobalSyncTable.bljDisabled==true) then m.forwardVel = -15; end end -- could technically just check the first index i'd imagine but i'd rather be safe than sure with the limited documentation local function nobody_connected() for i=0,(MAX_PLAYERS-1) do if(gNetworkPlayers[i].connected==true)then return false end end return true end -- since this code is outside any function and therefore only executed when the .lua file loads, -- this check can ONLY be true when the server begins -- this can also therefore be used to deremine the host since NPT_LOCAL is given as the player type on the -- host despite being NPT_HOST in reality if(nobody_connected())then gGlobalSyncTable.bljDisabled=true hook_chat_command(cmdName, helpTxt, no_blj_command) end hook_event(HOOK_BEFORE_MARIO_UPDATE, blj_preventor) hook_event(HOOK_ON_PACKET_RECEIVE,packet_receive_process)