Need help.
#1

I have a command if i type /class and select Invincible,Then it activates invincible and if you press JUMP_KEy it makes you invincible for 7 seconds.I have made a timer so that it can be only used once 50 seconds here are my code.
on top
pawn Код:
new IsInvincible[MAX_PLAYERS];
new ClassSelectedInvin[MAX_PLAYERS];
new ClassTimerInvinVar;
OnPlayerSpawn
pawn Код:
IsInvincible[playerid] = 0;
             ClassSelectedInvin[playerid] = 0;
Under OnPlayerKeyStateChange
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP)
    {
        IsInvincible[playerid] = 0;
        SetPlayerHealth(playerid,99999);
        SetTimerEx("Invincible",7000,0, "i", playerid);
and here the forward'
pawn Код:
forward ClassTimerInvin(playerid);
public ClassTimerInvin(playerid)
{
    ClassSelectedInvin[playerid] = 0;
    KillTimer(ClassTimerInvinVar);
    return 1;
}
forward Invincible(playerid);
public Invincible(playerid)
{
    if(IsInvincible[playerid] == 0) return IsInvincible[playerid] = 1;
    SetPlayerHealth(playerid,50);
    SendClientMessage(playerid,-1,"You are now Un-Invincible");
    return 1;
and here's my Dialog
pawn Код:
if(dialogid == 4)
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(IsInvincible[playerid] == 1)
                        {
                            SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
                        }
                        else if(IsInvincible[playerid] == 0)
                        {
                            IsInvincible[playerid] = 1;
                            ClassSelectedInvin[playerid] = 1;
                            SendClientMessage(playerid, -1, "Invincible Class Activated");
                            SendClientMessage(playerid,-1, "Press Jump_Key To Activated Invincible Mode");
                            ClassTimerInvinVar = SetTimer("ClassTimerInvin",50000,false);
                        }
                    }

}
i really need it ...
no errors
Will +Rep if you want.
Reply
#2

What is your actual problem?
Reply
#3

You're not showing the dialogue in your code, it's just sitting there dormant.

Could you please be more specific as to what the entire problem is too?
Reply
#4

the timer is not working, i type'd /class and selected Invinicble and then used it again and it also worked but i had made a Timer of 50 seconds..
Reply
#5

pawn Код:
if(IsInvincible[playerid] == 1)
                        {
                            SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
                            ClassTimerInvinVar = SetTimer("ClassTimerInvin",50000,true);// I think you forgot to put the timer here
                        }
Reply
#6

Try:

pawn Код:
if(dialogid == 4)
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(IsInvincible[playerid] == 1)
                        {
                            SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
                        }
                        else if(IsInvincible[playerid] == 0)
                        {
                            IsInvincible[playerid] = 1;
                            ClassSelectedInvin[playerid] = 1;
                            SendClientMessage(playerid, -1, "Invincible Class Activated");
                            SendClientMessage(playerid,-1, "Press Jump_Key To Activated Invincible Mode");
                            SetTimerEx("ClassTimerInvin",50000,false,"i",0);
                        }
                    }

}
Reply
#7

pawn Код:
if(dialogid == 4)
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(IsInvincible[playerid] == 1)
                        {
                            SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
                        }
                        else if(IsInvincible[playerid] == 0)
                        {
                            IsInvincible[playerid] = 1;
                            ClassSelectedInvin[playerid] = 1;
                            SendClientMessage(playerid, -1, "Invincible Class Activated");
                            SendClientMessage(playerid,-1, "Press Jump_Key To Activated Invincible Mode");
                            SetTimerEx("ClassTimerInvin",50000,false,"i",0);
                        }
                    }
                }
            }
        }
Still the timer is not working..
i can use it without waiting 50 secs, i have homehost if anyone want to see the bug just pm, me i'll give the ip. (Not AD)
Reply
#8

pawn Код:
if(dialogid == 4)
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(IsInvincible[playerid] == 1)
                        {
                            SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
                            //Here you saying that if the player is invicible than u should wait 50 sec but you didn't put any code for making the timer true
                        }
                        else if(IsInvincible[playerid] == 0)
                        {
                            IsInvincible[playerid] = 1;
                            ClassSelectedInvin[playerid] = 1;
                            SendClientMessage(playerid, -1, "Invincible Class Activated");
                            SendClientMessage(playerid,-1, "Press Jump_Key To Activated Invincible Mode");
                            SetTimerEx("ClassTimerInvin",50000,false,"i",0);
                        }
                    }
                }
            }
        }
Reply
#9

Quote:
Originally Posted by nilanjay
Посмотреть сообщение
pawn Код:
if(dialogid == 4)
        {
            if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(IsInvincible[playerid] == 1)// Here i already did " == 1" makes it Don't work..
                        {
                            SendClientMessage(playerid,-1,"You need to wait 50 Secods before using this class again");
                            //Here you saying that if the player is invicible than u should wait 50 sec but you didn't put any code for making the timer true
                        }
                        else if(IsInvincible[playerid] == 0)
                        {
                            IsInvincible[playerid] = 1;
                            ClassSelectedInvin[playerid] = 1;
                            SendClientMessage(playerid, -1, "Invincible Class Activated");
                            SendClientMessage(playerid,-1, "Press Jump_Key To Activated Invincible Mode");
                            SetTimerEx("ClassTimerInvin",50000,false,"i",0);
                        }
                    }
                }
            }
        }
....................
Reply
#10

Found the problem, add this:

pawn Код:
forward ClassTimerInvin(playerid);
public ClassTimerInvin(playerid)
{
    ClassSelectedInvin[playerid] = 0;
     IsInvincible[playerid] = 1 // <-----
    KillTimer(ClassTimerInvinVar);
    return 1;
}
forward Invincible(playerid);
public Invincible(playerid)
{
    if(IsInvincible[playerid] == 0) return IsInvincible[playerid] = 1;
    SetPlayerHealth(playerid,50);
    SendClientMessage(playerid,-1,"You are now Un-Invincible");
    return 1;
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)