Raised This Month: $ Target: $400
 0% 

Hook changelevel


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 10-30-2011 , 17:38   Hook changelevel
Reply With Quote #1

Can I hook srvcmd changelevel? Something like:

PHP Code:
register_srvcmd("changelevel""func")
...


public 
func()
{
    
asd=true
    
return PLUGIN_CONTINUE


Last edited by Blue Snake.; 10-30-2011 at 17:38.
Blue Snake. is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-30-2011 , 18:11   Re: Hook changelevel
Reply With Quote #2

What do you want to do inside exactly ?
__________________
Arkshine is offline
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 10-30-2011 , 18:26   Re: Hook changelevel
Reply With Quote #3

I have this for a deathrun server, but when the map change, all players disconnect and if the terrorist disconnect before CTs, the server crash (the plugin will find a CT, but he will be disconnected before the 2 task execute.)
I want to hook changelevel with a bool mapend=true (And add it in the plugin_init 'false') and add

PHP Code:
if(get_pdata_int(idm_iTeam5) == && is_user_alive(id) && !is_user_bot(id) && !mapend
This is the code

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <colorchat>
#include <cstrike>
#include <fun>
#include <hamsandwich>

#define PLUGIN    "Terrorist replace"
#define AUTHOR    "Blue Snake."
#define VERSION    "1.1"

new origin[3]
const 
m_iTeam 114;

public 
plugin_init()
    
register_plugin(PLUGINVERSIONAUTHOR)





public 
client_disconnect(id)
{
    if(
get_pdata_int(idm_iTeam5) == && is_user_alive(id) && !is_user_bot(id))
    {
        
get_user_origin(idorigin)
        new 
teroname[32]
        
get_user_name(idteroname31)
        
        new 
bool:alive=false
        
new players[32], inum
        get_players
(playersinum"bceh","CT")
        if(!
inum)
        {
            
get_players(playersinum"aceh","CT")
            
alive=true
        
}
        new 
newtero=players[random_num(0,inum-1)]
        
        new 
ctname[32]
        
get_user_name(newteroctname31)
        
        
ColorChat(0RED"^x04[Deathrun]^x03 %s^x01 left, ^x04 %s^x01 is the new terrorist.",teronamectname)
        
        if(
alive)
            
user_silentkill(newtero)
        
        
set_task(0.5"func"newtero)
        
set_task(0.8"teleport",newtero)

    }
}

public 
func(newtero)
{
    
    
cs_set_user_team(newteroCS_TEAM_T)
    
ExecuteHamB(Ham_CS_RoundRespawn,newtero)
    
set_task(0.1"strip"newtero)
    
set_task(0.2"item"newtero)
}

public 
strip(newtero)
    
strip_user_weapons(newtero)

    
    
public 
item(newtero)
    
give_item(newtero"weapon_knife")


public 
teleport(newtero)
    
set_user_origin(newteroorigin

Last edited by Blue Snake.; 10-30-2011 at 18:28.
Blue Snake. is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 10-30-2011 , 18:59   Re: Hook changelevel
Reply With Quote #4

You could check if the player is still connected in the 2 tasks
& get a new one if he has disconnected.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 10-31-2011 , 08:39   Re: Hook changelevel
Reply With Quote #5

Something like this? Ok, I'll try.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <colorchat>
#include <cstrike>
#include <fun>
#include <hamsandwich>

#define PLUGIN    "Terrorist replace"
#define AUTHOR    "Blue Snake."
#define VERSION    "1.1"

new origin[3]
const 
m_iTeam 114;

public 
plugin_init()
    
register_plugin(PLUGINVERSIONAUTHOR)





public 
client_disconnect(id)
{
    if(
get_pdata_int(idm_iTeam5) == && is_user_alive(id) && !is_user_bot(id))
    {
        
get_user_origin(idorigin)
        new 
teroname[32]
        
get_user_name(idteroname31)
        
        new 
bool:alive=false
        
new players[32], inum
        get_players
(playersinum"bceh","CT")
        if(!
inum)
        {
            
get_players(playersinum"aceh","CT")
            
alive=true
        
}

        if(!
inum)
            return 
PLUGIN_CONTINUE

        
new newtero=players[random_num(0,inum-1)]
        
        new 
ctname[32]
        
get_user_name(newteroctname31)
        
        
ColorChat(0RED"^x04[Deathrun]^x03 %s^x01 left, ^x04 %s^x01 is the new terrorist.",teronamectname)
        
        if(
alive)
            
user_silentkill(newtero)
        
        
set_task(0.5"func"newtero)
        
set_task(0.8"teleport",newtero)


    }
    return 
PLUGIN_CONTINUE
}

public 
func(newtero)
{
    if(!
is_user_connected(newtero)) return PLUGIN_HANDLED;
    
cs_set_user_team(newteroCS_TEAM_T)
    
ExecuteHamB(Ham_CS_RoundRespawn,newtero)
    
set_task(0.1"strip"newtero)
    
set_task(0.2"item"newtero)
    return 
PLUGIN_HANDLED
}

public 
strip(newtero)
{
    if(!
is_user_connected(newtero)) return PLUGIN_HANDLED;
    
strip_user_weapons(newtero)
    return 
PLUGIN_HANDLED
}

    
    
public 
item(newtero)
{
    if(!
is_user_connected(newtero)) return PLUGIN_HANDLED;
    
give_item(newtero"weapon_knife")
    return 
PLUGIN_HANDLED
}


public 
teleport(newtero)
{
    if(!
is_user_connected(newtero)) return PLUGIN_HANDLED;
    
set_user_origin(newteroorigin)  
    return 
PLUGIN_HANDLED


Last edited by Blue Snake.; 10-31-2011 at 08:43.
Blue Snake. is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-31-2011 , 10:27   Re: Hook changelevel
Reply With Quote #6

Try this: http://forums.alliedmods.net/showthread.php?t=156236
__________________
Impossible is Nothing
Sylwester is offline
Blue Snake.
Member
Join Date: May 2011
Location: Romania
Old 10-31-2011 , 12:18   Re: Hook changelevel
Reply With Quote #7

I know this but there's a bug which give to the new terrorist an USP. More then, my plugin check dead CTs first and if no dead ct, it move to alive.

I've tested this version and it works. Thank you, drekes.

Problem sloved, you can close the thread.

Last edited by Blue Snake.; 10-31-2011 at 12:19.
Blue Snake. is offline
Reply


Thread Tools
Display Modes

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


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