Hello, this code will let the sender of the TP request to cancel but not the receiver, is there a way to I can cancel both ways ??
This bit of code goes inside of the plugin m-Teleportation
Also BTW, I don't code, This was me just messing around of Lua
Code:function PLUGIN: cmdTeleportCancel( player, cmd, args ) local playerID = rust.UserIDFromPlayer( player ) -- Check if the player has any pending requests. if PendingRequests[playerID] then -- The player has a pending request, send a message to the player that -- send this request, kill the timer and remove the data. -- Grab the target player and his/her Steam ID. local originPlayer = PlayersRequests[playerID] local originPlayerID = rust.UserIDFromPlayer( originPlayer ) -- Send a message to the self:SendMessage( originPlayer, "The Currnent TP has canceled" ) self:SendMessage( player, "You have canceled the TP" ) -- Destroy the timer and remove the table entries. PendingRequests[playerID]:Destroy() PendingRequests[playerID] = nil PlayersRequests[playerID] = nil PlayersRequests[originPlayerID] = nil if TeleportTimers[PlayerID] then TeleportTimers[originPlayerID].timer:Destroy() TeleportTimers[originPlayerID] = nil self:SendMessage( originPlayer, "The Currnent TP has canceled" ) self:SendMessage( player, "You have canceled the TP" ) end end -- Check if the player has a teleport in progress. if TeleportTimers[playerID] then -- The player is about to be teleported, cancel the teleport and remove -- the table entry. local originPlayer = PlayersRequests[playerID] TeleportTimers[playerID].timer:Destroy() TeleportTimers[playerID] = nil self:SendMessage( originPlayer, "The Currnent TP has canceled" ) self:SendMessage( player, "You have canceled the TP" ) end end
Need help fixing my TP cancel code
Discussion in 'Rust Development' started by MisterPixie, Apr 6, 2016.
-
great idea !
-
There might be a easier way to do this and plus I dont code in lua. But you could create like a temp data thing that stores both players once a tp is sent, and when it gets canceled just remove both players from the dictionary so when a player does /tpa or whatever that command is it says he cant accept it.
[DOUBLEPOST=1459989555][/DOUBLEPOST]You could also possibly override this function :
[DOUBLEPOST=1459989671][/DOUBLEPOST]And or use this "plugins.CallHook( "CanTeleport", arr )" to override it.Code:function PLUGIN:CanPlayerTeleport( player ) local arr = util.TableToArray( { player } ) util.ConvertAndSetOnArray( arr, 0, player, UnityEngine.Object._type ) local _return = plugins.CallHook( "CanTeleport", arr ) if not _return then return true end return false, tostring( _return ) end

