5and5 / BO1-StratTester

A mod for strat testing
17 stars 2 forks source link

Need help with the code #24

Closed 330CanWalk closed 1 year ago

330CanWalk commented 1 year ago

Sry for asking this here but recently ive been trying to code a timer for my game but ive been strugling with implementing it to the game since the library #include maps_zombiemode_utility; doesnt seem to be found by the game. image and this is my code:

include maps_utility;

include common_scripts\utility;

include maps_zombiemode_utility;

init() { if ( GetDvar( #"zombiemode" ) == "1" ) { level thread onPlayerConnect(); }

}

game_timer() {
hud = create_simple_hud( self ); hud.foreground = true; hud.sort = 1; hud.hidewheninmenu = true; hud.alignX = "left"; hud.alignY = "top"; hud.horzAlign = "user_left"; hud.vertAlign = "user_top"; hud.x = hud.x - -30; hud.y = hud.y + 15; hud.alpha = 1; time_text = string(GetTime() / 1000); flag_wait("all_players_spawned"); while (1){ hud setTimerUp(1); hud setTimer(time_text);

}

}

onPlayerConnect() { for(;;) { level waittill ("connecting", player); player thread onPlayerSpawned(); } }

onPlayerSpawned() { for(;;) { self waittill("spawned_player"); self thread game_timer(); }

} I will aprecciate if u guys help, u are the only people i know that know how to code on Bo1.

TTS4life commented 1 year ago

In the code you pasted, looks like you have incorrect file paths. Try

#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;
330CanWalk commented 1 year ago

image yea this is how the code looks like but i still get the same error :(

TTS4life commented 1 year ago

The code works for me. I created a new folder in my mods folder called timertest and added your code to it in a file called timertest.gsc as the following:

#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
    if ( GetDvar( #"zombiemode" ) == "1" )
    {
        level thread onPlayerConnect();
    }

}

game_timer()
{
    hud = create_simple_hud( self );
    hud.foreground = true;
    hud.sort = 1;
    hud.hidewheninmenu = true;
    hud.alignX = "left";
    hud.alignY = "top";
    hud.horzAlign = "user_left";
    hud.vertAlign = "user_top";
    hud.x = hud.x - -30;
    hud.y = hud.y + 15;
    hud.alpha = 1;
    time_text = string(GetTime() / 1000);
    flag_wait("all_players_spawned");
    while (1){
        hud setTimerUp(1);
        hud setTimer(time_text);
    }
}

onPlayerConnect()
{
    for(;;)
    {
        level waittill ("connecting", player);
        player thread onPlayerSpawned();
    }
}

onPlayerSpawned()
{
    for(;;)
    {
        self waittill("spawned_player");
        self thread game_timer();
    }

}

then I added _zombiemode.gsc to the project and added the following in main() around line 127:

    maps\_zombiemode_bowie::bowie_init();
//  maps\_zombiemode_betty::init();
//  maps\_zombiemode_timer::init();
//  maps\_zombiemode_auto_turret::init();
    //maps\_zombiemode_protips::pro_tips_initialize();
    maps\_zombiemode_traps::init();
    maps\_zombiemode_weapon_box::init();
    /#
    maps\_zombiemode_devgui::init();
    #/

    maps\maptest::init();    <<<<<<<<<<<<<<<<<<< This here

    init_function_overrides();

    // ww: init the pistols in the game so last stand has the importance order
    level thread last_stand_pistol_rank_init();

    //thread maps\_zombiemode_rank::init();             

    // These MUST be threaded because they contain waits
    //level thread maps\_zombiemode_deathcard::init();
    //level thread maps\_zombiemode_money::init();
    level thread [[level.Player_Spawn_func]]();
    level thread onPlayerConnect(); 

once I had both of those set up, I loaded things up using game_mod and everything seems to work fine. image

330CanWalk commented 1 year ago

Sry for late response but i had an uni exam today. I have done what u wrote but i still get the same error also I play on plutonium so that might be the problem i havent figured it yet. image Maybe on plut scripts doesnt work as they do on steam bo1. Anyway thank u for ur help.

TTS4life commented 1 year ago

I have not developed for Plutonium so I do not know what is required in order for a mod to work on Plutonium. You will have to consult their forums for help on that part. I have only developed for game_mod and what I have demonstrated would work on game_mod.