27.04.2014, 21:01
The code:
The forward:
First of all, how can I make it give a player +5 HP when /use cigar instead of setting the players health to 5?
And the second problem is how to make the timer minus a players health by 1 each minute after smoking the cigarette?
pawn Код:
CMD:use(playerid, params[])
{
new string[128];
if(sscanf(params, "s[8]", params))
{
SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /use [type]");
SendClientMessage(playerid, COLOR_GREY, "TYPES: Cigar | cocaine");
return 1;
}
if(IsPlayerCuffed(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");
if(!strcmp(params, "cigar", true))
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");
if(!PlayerInfo[playerid][pCigar]) return SendClientMessage(playerid, COLOR_GREY, "You don't have any cigarettes on you.");
new Float:H;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
SetPlayerHealth(playerid, H+5);
GetPlayerHealth(playerid, H);
if(H > 100) SetPlayerHealth(playerid, 100);
PlayerInfo[playerid][pCigar] --;
format(string, sizeof(string), "* %s takes out a cigarette and lights it up.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetTimerEx("Regenation",10000,false,"dd",playerid,1);
}
pawn Код:
forward Regernation(playerid,times);
public Regernation(playerid,times)
{
if(times)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
if(Health > 100) SetPlayerHealth(playerid, 98.0);
else SetPlayerHealth(playerid, Health - 2.0);
SetTimerEx("Regenation",2000,false,"dd",playerid,1);
}
return 1;
}
And the second problem is how to make the timer minus a players health by 1 each minute after smoking the cigarette?