Raised This Month: $ Target: $400
 0% 

Name randomizer for tf2 servers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeadBoom
Member
Join Date: Sep 2014
Old 01-15-2015 , 05:23   Name randomizer for tf2 servers
Reply With Quote #1

So basically what happens is that you type a command like /nrandom and it comes up in a little tab with a random person's name on the server, this would be good for server raffles and server giveaways, thanks
DeadBoom is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 01-15-2015 , 05:59   Re: Name randomizer for tf2 servers
Reply With Quote #2

PHP Code:
#include <sourcemod>

public OnPluginStart()
{
    
RegConsoleCmd("sm_nrandom"Command_Random);
}

public 
Action:Command_Random(clientargs)
{
    
decl playerarray[MAXPLAYERS+1];
    new 
playercount;
    
    for(new 
player 1player <= MaxClientsplayer++)
    {
        if(
player != client && player && player <= MaxClients && IsClientConnected(player) && IsClientInGame(player))
        {
            
playerarray[playercount] = player;
            
playercount++;
        }
    }
    
    if(
playercount)
    {
        new 
target playerarray[GetRandomInt(0playercount-1)];
        
PrintToChatAll("[RANDOM] %N was selected at random!"target);
        
        
decl String:name[MAX_NAME_LENGTH];
        
GetClientName(targetnamesizeof(name));
        
        for(new 
player 1player <= MaxClientsplayer++)
        {
            if(
player && player <= MaxClients && IsClientConnected(player) && IsClientInGame(player))
            {
                new 
Handle:menu CreateMenu(Menu_Nothing);
                
SetMenuTitle(menu"The lucky random guy is:");
                
AddMenuItem(menu"1"nameITEMDRAW_DISABLED);
                
                
SetMenuExitButton(menutrue);
                
DisplayMenu(menuplayer60);
            }
        }
    }
    else
        
PrintToChat(client"[RANDOM] It seems that you are the only person on the server.");
    
    return 
Plugin_Handled;
}

public 
Menu_Nothing(Handle:menuMenuAction:actionparam1option)
{
    if(
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }

You can compile it here, i didn't test it but it should work
__________________

Last edited by Pelipoika; 01-15-2015 at 09:34.
Pelipoika is offline
DeadBoom
Member
Join Date: Sep 2014
Old 01-15-2015 , 06:01   Re: Name randomizer for tf2 servers
Reply With Quote #3

Quote:
Originally Posted by Pelipoika View Post
PHP Code:
#include <sourcemod>

public OnPluginStart()
{
    
RegConsoleCmd("sm_nrandom"Command_Random"Pet test");
}

public 
Action:Command_Random(clientargs)
{
    
decl playerarray[MAXPLAYERS+1];
    new 
playercount;
    
    for(new 
player 1player <= MaxClientsplayer++)
    {
        if(
player != client && player && player <= MaxClients && IsClientConnected(player) && IsClientInGame(player))
        {
            
playerarray[playercount] = player;
            
playercount++;
        }
    }
    
    if(
playercount)
    {
        new 
target playerarray[GetRandomInt(0playercount-1)];
        
PrintToChatAll("{RANDOM] %N was selected at random!"target);
        
        
decl String:name[MAX_NAME_LENGTH];
        
GetClientName(targetnamesizeof(name));
        
        for(new 
player 1player <= MaxClientsplayer++)
        {
            if(
player != client && player && player <= MaxClients && IsClientConnected(player) && IsClientInGame(player))
            {
                new 
Handle:menu CreateMenu(Menu_Nothing);
                
SetMenuTitle(menu"The lucky random guy is:");
                
AddMenuItem(menu"1"nameITEMDRAW_DISABLED);
                
                
SetMenuExitButton(menutrue);
                
DisplayMenu(menuplayer60);
            }
        }
    }
    else
        
PrintToChat(client"[RANDOM] It seems that you are the only person on the server.");
    
    return 
Plugin_Handled;
}

public 
Menu_Nothing(Handle:menuMenuAction:actionparam1option)
{
    
CloseHandle(menu);

You can compile it here, i didn't test it but it should work
Sorry im kinda noob at this kind of text, i just mainly do editing server files like overrides, and doing .smx and other files not this mumbo jumbo (to me XD). Sorry could you link me to a guide or teach me?
DeadBoom is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 01-15-2015 , 06:04   Re: Name randomizer for tf2 servers
Reply With Quote #4

Quote:
Originally Posted by DeadBoom View Post
Sorry im kinda noob at this kind of text, i just mainly do editing server files like overrides, and doing .smx and other files not this mumbo jumbo (to me XD). Sorry could you link me to a guide or teach me?
Goto the link i posted in my post, paste the code into the big textbox, select some name for the plugin, press compile and then download the compiled plugin from the link that appears somewhere above the box
__________________
Pelipoika is offline
DeadBoom
Member
Join Date: Sep 2014
Old 01-15-2015 , 06:07   Re: Name randomizer for tf2 servers
Reply With Quote #5

Quote:
Originally Posted by Pelipoika View Post
Goto the link i posted in my post, paste the code into the big textbox, select some name for the plugin, press compile and then download the compiled plugin from the link that appears somewhere above the box
If this works would I be able to post this, giving credit for idea to me and giving like all/therest of the credit to you?
DeadBoom is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 01-15-2015 , 06:17   Re: Name randomizer for tf2 servers
Reply With Quote #6

Quote:
Originally Posted by DeadBoom View Post
If this works would I be able to post this, giving credit for idea to me and giving like all/therest of the credit to you?
I dont see any point in that, + i think theres already some raffle plugins
__________________
Pelipoika is offline
DeadBoom
Member
Join Date: Sep 2014
Old 01-15-2015 , 06:18   Re: Name randomizer for tf2 servers
Reply With Quote #7

Quote:
Originally Posted by Pelipoika View Post
I dont see any point in that, + i think theres already some raffle plugins
I found a bug in this, it works like a charm if i type it once, but if i type it again it crashes the server making a connection problem
DeadBoom is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 01-15-2015 , 06:32   Re: Name randomizer for tf2 servers
Reply With Quote #8

Quote:
Originally Posted by DeadBoom View Post
I found a bug in this, it works like a charm if i type it once, but if i type it again it crashes the server making a connection problem
Updated the code in my post, please recompile
__________________
Pelipoika is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-15-2015 , 09:33   Re: Name randomizer for tf2 servers
Reply With Quote #9

Quote:
Originally Posted by DeadBoom View Post
If this works would I be able to post this, giving credit for idea to me and giving like all/therest of the credit to you?
YOu're better off leaving the coder post the thread. Especially since there is a few things missing for it to be considered approved, etc. Plus maintenance is easier when you have access to the first post..
Mitchell is offline
Reply



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 05:14.


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