AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Life Mode (https://forums.alliedmods.net/showthread.php?t=232363)

datasource 12-29-2013 13:08

Life Mode
 
Hi again :D Finaly i created my new plugin. Life mode. Yep... it looks awfl. but it works ! :D Anyway what I wanna to do to is share with you guys and try to help me a little bit. Here is the code:
Code:

#include <amxmodx>
#include <cstrike>
#include <fun>
#include <colorchat>
#include <fakemeta_util>

#define PLUGIN "Life Mode"
#define VERSION "1.0"
#define AUTHOR "DataSource"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_event( "DeathMsg", "lf_someone_death", "a")
    register_event( "BombDrop", "lf_bomb_planted", "a")
    register_event("CurWeapon", "CurWeapon","be", "1=1")
    register_logevent("lf_bomb_plant", 3, "2=Planted_The_Bomb")
    register_logevent("lf_round_end", 2, "1=Round_End")
    register_logevent("lf_round_start", 2, "1=Round_Start")
   
    set_task( 20.0, "lf_textmsg")
}

public lf_textmsg(id) {
    ColorChat( 0, Color:RED, "^x04Plant or defuse the bomb to save your teammates and ^x03 yourself!")
    set_task(300.0, "lf_textmsg", id)
   
}

public lf_round_end() {
   
    new players[32], num, tid
    get_players(players, num, "a")

    for( new i = 0; i < num; i++ )
    {
    tid = players[i]
    remove_task(tid)
   
    }
}

public lf_round_start() {
   
    if (fm_find_ent_by_class(-1, "weapon_c4") ) {
    new players[32], num, tid
    get_players(players, num, "a")
   
    for( new i = 0; i < num; i++ )
    {
    tid = players[i]
    if ( cs_get_user_team(tid) == CS_TEAM_T ) {
        set_task(1.0, "lf_mode_start", tid, "", 0, "a", 100)
    }
    }
    }
   
}


public lf_mode_start(tid) {

   
    if( !is_user_alive(tid) ) {
    remove_task(tid)
    }
    else {
   
    new Health = get_user_health(tid)
   
    set_user_health( tid, Health - 1)
   
    }
}

public lf_someone_death() {
    new iVictim = read_data( 2 )
    remove_task(iVictim)
   
}
new planter
public lf_bomb_plant() {
    new players[32], num, tid
    get_players(players, num, "a")

    for( new i = 0; i < num; i++ )
    {
    tid = players[i]
   
    if ( cs_get_user_team( tid ) == CS_TEAM_T )
        if ( planter == ( tid ) ) {
        new t_health = get_user_health( tid )
        set_user_health( tid, t_health + 20 )
        } else {
        new t_health = get_user_health( tid )
        set_user_health( tid, t_health + 10 )
        }
    }
   
}

public CurWeapon(tid) {
    if(read_data(2) == CSW_C4)
    planter = tid
}

public lf_bomb_planted() {
    new BombPlanted = read_data(4)
    new players[32], num, tid
    if ( BombPlanted == 1 ) {
   
    get_players(players, num, "a")

    for( new i = 0; i < num; i++ )
    {
    tid = players[i]
    remove_task(tid)
    }
    set_task(1.0, "lf_bomb_defuse_time")
    }
   
}

public lf_bomb_defuse_time(tid) {
    new players[32], num, tid
   
   
    get_players(players, num, "a")
   
    for (new i = 0; i < num; i++ )
    {
    tid = players[i]
   
    if ( cs_get_user_team(tid) == CS_TEAM_CT ) {
        set_task(1.0, "lf_mode_start", tid, "", 0, "a", 100)
    }
    }
}

It doesn't look very good but problem is when someone connects 1-2s later and joinded the game the plugin doesn't work because it only checks at round start not when somebody connected... Any ideas?

Torge 12-29-2013 17:24

Re: Life Mode
 
It might work if you use the function when a player connects and then set_task then it should actually work.

DavidJr 12-30-2013 14:29

Re: Life Mode
 
Public client_connect(id) ?

If I were you, I'd rather use Ham_Spawn than check round start :3

Torge 12-30-2013 21:56

Re: Life Mode
 
client_putinserver(id) instead of client_connect(id).

I didn't code pawn for a long while I got very nooby ^^
your method could also work :D


All times are GMT -4. The time now is 10:05.

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