AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Light flicker (https://forums.alliedmods.net/showthread.php?t=40582)

ThomasNguyen 06-29-2006 20:02

Light flicker
 
Can someone tell me how to make the lights flicker like zombie mod. because i play cz and i took the zbot .sma and me and a friend fixed the errors so it would work and changed some of the code. We called it AlienSwarm and changed the models to the monster models from half-life. Anyways, I leave the darkness set on set_lights("b") but i want it on A with lights flickering. I was looking at hawks new zombie mod code but i couldnt find out where the flicker part was. if anyone can fix/edit this code for me to make lights flicker, it would be much appreciated.

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>

public plugin_init() {
        register_plugin("Alien Swarm", "1.0", "Mini_midget//Thomas")
        register_dictionary("AlienSwarm.txt")
       
        register_cvar("amx_aswarm" , "1")
        register_cvar("amx_aswarm_hp" , "450")
        register_cvar("amx_aswarm_ap" , "300")
        register_cvar("amx_aswarm_speed" , "550.0")
        register_cvar("amx_aswarm_steps" , "1")
        register_cvar("amx_aswarm_backspeed" , "175.0")
        register_cvar("amx_aswarm_sidespeed" , "175.0")
        register_cvar("amx_aswarm_msg" , "1")
       
        register_concmd("amx_aswarm_dark", "admin_dark", ADMIN_KICK, " ")
       
        register_event("CurWeapon","ctspeed","be","1=1")
        register_event("WeapPickup", "WeaponPickedUp", "be", "1!29")
       
        register_logevent("round_start",2,"0=World triggered","1=Round_Start")
}

public plugin_precache() {
        precache_model("models/player/alien3/islaveT.mdl")
}

public client_putinserver() {
        if (get_playersnum() == 1) {
                set_cvar_num("mp_buytime", 10)
                set_cvar_num("mp_roundtime", 4)
                set_cvar_num("sv_restartround", 10)
                set_cvar_num("sv_maxspeed", get_cvar_num("amx_aswarm_speed"))
        }
}

public client_connect(id){ 
        new newName[33] 
        get_user_info(id,"name",newName,32) 
       
        if(is_user_bot(id) && containi(newName,"-[A]lien[S]warm |") == -1) 
                { 
                format(newName,32,"-[A]lien[S]warm | %s",newName) 
                set_user_info(id,"name",newName)   
        } 


public round_start() {
        set_task(0.1,"BotNumber")
        set_task(0.3,"TeamCheck")
        set_task(0.6,"TeamSet")
        set_task(1.0,"MakeBots")
        set_task(2.5,"StartMsg")
        set_task(3.0,"SetKnife")
}

public BotNumber() {
        new player_num, bot_num, rplayer_num
        player_num = get_playersnum()
        bot_num = get_cvar_num("bot_quota")
        rplayer_num = player_num - bot_num
       
        if (rplayer_num > 0 && rplayer_num < 3) {
                set_cvar_num("bot_quota", 2)
        }
        if (rplayer_num > 2 && rplayer_num < 5) {
                set_cvar_num("bot_quota", 4)
        }
        if (rplayer_num > 4 && rplayer_num < 7) {
                set_cvar_num("bot_quota", 6)
        }
        if (rplayer_num > 6 && rplayer_num < 9) {
                set_cvar_num("bot_quota", 8)
        }
        if (rplayer_num > 8 && rplayer_num < 11) {
                set_cvar_num("bot_quota", 10)
        }
        if (rplayer_num > 10 && rplayer_num < 13) {
                set_cvar_num("bot_quota", 12)
        }
        if (rplayer_num > 12 && rplayer_num < 15) {
                set_cvar_num("bot_quota", 14)
        }
        if (rplayer_num > 14 && rplayer_num < 17) {
                set_cvar_num("bot_quota", 16)
        }
        return PLUGIN_CONTINUE
}

public MakeBots(players[]) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i,id,CsArmorType:ArmorType = CS_ARMOR_VESTHELM
        get_players(players,num)
        for(i = 0; i <= num; i++) {
                id = players[i]
                if (is_user_alive(id) && is_user_bot(id)) {
                        set_user_maxspeed(id,float(get_cvar_num("amx_aswarm_speed")))
                        set_user_health(id,get_cvar_num("amx_aswarm_hp"))
                        set_user_footsteps(id,get_cvar_num("amx_aswarm_steps"))
                        cs_set_user_armor(id,get_cvar_num("amx_aswarm_ap"),ArmorType)
                        cs_set_user_model(id,"islave")
                }
        }
        return PLUGIN_CONTINUE


public TeamSet(players[]) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i,id
        get_players(players,num)
        for(i = 0; i < num; i++) {
                id = players[i]
                if (is_user_bot(id) && is_user_alive(id)) {
                        cs_set_user_team(id,CS_TEAM_T)
                        cs_set_user_model(id,"islave")
                        } else {
                        if (is_user_alive(id)) {
                                cs_set_user_team(id,CS_TEAM_CT)
                        }
                }
        }
        return PLUGIN_CONTINUE
}

public TeamCheck(players[]) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i,id
        get_players(players,num)
        for(i = 0; i < num; i++) {
                id = players[i]
                if (is_user_alive(id)) {
                        if (is_user_bot(id) && cs_get_user_team(id) == CS_TEAM_CT) {
                                set_cvar_num("sv_restartround", 1)
                        }
                }
        }
        return PLUGIN_CONTINUE
}

public StartMsg() {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_HEALTHMSG",get_cvar_num("amx_aswarm_hp"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_ARMOURMSG",get_cvar_num("amx_aswarm_ap"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_SPEEDMSG",get_cvar_num("amx_aswarm_speed"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_NUMBER",get_cvar_num("bot_quota"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_MSG",get_cvar_num("amx_aswarm_msg"))
        return PLUGIN_CONTINUE
}

public SetKnife(index) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i
        get_players(players,num)
        for(i = 0; i <= num; i++) {
                new id = players[i]
                if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T) {
                        strip_user_weapons(id)
                        give_item(id,"weapon_knife")
                }
        }
        return PLUGIN_HANDLED
}

public ctspeed(id) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new CsTeams:team = cs_get_user_team(id)
        if (is_user_alive(id) && team == CS_TEAM_CT) {
                client_cmd(id, "cl_backspeed %d" , get_cvar_num("amx_aswarm_backspeed"))
                client_cmd(id, "cl_sidespeed %d" , get_cvar_num("amx_aswarm_sidespeed"))
        }
        return PLUGIN_CONTINUE
}

public RemovePickedWeapon(id) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        if (is_user_alive(id) && get_user_team(id) == 1) {
                strip_user_weapons(id)
                give_item(id, "weapon_knife")
        }
        return PLUGIN_HANDLED
}

public WeaponPickedUp(id) {
        set_task(0.1, "RemovePickedWeapon", id)
}

public client_death(killer,victim) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new victimname[32]
        get_user_name(victim,victimname,31)
        if (cs_get_user_team(killer) == CS_TEAM_T) {               
                set_hudmessage(255, 0, 0, -1.0, 0.2, 0, 6.0, 4.0)
                show_hudmessage(0,"%L",LANG_PLAYER,"ALIENSWARM_ALIENKILL",victimname)
        }
        return PLUGIN_CONTINUE
}

public admin_dark(id, level, cid) {
        if (!cmd_access(id, level, cid, 2))
                {
                return PLUGIN_HANDLED
        }
       
        new arg[32];
        read_argv(1,arg,31);
        if(arg[0] == '1') {       
                set_hudmessage(0, 255, 0, -1.0, 0.2, 0, 6.0, 4.0)
                show_hudmessage(0, "Dark Mode ENABLED")
                set_lights("b")       
        }
       
        else if(arg[0] == '0') {
                set_hudmessage(0, 255, 0, -1.0, 0.2, 0, 6.0, 4.0)
                show_hudmessage(0, "Dark Mode DISABLED")
                set_lights("#OFF")
        }
        return PLUGIN_HANDLED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang5129\\ f0\\ fs16 \n\\ par }
*/


ThomasNguyen 06-29-2006 20:10

Re: Light flicker
 
Quote:

Originally Posted by ThomasNguyen
Can someone tell me how to make the lights flicker like zombie mod. because i play cz and i took the zbot .sma and me and a friend fixed the errors so it would work and changed some of the code. We called it AlienSwarm and changed the models to the monster models from half-life. Anyways, I leave the darkness set on set_lights("b") but i want it on A with lights flickering. I was looking at hawks new zombie mod code but i couldnt find out where the flicker part was. if anyone can fix/edit this code for me to make lights flicker, it would be much appreciated.

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>

public plugin_init() {
        register_plugin("Alien Swarm", "1.0", "Mini_midget//Thomas")
        register_dictionary("AlienSwarm.txt")
       
        register_cvar("amx_aswarm" , "1")
        register_cvar("amx_aswarm_hp" , "450")
        register_cvar("amx_aswarm_ap" , "300")
        register_cvar("amx_aswarm_speed" , "550.0")
        register_cvar("amx_aswarm_steps" , "1")
        register_cvar("amx_aswarm_backspeed" , "175.0")
        register_cvar("amx_aswarm_sidespeed" , "175.0")
        register_cvar("amx_aswarm_msg" , "1")
       
        register_concmd("amx_aswarm_dark", "admin_dark", ADMIN_KICK, " ")
       
        register_event("CurWeapon","ctspeed","be","1=1")
        register_event("WeapPickup", "WeaponPickedUp", "be", "1!29")
       
        register_logevent("round_start",2,"0=World triggered","1=Round_Start")
}

public plugin_precache() {
        precache_model("models/player/alien3/islaveT.mdl")
}

public client_putinserver() {
        if (get_playersnum() == 1) {
                set_cvar_num("mp_buytime", 10)
                set_cvar_num("mp_roundtime", 4)
                set_cvar_num("sv_restartround", 10)
                set_cvar_num("sv_maxspeed", get_cvar_num("amx_aswarm_speed"))
        }
}

public client_connect(id){ 
        new newName[33] 
        get_user_info(id,"name",newName,32) 
       
        if(is_user_bot(id) && containi(newName,"-[A]lien[S]warm |") == -1) 
                { 
                format(newName,32,"-[A]lien[S]warm | %s",newName) 
                set_user_info(id,"name",newName)   
        } 


public round_start() {
        set_task(0.1,"BotNumber")
        set_task(0.3,"TeamCheck")
        set_task(0.6,"TeamSet")
        set_task(1.0,"MakeBots")
        set_task(2.5,"StartMsg")
        set_task(3.0,"SetKnife")
}

public BotNumber() {
        new player_num, bot_num, rplayer_num
        player_num = get_playersnum()
        bot_num = get_cvar_num("bot_quota")
        rplayer_num = player_num - bot_num
       
        if (rplayer_num > 0 && rplayer_num < 3) {
                set_cvar_num("bot_quota", 2)
        }
        if (rplayer_num > 2 && rplayer_num < 5) {
                set_cvar_num("bot_quota", 4)
        }
        if (rplayer_num > 4 && rplayer_num < 7) {
                set_cvar_num("bot_quota", 6)
        }
        if (rplayer_num > 6 && rplayer_num < 9) {
                set_cvar_num("bot_quota", 8)
        }
        if (rplayer_num > 8 && rplayer_num < 11) {
                set_cvar_num("bot_quota", 10)
        }
        if (rplayer_num > 10 && rplayer_num < 13) {
                set_cvar_num("bot_quota", 12)
        }
        if (rplayer_num > 12 && rplayer_num < 15) {
                set_cvar_num("bot_quota", 14)
        }
        if (rplayer_num > 14 && rplayer_num < 17) {
                set_cvar_num("bot_quota", 16)
        }
        return PLUGIN_CONTINUE
}

public MakeBots(players[]) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i,id,CsArmorType:ArmorType = CS_ARMOR_VESTHELM
        get_players(players,num)
        for(i = 0; i <= num; i++) {
                id = players[i]
                if (is_user_alive(id) && is_user_bot(id)) {
                        set_user_maxspeed(id,float(get_cvar_num("amx_aswarm_speed")))
                        set_user_health(id,get_cvar_num("amx_aswarm_hp"))
                        set_user_footsteps(id,get_cvar_num("amx_aswarm_steps"))
                        cs_set_user_armor(id,get_cvar_num("amx_aswarm_ap"),ArmorType)
                        cs_set_user_model(id,"islave")
                }
        }
        return PLUGIN_CONTINUE


public TeamSet(players[]) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i,id
        get_players(players,num)
        for(i = 0; i < num; i++) {
                id = players[i]
                if (is_user_bot(id) && is_user_alive(id)) {
                        cs_set_user_team(id,CS_TEAM_T)
                        cs_set_user_model(id,"islave")
                        } else {
                        if (is_user_alive(id)) {
                                cs_set_user_team(id,CS_TEAM_CT)
                        }
                }
        }
        return PLUGIN_CONTINUE
}

public TeamCheck(players[]) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i,id
        get_players(players,num)
        for(i = 0; i < num; i++) {
                id = players[i]
                if (is_user_alive(id)) {
                        if (is_user_bot(id) && cs_get_user_team(id) == CS_TEAM_CT) {
                                set_cvar_num("sv_restartround", 1)
                        }
                }
        }
        return PLUGIN_CONTINUE
}

public StartMsg() {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_HEALTHMSG",get_cvar_num("amx_aswarm_hp"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_ARMOURMSG",get_cvar_num("amx_aswarm_ap"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_SPEEDMSG",get_cvar_num("amx_aswarm_speed"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_NUMBER",get_cvar_num("bot_quota"))
        client_print(0,print_chat,"%L",LANG_PLAYER,"ALIENSWARM_MSG",get_cvar_num("amx_aswarm_msg"))
        return PLUGIN_CONTINUE
}

public SetKnife(index) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new players[32],num,i
        get_players(players,num)
        for(i = 0; i <= num; i++) {
                new id = players[i]
                if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T) {
                        strip_user_weapons(id)
                        give_item(id,"weapon_knife")
                }
        }
        return PLUGIN_HANDLED
}

public ctspeed(id) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new CsTeams:team = cs_get_user_team(id)
        if (is_user_alive(id) && team == CS_TEAM_CT) {
                client_cmd(id, "cl_backspeed %d" , get_cvar_num("amx_aswarm_backspeed"))
                client_cmd(id, "cl_sidespeed %d" , get_cvar_num("amx_aswarm_sidespeed"))
        }
        return PLUGIN_CONTINUE
}

public RemovePickedWeapon(id) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        if (is_user_alive(id) && get_user_team(id) == 1) {
                strip_user_weapons(id)
                give_item(id, "weapon_knife")
        }
        return PLUGIN_HANDLED
}

public WeaponPickedUp(id) {
        set_task(0.1, "RemovePickedWeapon", id)
}

public client_death(killer,victim) {
        if( get_cvar_num("amx_aswarm") != 1 ) {
                return PLUGIN_HANDLED
        }
        new victimname[32]
        get_user_name(victim,victimname,31)
        if (cs_get_user_team(killer) == CS_TEAM_T) {               
                set_hudmessage(255, 0, 0, -1.0, 0.2, 0, 6.0, 4.0)
                show_hudmessage(0,"%L",LANG_PLAYER,"ALIENSWARM_ALIENKILL",victimname)
        }
        return PLUGIN_CONTINUE
}

public admin_dark(id, level, cid) {
        if (!cmd_access(id, level, cid, 2))
                {
                return PLUGIN_HANDLED
        }
       
        new arg[32];
        read_argv(1,arg,31);
        if(arg[0] == '1') {       
                set_hudmessage(0, 255, 0, -1.0, 0.2, 0, 6.0, 4.0)
                show_hudmessage(0, "Dark Mode ENABLED")
                set_lights("b")       
        }
       
        else if(arg[0] == '0') {
                set_hudmessage(0, 255, 0, -1.0, 0.2, 0, 6.0, 4.0)
                show_hudmessage(0, "Dark Mode DISABLED")
                set_lights("#OFF")
        }
        return PLUGIN_HANDLED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang5129\\ f0\\ fs16 \n\\ par }
*/




================--------------------------------================
Another thing...
================--------------------------------================

Is there a way to make it so that there are different types on aliens. Like sometimes there would be all normal aliens [islaves] or all aliengrunts[garg] (not using the real agrunt because it floats) and sometimes mixed. the aliengrunts would be stronger than the normal aliens [health, speed, armor]
Any possible way to do this please let me know :)

Smokey485 06-29-2006 20:21

Re: Light flicker
 
Lights flicker? Like making a TE_DLIGHT tempentity?

ThomasNguyen 06-29-2006 20:33

Re: Light flicker
 
I have no clue what your talking about because i dont know anything about scripting except changing things that are easy (models etc...) By lights flicker i mean just like on zombie mod. Like the same exact thing.

Mini_Midget 06-29-2006 22:35

Re: Light flicker
 
umm...
i believe thats my zbot script you just ripped...
you didn't ask me for it and it doesn't seem like you did a heavy edit to it
but my name is still up there...

oh yeah, i want to know this too as i was gonna add it to zbot (i haven't got much around it lately)

ThomasNguyen 06-30-2006 01:23

Re: Light flicker
 
Quote:

Originally Posted by Mini_Midget
umm...
i believe thats my zbot script you just ripped...
you didn't ask me for it and it doesn't seem like you did a heavy edit to it
but my name is still up there...

oh yeah, i want to know this too as i was gonna add it to zbot (i haven't got much around it lately)

Your right about your plugin being ripped by me but im just changing it to what i want it to be and using it for my self [private] I wasnt gonna post the sma but i had to, to learn where to put the part where the lights flicker. I dont consider me "ripping" your/shino's plugin off by making it different in a way. but i guess i did now since i posted the plugin script.

All i did was change the code a little like everyone else does to other codes. Thats what the .sma is for, if you not want people "ripping/changing" your code then dont post the .sma but its against the rules.. soo :P

Mini_Midget 06-30-2006 04:00

Re: Light flicker
 
meh... as long as theres credit with my name in it, then i'm cool with what you did
anywho...
this might sound stupid just to make the lights flicker but it might work
using the set_task command might work
you could like have the flicker happen every 10 seconds then go back to night
i think its like:
set_task 1.0 "night hour"

night hour
set_lights "b"
set_task 10.0 "lighting"

lighting
set_lights "g"
set_task 1.0 "night hour"

thats just a blur of what i'm talking, i guess you can call it a loop or something but i'm sure theres a better way to do this
i know thats a shit description but it could work ;)

Hawk552 06-30-2006 12:34

Re: Light flicker
 
Quote:

Originally Posted by Mini_Midget
meh... as long as theres credit with my name in it, then i'm cool with what you did
anywho...
this might sound stupid just to make the lights flicker but it might work
using the set_task command might work
you could like have the flicker happen every 10 seconds then go back to night
i think its like:
set_task 1.0 "night hour"

night hour
set_lights "b"
set_task 10.0 "lighting"

lighting
set_lights "g"
set_task 1.0 "night hour"

thats just a blur of what i'm talking, i guess you can call it a loop or something but i'm sure theres a better way to do this
i know thats a shit description but it could work ;)

That makes no sense. Just spawn an ent and set its effects to EF_BRIGHTLIGHT. Either that, or you can send a message to every player with TE_DLIGHT with a low decay.

EDIT: If you mean a lightning effect, here's part of it taken from the old zombie mod:

Code:
    if (get_cvar_num("amx_zombie_lightning"))     {         if (random_num(0,7) == 1)         {             g_iLastLights = 1             new iRand = random_num(1,5)                         switch (iRand)             {                 case 1:                     set_lights("aaaaaaaaabcdefdbaa")                 case 2:                     set_lights("aaaaaagcdaaaaaa")                 case 3:                     set_lights("aaacdefdbaaaa")                 case 4:                     set_lights("aaaabbbaaaa")                 case 5:                     set_lights("aaaacbbcaaaab")             }         }         else if (g_iLastLights)         {             g_iLastLights = 0             set_lights("aaaaaaaaaaaaaaaaaaabbbaaaa")         }     }     else         set_lights("a")

ThomasNguyen 06-30-2006 13:30

Re: Light flicker
 
if i use that light thing you posted where would i place it?

Hawk552 06-30-2006 13:39

Re: Light flicker
 
You'll have to do a set_task on it set for every 1 second.


All times are GMT -4. The time now is 08:09.

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