AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HL] How to write a plugin that will... (https://forums.alliedmods.net/showthread.php?t=118184)

nakash 02-08-2010 12:58

[HL] How to write a plugin that will...
 
I need a plugin that when I type !rr it will restart the server [sv_restart 1]
and when I type !slay PARTOFNAME/NAME it will kill the player. I think I can do the rest.
[I know that I need to use Handle_Say]

drekes 02-09-2010 07:00

Re: [HL] How to write a plugin that will...
 
restart thing
Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say !rr", "restart")
}

public restart()
{
    server_cmd("sv_restart 1")
}


Arkshine 02-09-2010 07:04

Re: [HL] How to write a plugin that will...
 
You say it's for HL, but sv_restart doesn't exist for HL. Oo

nakash 02-09-2010 07:36

Re: [HL] How to write a plugin that will...
 
Quote:

Originally Posted by Arkshine (Post 1083525)
You say it's for HL, but sv_restart doesn't exist for HL. Oo

eh hehe,I didn't know.
I needed this for counter strike 1.6 [It's based on HL]
thank you for giving me the code !!

How to make the !slay? I don't know how to get a players name.

minimiller 02-09-2010 08:49

Re: [HL] How to write a plugin that will...
 
PHP Code:

new szName[33];
get_user_name(idszName32);
new 
iPlayer find_player("b"szName);
slay(iPlayer); 

should work

nakash 02-09-2010 10:05

Re: [HL] How to write a plugin that will...
 
Quote:

Originally Posted by minimiller (Post 1083582)
PHP Code:

new szName[33];
get_user_name(idszName32);
new 
iPlayer find_player("b"szName);
slay(iPlayer); 

should work

It gives me an error: undefinded symbol "slay".

another problem that I have is when someone types !rr it prints the name of the server and not the player who wrote !rr,is there a way to fix that?
PHP Code:

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Restart
    
register_clcmd("say !rr""cmdrr")
}

public  
cmdrr(pid,level,id,cid)
{
    if(!
cmd_access (pid,level,cid,1)) return PLUGIN_HANDLED
    
new szName33 ];
    
get_user_namecid szName charsmaxszName ) );
    
client_print(0,print_chat,"%s has restarted the round.",szName)
    
server_cmd("sv_restart 1")
    return 
0;



minimiller 02-09-2010 11:00

Re: [HL] How to write a plugin that will...
 
there isnt a slay function, that should of been commented just to show where to slay the player

and with your 2nd problem, change "get_user_name(cid, name, 32)" to "get_user_name(pid, name, 32)"

Mxnn 02-09-2010 14:45

Re: [HL] How to write a plugin that will...
 
Quote:

Originally Posted by minimiller (Post 1083582)
PHP Code:

new szName[33];
get_user_name(idszName32);
new 
iPlayer find_player("b"szName);
slay(iPlayer); 

should work

PHP Code:

slay(iPlayer

To
PHP Code:

user_kill(iPlayer


AfteR. 02-09-2010 20:04

Re: [HL] How to write a plugin that will...
 
Quote:

Originally Posted by nakash (Post 1083622)
It gives me an error: undefinded symbol "slay".

another problem that I have is when someone types !rr it prints the name of the server and not the player who wrote !rr,is there a way to fix that?
PHP Code:

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Restart
    
register_clcmd("say !rr""cmdrr")
}

public  
cmdrr(pid,level,id,cid)
{
    if(!
cmd_access (pid,level,cid,1)) return PLUGIN_HANDLED
    
new szName33 ];
    
get_user_namecid szName charsmaxszName ) );
    
client_print(0,print_chat,"%s has restarted the round.",szName)
    
server_cmd("sv_restart 1")
    return 
0;




PHP Code:

#include <amxmodx>

#define PLUGIN "Restart in chat"
#define VERSION "1.0"
#define AUTHOR "AfteR ;)"

const FLAG ADMIN_CHAT

public plugin_init( ) 
{
    
register_pluginPLUGIN VERSION AUTHOR )
    
register_clcmd"say !rr" "rr" )
}

public 
rrid )
{
    if (
get_user_flagsid ) & FLAG)
    {
        new 
name[32]
        
get_user_nameid name charsmax(name) )
        
server_cmd"sv_restart 1" )
        
client_printprint_chat "%s has restarted the round"name )
    }



nakash 02-10-2010 07:20

Re: [HL] How to write a plugin that will...
 
Thank you! works perfectly.
I still need the slay thing,can somebody help me?


All times are GMT -4. The time now is 07:16.

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