AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hook changelevel (https://forums.alliedmods.net/showthread.php?t=170960)

Blue Snake. 10-30-2011 17:38

Hook changelevel
 
Can I hook srvcmd changelevel? Something like:

PHP Code:

register_srvcmd("changelevel""func")
...


public 
func()
{
    
asd=true
    
return PLUGIN_CONTINUE



Arkshine 10-30-2011 18:11

Re: Hook changelevel
 
What do you want to do inside exactly ?

Blue Snake. 10-30-2011 18:26

Re: Hook changelevel
 
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


drekes 10-30-2011 18:59

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

Blue Snake. 10-31-2011 08:39

Re: Hook changelevel
 
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



Sylwester 10-31-2011 10:27

Re: Hook changelevel
 
Try this: http://forums.alliedmods.net/showthread.php?t=156236

Blue Snake. 10-31-2011 12:18

Re: Hook changelevel
 
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.


All times are GMT -4. The time now is 14:26.

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