Raised This Month: $ Target: $400
 0% 

[req] fix error in a plugin replace_disconnected_t


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sigerman
Senior Member
Join Date: Aug 2013
Location: Argentina, Bs.As.
Old 05-02-2014 , 00:47   [req] fix error in a plugin replace_disconnected_t
Reply With Quote #1

This plugin is of deathrun mod.

The problem I found, is that in case of kill/slay, there isn't a replacement for tt.
I posted this in the plugin's forum, The creator didn't answer me, and other msj before mine.
Attached Files
File Type: sma Get Plugin or Get Source (replace_disconnected_t.sma - 367 views - 5.1 KB)
sigerman is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 05-02-2014 , 02:58   Re: [req] fix error in a plugin replace_disconnected_t
Reply With Quote #2

In player_killed you should copy this code

PHP Code:
public client_disconnect(id){  
    
_UnSet(_humanid)
    
_UnSet(_aliveid)
    new 
players[32], pnum
    
for(new i=1i<=g_max_playersi++){
        if(!
_Is(_humani))
            continue
        if(
cs_get_user_team(i) == CS_TEAM_T)
            return
        
players[pnum++] = i
    
}
    if(
pnum<=0)
        return
    new 
new_terr players[random(pnum)]
    
cs_set_user_team(new_terrCS_TEAM_T)

    
announce_t_change(new_terrid)

    if(!
g_valid_origin){
        
ExecuteHamB(Ham_CS_RoundRespawnnew_terr)
        return
    }
    
ExecuteHamB(Ham_CS_RoundRespawnnew_terr)
    
g_valid_origin true
    
new param[2]
    
param[0] = new_terr
    param
[1] = 10 //max teleport attempts
    
restore_origin(param)

Or better
PHP Code:
public Player_Killed(id){
    
_UnSet(_aliveid)
    
elegir_nuevo_tt()
}

public 
client_disconnect(id){  
    
_UnSet(_humanid)
    
_UnSet(_aliveid)
    
elegir_nuevo_tt()

PHP Code:
public elegir_nuevo_tt(){
    new 
players[32], pnum
    
for(new i=1i<=g_max_playersi++){
        if(!
_Is(_humani))
            continue
        if(
cs_get_user_team(i) == CS_TEAM_T)
            return
        
players[pnum++] = i
    
}
    if(
pnum<=0)
        return
    new 
new_terr players[random(pnum)]
    
cs_set_user_team(new_terrCS_TEAM_T)

    
announce_t_change(new_terrid)

    if(!
g_valid_origin){
        
ExecuteHamB(Ham_CS_RoundRespawnnew_terr)
        return
    }
    
ExecuteHamB(Ham_CS_RoundRespawnnew_terr)
    
g_valid_origin true
    
new param[2]
    
param[0] = new_terr
    param
[1] = 10 //max teleport attempts
    
restore_origin(param)

NikKOo31 is offline
sigerman
Senior Member
Join Date: Aug 2013
Location: Argentina, Bs.As.
Old 05-02-2014 , 03:33   Re: [req] fix error in a plugin replace_disconnected_t
Reply With Quote #3

@NikKOo31

Could you explain better what I have to do? because I don't understand too much.
I try to do it but it didn't compile
sigerman is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 05-02-2014 , 06:16   Re: [req] fix error in a plugin replace_disconnected_t
Reply With Quote #4

In client_disconnect(id) you pick a CT and transfer him to T, you have to do the same in Player_Killed(id), else when T dies it won't be replaced, just will work when he disconnect

My suggestion is to copy the code from client_disconnect and do a funtion that you can call from client disconnect and player_killed. I just realize that the function needs a parameter id and in case of player_killed you have to check that there's no attacker. I attached a sma for you

This is the func I added
PHP Code:
public elegir_nuevo_tt(id){ 
    new 
players[32], pnum 
    
for(new i=1i<=g_max_playersi++){ 
        if(!
_Is(_humani)) 
            continue 
        if(
cs_get_user_team(i) == CS_TEAM_T
            return 
        
players[pnum++] = 
    

    if(
pnum<=0
        return 
    new 
new_terr players[random(pnum)] 
    
cs_set_user_team(new_terrCS_TEAM_T

    
announce_t_change(new_terrid

    if(!
g_valid_origin){ 
        
ExecuteHamB(Ham_CS_RoundRespawnnew_terr
        return 
    } 
    
ExecuteHamB(Ham_CS_RoundRespawnnew_terr
    
g_valid_origin true 
    
new param[2
    
param[0] = new_terr 
    param
[1] = 10 //max teleport attempts 
    
restore_origin(param

Attached Files
File Type: sma Get Plugin or Get Source (replace_disconnected_t.sma - 606 views - 5.5 KB)
NikKOo31 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 22:10.


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