Legacy GM action doesn't work unless physically pressing button(SOLVED)

Y

Yvalson

Guest
In my game when the player presses a key and some conditions are met it should emulate a keypress(number 3) this will change the players wielding weapon and should change the attack animation accordingly.

if I physically press the 3 button it does work. but when do it through the code my player disappears when performing the attack animation and doesn't change it's idle state either (still in the no weapon state) here is the code:

Code:
//npc chats

if(distance_to_object(Obj_Yulath1) < 3){
    if(global.Mission[1] = 1 && global.MissionQuest[2] = 1){
        global.Inchat = 1
        newChat(global.Mission_One_Quest_Three_Dial, "none");
        if(global.Inchat = 0){
            event_perform(ev_keypress, ord("3"))
        }
    }
}
thats the button press

and this is what the 3 button should do:

Code:
if(Accept_Input = 1){
Weapon = 3
}
and here is the attack thing:

Code:
///Attack

if(Accept_Input = 1 && Stamina >= 25){
Can_Attack = 0
Repoth_Hspeed = 0
Repoth_Vspeed = 0
Is_Attacking = 1
Accept_Input = 0
audio_play_sound(snd_Attack_Swoosh, 1, 0)

{
var base = "Spr_Repoth";

switch Weapon {
case 2: base += "_FireStick"; break;
case 3: base += "_Bogor"; break;
case 4: base += "_Epicor"; break;
}

base += "_Attack";

switch Last_Angle {
case 1: base += "_Up"; break;
case 2: base += "_Down"; break;
case 3: base += "_Left"; break;
case 4: base += "_Right"; break;
}

sprite_index = asset_get_index(base);
Repoth_Hspeed = 0
Repoth_Vspeed = 0
}

alarm[0] = 9
}
 
Y

Yvalson

Guest
fixed it already the Inchat = 0 would get set to 1 before making the code never get to the emulating button its fixed now
 
Top