Hi,
How to allow an actor just to shot after 500ms?
so when you press a key and shot you need to wait 500ms.
EventDisable("Event Actor", EVENTKEYDOWN);
CreateTimer("Event Actor", "delay", 500);
EventEnable("Event Actor", EVENTKEYDOWN);
if(shoot==1)
{
//shoot script here
shoot=0;
CreateTimer("Event Actor", "delay", 500);
shoot=1;
char* key = GetKeyState();
if(shot>=1 && shotwait==1 && key[KEY_PAD_4]==1 )
{
CreateActor("bullet_left", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_7]==1 )
{
CreateActor("bullet_upleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_8]==1 )
{
CreateActor("bullet_up", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_9]==1 )
{
CreateActor("bullet_upright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_6]==1 )
{
CreateActor("bullet", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_PAD_3]==1 )
{
CreateActor("bullet_downright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_2]==1 )
{
CreateActor("bullet_down", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_1]==1 )
{
CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
BogdansB wrote:thanks, i want to put it in Draw Actor but there are glitches idk
- Code: Select all
char* key = GetKeyState();
if(shot>=1 && shotwait==1 && key[KEY_PAD_4]==1 )
{
CreateActor("bullet_left", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_7]==1 )
{
CreateActor("bullet_upleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_8]==1 )
{
CreateActor("bullet_up", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_9]==1 )
{
CreateActor("bullet_upright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_6]==1 )
{
CreateActor("bullet", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_PAD_3]==1 )
{
CreateActor("bullet_downright", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_2]==1 )
{
CreateActor("bullet_down", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
else if(shot>=1 && shotwait==1 && key[KEY_1]==1 )
{
CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
shotwait=0;
CreateTimer("Event Actor", "shot wait", 500);
}
CreateActor("bullet_downleft", "bullet_blue.png", "(none)", "(none)", 0, 0, false);
meansthe bullet creates and I made when it creates it goes xvelocity=10;
Users browsing this forum: No registered users and 1 guest