Raised This Month: $ Target: $400
 0% 

[USEFUL] Function list (update)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-10-2007 , 15:49   Re: [USEFUL] Function list (update)
Reply With Quote #18

I just pasted the code from my namechanger plugin into it, so:

PHP Code:
/**
* namechanger.sp by bl4nk
* Allows an admin with the 'f' flag to change a player's name.
*
* Thanks to:
*   Extreme_One for requesting the plugin.
*   ferret for his easy-to-copy "client checker" code.
*   theY4Kman for a fix with the single quote bug.
*
* Changelog at http://forums.alliedmods.net/showthread.php?t=58825
*/

#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION "1.2"

public Plugin:myinfo 
{
    
name "Name Changer",
    
author "bl4nk",
    
description "Change the name of a player",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net"
};

public 
OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
LoadTranslations("namechanger.phrases");
    
    
CreateConVar("sm_namechanger_version"PLUGIN_VERSION"Name Changer Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
RegAdminCmd("sm_name"Command_NameADMFLAG_SLAY"sm_name <user> <name>");
}

public 
Action:Command_Name(clientargs)
{

    if (
args 2)
    {
        
ReplyToCommand(client"[SM] Usage: sm_name <user> <name>");
        return 
Plugin_Handled;
    }

    new 
String:target[64];
    
GetCmdArg(1targetsizeof(target));

    new 
String:name[64];
    
GetCmdArg(2namesizeof(name));

    
ReplaceString(namesizeof(name), " ' ""'");

    new 
clients[2];
    new 
numClients SearchForClients(targetclients2);
    
    if (
numClients == 0)
    {
        
ReplyToCommand(client"[SM] %t""No matching client");
        return 
Plugin_Handled;
    }
    else if (
numClients 1)
    {
        
ReplyToCommand(client"[SM] %t""More than one client matches");
        return 
Plugin_Handled;
    }
    else if (!
CanUserTarget(clientclients[0]))
    {
        
ReplyToCommand(client"[SM] %t""Unable to target");
        return 
Plugin_Handled;
    }
    else if (
IsFakeClient(clients[0]))
    {
        
ReplyToCommand(client"[SM] %t""Cannot target bot");
        return 
Plugin_Handled;
    }

    new 
player clients[0];

    
PrintToChat(player"[SM] %t""Name Changed");
    
ClientCommand(player"name \"%s\""name);

    return 
Plugin_Handled;

bl4nk is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:55.


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