AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Simple Player Teleport (GoTo) (https://forums.alliedmods.net/showthread.php?t=222442)

htcarnage 08-02-2013 15:59

Simple Player Teleport (GoTo)
 
10 Attachment(s)
Description:
This plugin provides a convenient way for players to teleport to one another. When a teleport request is made, a menu is displayed to the target player that will allow them to:

Accept
Deny
Block the individual player
Block ALL players
Accept all future requests


After a request is made, a client enters a cool down period in which they can not request any more teleports until the period has passed.

The plugin makes use of admin overrides that will allow admins with a certain flags to bypass client authorization and bypass the cool down period. Admins are able to forcefully bring a player to them, and players can teleport themselves back to their previous location.

As of version 1.3.6, admins with ADMFLAG_KICK authorization can ban players from making goto requests.

How is this different from other teleport plugins?
This plugin offers simple teleport access for non-admins, and also implements an authorization system to prevent unwanted teleports. Has translation support. Allows admins to ban players from using the plugin.

Requirements:
SDKTools
A noblock plugin of your choice



PLAYER COMMANDS:
sm_goto <player>
sm_unblock <player|all>
sm_tpb
sm_goback

ADMIN COMMANDS:
By default, these commands are tied to ADMFLAG_KICK.
sm_bring <player>
sm_goto_ban <player>
sm_goto_unban <player>
sm_goto_listbans



Database Setup
GoTo bans are stored using SQLITE.
Add the following to addons/sourcemod/configs/databases.cfg
Code:

        "goto_bans"
        {
                "driver"                        "sqlite"
                "host"                                "localhost"
                "database"                        "goto_bans"
        }



CVars:
gt_cooldowntime 60.0 ||| Time between a player's use of the goto command.
gt_target_opposite_team 1 ||| Allow clients to target players of the opposite team.
gt_teleport_back_limit 0 ||| Prevent users from teleporting back to their saved location multiple times.

The plugin auto-creates a config in cfg/sourcemod/goto.cfg with the above cvars for easy access.



This plugin uses Sourcemod's built in admin override system to change command access:

How to change command access:
Example addons/sourcemod/configs/admin_overrides.cfg
Code:

Overrides
{
    "sm_goto_cooldown_bypass"    "c"
    "sm_goto_auth_bypass"        "z"
    "sm_tpb"                ""
    "sm_goback"            ""
    "sm_bring"                ""
    "sm_goto"                ""
}

The above would restrict the cooldown period bypass to admins with "c" flag, and would allow admins with "z" flag to bypass authorization completely. All other commands would be available to regular players. To restrict them, simply add a flag between the quotes.


Changelog:
Spoiler

Credits:
johan123jo for helping me with the teleport authorization menu
11530 for his advice on code cleanup

Servers using this plugin


766

captaindeterprimary 08-02-2013 17:42

Re: Simple GoTo Command
 
Could be useful as a achevment server command.

MrSkullbeef 08-03-2013 17:24

Re: Simple GoTo Command
 
This is awesome.

Any chance you could implement an option to block a user from requesting teleports to you? Preferably in the accept/deny menu as a third option.

EDIT: Would also be great if you could add an option to teleport a user to yourself instead of only vice versa.

htcarnage 08-03-2013 18:35

Re: Simple GoTo Command
 
Sure ill work on those suggestions

htcarnage 08-03-2013 21:37

Re: Simple GoTo Command
 
Updated with MORE FEATURES!

Check OP

htcarnage 08-04-2013 14:12

Re: Simple GoTo Command
 
1.2.0 Released. See changelog.
1.3.0: Added teleport back commands

htcarnage 08-05-2013 16:54

Re: Simple GoTo Command
 
Updated. See changelog.

11530 08-06-2013 06:38

Re: Simple GoTo Command
 
Looking through this plugin, there are a few things you'd need to update:
  • Remove the ConVars which define flags and code employing GetUserFlagBits etc. in favor of overrides. That is what the system is there for.
  • Your IsClientInGame check upon client disconnect should not be required and the checks for certain values are not needed either. Just set to false and 0 regardless of what the values may be. With the exception of the ClearTimer - you'd still need to check the handle is valid first, as you already do.
  • Handle RCON within your commands appropriately.
  • new numargs = GetCmdArgs(); is not needed when the args parameter already holds the same value.
  • You can simplify !(PlayerStatus[player] == DenyAll) to !=
  • Use GetConVarInt instead of GetConVarFloat for your cooldown. Anything more specific than an integer will not be used anyway.
  • A string of length 255 is not needed to hold an integer, nor should Format be used on this asker variable. Using StringToInt on a string of size 12 should be sufficient. Additionally, convert it to a UserID in case the client disconnects before the callback is fired.
  • You do not use the name variable at all in your asker callback.
  • As a minor matter of style, do not use Timer as your parameter name in ClearTimer as this is a SourceMod funcenum.
  • It'd be more efficient to store GetTime() rather than start timers for each client's cooldown.
  • In your ResetCooldown (see above) change client < MaxClients to client <= MaxClients, or preferably leave it out entirely.

htcarnage 08-06-2013 13:06

Re: Simple GoTo Command
 
1 Attachment(s)
Ok, I think I've addressed all of the above except a couple I need clarification on.

Also, I am using the system of GetUserFlagBits as opposed to the override system because I intended the plugin to be used for regular non-admin players. However, I still want admins to be able to use the plugin a little more efficiently. The override system would effectively make the plugin admin-only, or completely open for use by all players. Using the GetUserFlagBits system I can access the middle ground where normal players can use the plugin, and admins can access it a bit more efficiently.

For clarification on some of your suggestions, I am not sure how to implement the GetTime() over using timers for each client.

When you recommended using StringToInt on the asker, I assume you meant IntToString?

Thanks for the feedback by the way :)

11530 08-06-2013 17:47

Re: Simple GoTo Command
 
You could still use the override system. Just set the general commands to public by default, and employ two overrides such as sm_goto_cooldown and sm_goto_auth which are set to ADMFLAG_KICK and ADMFLAG_ROOT respectively and the server operator can easily override that should the need arise. You'd check whether the client has the privileges necessary using CheckCommandAccess then taking the necessary steps should they have one or both of the overrides.

As for the cooldown, a simple implementation would look like this, though personally I prefer global variables over GetConVarInts etc.

PHP Code:

new g_iLastUsed[MAXPLAYERS+1];

public 
OnClientPutInServer(client)
{
    
g_iLastUsed[client] = 0;
}

SomeFunction()
{
    new 
iNow GetTime(), iTimeLeft = (g_iLastUsed[client] + GetConVarInt(CooldownTime) - iNow);
    if (
iTimeLeft 0)
    {
        
PrintToChat(client"You must wait another %d second(s)."iTimeLeft);
        return 
Plugin_Handled;
    }
    
g_iLastUsed[client] = iNow;
    
//...


And yes, IntToString. :)


All times are GMT -4. The time now is 05:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.