SA-MP Forums Archive
Armour Problem - 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: Armour Problem (/showthread.php?tid=420582)



Armour Problem - Blackazur - 05.03.2013

Hello, how to make that the Player dont get more then 95 HP?

Код:
CMD:klevar(playerid,params[])
{
    if(pInfo[playerid][pVipLevel] >= 2)
	{
		if(team[playerid] == TEAM_HUMAN)
		{
				new Float:armor;
				GetPlayerArmour(playerid,armor);
								if(team[playerid] == TEAM_HUMAN)
				{
				if(armor >= 95)
					{
						SendClientMessage(playerid,-1,""chat" You have enough armour to survive.");
					}
							SetPlayerArmour(playerid,armor+25);
							new string[18];
                             format(string, sizeof(string), "~w~+25 Armour");
							GameTextForPlayer(playerid,string,4000,1);
							new str[480];
							format(str,sizeof(str),""chat""COL_YELLOW" [VIP]%s used an {99FFFF}SURVIVAL PACK to get +25 ARMOUR",PlayerName(playerid));
				SendClientMessageToAll(-1,str);
						}
					}
				}
		else return SendClientMessage(playerid,-1,""chat""COL_LGREEN" [ERROR]: You are not an V.I.P!");
	return 1;
}



Re : Armour Problem - Shidony - 05.03.2013

pawn Код:
if(armor >= 95)
{
    SendClientMessage(playerid,-1,""chat" You have enough armour to survive.");
    return 1;
}



Re: Armour Problem - Kreatyve - 05.03.2013

Код:
if(armor >= 95 || (armor + 25) >= 95)
{
	SendClientMessage(playerid,-1,""chat" You have enough armour to survive.");
	return 1;
}
Check if the current armour + 25 will be equal to or greater than 95 first.
return 1; to stop the rest of the function from functioning.


Re : Armour Problem - DaRk_RaiN - 05.03.2013

pawn Код:
CMD:klevar(playerid,params[])
{
    if(pInfo[playerid][pVipLevel] >= 2)
    {
        if(team[playerid] == TEAM_HUMAN)
        {
                new Float:armor;
                GetPlayerArmour(playerid,armor);
                                if(team[playerid] == TEAM_HUMAN)
                {
                if(armor >= 95)return SendClientMessage(playerid,-1,""chat" You have enough armour to survive.");
                            SetPlayerArmour(playerid,armor+25);
                            new string[18];
                             format(string, sizeof(string), "~w~+25 Armour");
                            GameTextForPlayer(playerid,string,4000,1);
                            new str[480];
                            format(str,sizeof(str),""chat""COL_YELLOW" [VIP]%s used an {99FFFF}SURVIVAL PACK to get +25 ARMOUR",PlayerName(playerid));
                SendClientMessageToAll(-1,str);
                        }
                    }
                }
        else return SendClientMessage(playerid,-1,""chat""COL_LGREEN" [ERROR]: You are not an V.I.P!");
    return 1;
ADD: Dayam 3 messages at same minute.


AW: Armour Problem - Blackazur - 05.03.2013

Thanks, and how can i add that the Cmd work only all 15 Seconds?


Re: Armour Problem - Patrick - 05.03.2013

Try this. since im using this way to make a recently command if its only 1 command

pawn Код:
new HasUsedThisCommandRecently[ MAX_PLAYERS ];

forward Klevar(playerid);
public Klevar(playerid)
{
    HasUsedThisCommandRecently[playerid] =0;
    return 1;
}

CMD:klevar(playerid,params[])
{
    if(pInfo[playerid][pVipLevel] < 2)
        return SendClientMessage(playerid,-1,""chat""COL_LGREEN" [ERROR]: You are not an V.I.P!");
    if(HasUsedThisCommandRecently[playerid] == 1)
        return SendClientMessage(playerid, -1,"You have used this command recently");
    if(team[playerid] == TEAM_HUMAN)
    {
    new Float:armor;
    GetPlayerArmour(playerid,armor);
    if(team[playerid] == TEAM_HUMAN)
    {
        if(armor >= 95)return SendClientMessage(playerid,-1,""chat" You have enough armour to survive.");
        SetPlayerArmour(playerid,armor+25);
        new string[18];
        format(string, sizeof(string), "~w~+25 Armour");
        GameTextForPlayer(playerid,string,4000,1);
        new str[480];
        format(str,sizeof(str),""chat""COL_YELLOW" [VIP]%s used an {99FFFF}SURVIVAL PACK to get +25 ARMOUR",PlayerName(playerid));
        SendClientMessageToAll(-1,str);
        SetTimerEx("Klevar",15000,0,"i",playerid);//no repeat
        HasUsedThisCommandRecently[playerid] =1;
        }
    }
    return 1;
}



Re : Armour Problem - Shidony - 05.03.2013

You can add a timer of 15 seconds and set a player variable like CanTriggerCommand[playerid] if the variable is at 1, the player can do the command and cannot if the variable is at 0.


Re: Armour Problem - Vince - 05.03.2013

For your information: The thing is called Kevlar, not klevar.