Modme Forums

How to detect if the player is repairing a window?

Game Modding | Call of Duty: Black Ops 3 | Scripting


Ezzocorbi:

Just what the title says: how do I check if the player is repairing a window? I tried by checking whether the player's score increased, but if he shoots zombies my function still returns true.
Here's the code in action: https://streamable.com/8exord

function giveammo()
{
    while(1)
    {
        self waittill("trigger", player); //The trigger here is the trigger of the window, it's triggered when the player walks into it
        score_before_repair = player.score;
        wait 0.05;
        score_after_repair = player.score;
        if(score_after_repair > score_before_repair) //I compare the score before and after repairing the boards, if it increased I print "Repairing Board"
        {
            iPrintln("^2Repairing Board");  
        }
    wait 0.1;
    }
}

function get_windows()
{

    self endon("disconnect");
    self endon("death");

    window_boards = struct::get_array( "exterior_goal", "targetname" ); //Get all the windows in the map

    foreach(window in window_boards)
    {
        window thread giveammo(); //And thread the function giveammo() for each window
    }
}

This way of checking when the player is interacting with the window is kinda buggy, is there a better way to do it?
Thanks in advance!

P.S. I'm new to GSC and coding in general, this is my first project actually, so if you see any mistake or have any advice please tell me!


eDeK:

I dont test it but maybe something like that, idk.

callback::on_spawned( &xxx );
function xxx()
{   
    for( ;; )
    {
        self waittill( "boarding_window" );

        IPrintLn("^2Repairing Board");     
    }           
}


Ezzocorbi:

Thanks, this works perfectly.