SA-MP Forums Archive
[PLEASE NEED HELP] What's wrong with this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [PLEASE NEED HELP] What's wrong with this? (/showthread.php?tid=352906)



[PLEASE NEED HELP] What's wrong with this? - Saw® - 21.06.2012

Hi , i made a bitting code , so i putted it in a command to test it on me
pawn Код:
dcmd_bit(playerid, params[])
{
             new Float:Health, Float:a;
             GetPlayerArmour(playerid,a);
             if(a > 0)
             {
                SetPlayerArmour(playerid, a-10);
                GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits your ~g~armour ~w~!",2000,4);
             }
             else
             {
             if (IsInfected[playerid] == 0)
             {
                GetPlayerHealth(playerid,Health);
                SetPlayerHealth(playerid, Health-5);
                InfectionTime[playerid] = 0;
                StopTimer[playerid] = SetTimer("infectiontimer", 1000, true);//starts infection
                IsInfected[playerid] = 1;
                GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits you !",2000,4);
             }
             else
             {
             GetPlayerHealth(playerid,Health);
             SetPlayerHealth(playerid, Health-5);
             GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits you !",2000,4);
             }
             }
return 1;
}
So the problem , is whene the bitten player lose his armour , & i use /bit again , it gives him a new armour with more 100 resistence instead of making the player loose Health... i don't know what's wrong... i really need your Help Thanks.


Re: [PLEASE NEED HELP] What's wrong with this? - Saw® - 21.06.2012

I will Explain :

This code will work whene i punch someone , so , whene i punch a player , if the player has an armour , then do for him : HISARMOUR-10 , else , causing damage of health(-5HP) + infection , the infection system make the player loose -6HP each 2 seconds ,
Whene the Zombie want to punch the player again , i don't want to start an other Timer ! i have already one started , so this is why i made a variable cheking if the player has been bitten before , then making him losing only -5(the last else)

The problem : is whene i bit all player's armour , & want to bit his health , a New ARMOUR is given to the bitten player (i don't know why).

NOTE : this system is working if the player doesn't have an armour , else it .....

I Really need your help Guys , any help..


Re: [PLEASE NEED HELP] What's wrong with this? - judothijs - 21.06.2012

I do have a suspicion, but could you please post the code of the infectiontimer?


Re: [PLEASE NEED HELP] What's wrong with this? - Saw® - 21.06.2012

Sure :
pawn Код:
forward infectiontimer();
public infectiontimer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
    if(IsInfected[i] == 1)
    {
        if(!IsPlayerConnected(i)) continue;
        InfectionTime[i] ++;
        if(InfectionTime[i] == 2)
        {
            new Float:Health;
            GetPlayerHealth(i,Health);
            SetPlayerHealth(i, Health-6);
            SendClientMessage(i,COLOR_WHITE,"You Are infected ! go be cured by a Medic! or kill a Zombie!");
            InfectionTime[i] = 0;
        }
    }
    }

    return 1;
}



Re: [PLEASE NEED HELP] What's wrong with this? - judothijs - 21.06.2012

How much armour does he get after you bit when his armour is gone?

pawn Код:
dcmd_bit(playerid, params[])
{
             new Float:Health, Float:a;
             GetPlayerArmour(playerid,a);
             if(a > 0)
             {
                SetPlayerArmour(playerid, a-10);
                GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits your ~g~armour ~w~!",2000,4);
             }
             else if(a > 0 && a < 10)
             {
                SetPlayerArmour(playerid, 0);
                GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits your ~g~armour, your armour is now gone! RUN! ~w~!",2000,4);
             }
             else if (IsInfected[playerid] == 0 && a <= 0)
             {
                GetPlayerHealth(playerid,Health);
                SetPlayerHealth(playerid, Health-5);
                InfectionTime[playerid] = 0;
                StopTimer[playerid] = SetTimer("infectiontimer", 1000, true);//starts infection
                IsInfected[playerid] = 1;
                GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits you !",2000,4);
             }
             else
             {
             GetPlayerHealth(playerid,Health);
             SetPlayerHealth(playerid, Health-5);
             GameTextForPlayer(playerid,"A ~r~zombie ~w~ hits you !",2000,4);
             }
}
return 1;
}
Try this.


Re: [PLEASE NEED HELP] What's wrong with this? - Saw® - 21.06.2012

THank you for your help
but still not working , i have a remarque :

Whene the player spawns with 100 in armour , there is no problem so after armour is gone , it go to health bar , but if we have for ex 95 or 20 or... it gives him an armour with over 150 ammount

EDIT:

I think i just have to set players' Armour to 100 only...