takedrugs - 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: takedrugs (
/showthread.php?tid=418308)
takedrugs -
Markus1337 - 24.02.2013
Is there any other way I can do this? Doesnt work very well.. just sets my health to 20 or something.
What did I do wrong
pawn Код:
CMD:givemedrugs(playerid, params[])
{
SendClientMessage(playerid, -1,"You have received 1 drugs");
PlayerInfo[playerid][pHasDrugs]++;
return 1;
}
CMD:takedrugs(playerid, params[])
{
if(PlayerInfo[playerid][pHasDrugs] >= 1)
{
UseDrugs1[playerid] = SetTimerEx("UseDrugs", 1000, true, "i", playerid);
SetTimer("KillUseDrugs", 50000, false);
}
else if(PlayerInfo[playerid][pHasDrugs] >= 0)
{
SendClientMessage(playerid, COL_RED,"You do not have any drugs.");
}
return 1;
}
forward KillUseDrugs(playerid);
public KillUseDrugs(playerid)
{
KillTimer(UseDrugs1[playerid]);
return 1;
}
forward UseDrugs(playerid);
public UseDrugs(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 10.0)
{
SetPlayerHealth(playerid, 20.0);
}
else if (health > 20.0)
{
SetPlayerHealth(playerid, 25.0);
}
else if (health > 25.0)
{
SetPlayerHealth(playerid, 30.0);
}
else if (health > 30.0)
{
SetPlayerHealth(playerid, 35.0);
}
else if (health > 35.0)
{
SetPlayerHealth(playerid, 40.0);
}
else if (health > 40.0)
{
SetPlayerHealth(playerid, 45.0);
}
else if (health > 45.0)
{
SetPlayerHealth(playerid, 50.0);
}
else if (health > 50.0)
{
SetPlayerHealth(playerid, 55.0);
}
else if (health > 55.0)
{
SetPlayerHealth(playerid, 60.0);
}
else if (health > 60.0)
{
SetPlayerHealth(playerid, 65.0);
}
else if (health > 65.0)
{
SetPlayerHealth(playerid, 70.0);
}
else if (health > 70.0)
{
SetPlayerHealth(playerid, 75.0);
}
else if (health > 75.0)
{
SetPlayerHealth(playerid, 80.0);
}
else if (health > 80.0)
{
SetPlayerHealth(playerid, 85.0);
}
else if (health > 85.0)
{
SetPlayerHealth(playerid, 90.0);
}
else if (health > 90.0)
{
SetPlayerHealth(playerid, 95.0);
}
else if (health > 95.0)
{
SetPlayerHealth(playerid, 100.0);
}
return 1;
}
Re: takedrugs -
Da_Noob - 24.02.2013
You're KillUseDrugs public function isn't needed.
It should look something like this:
pawn Код:
CMD:givemedrugs(playerid, params[])
{
SendClientMessage(playerid, -1,"You have received 1 drugs");
PlayerInfo[playerid][pHasDrugs]++;
return 1;
}
CMD:takedrugs(playerid, params[])
{
if(PlayerInfo[playerid][pHasDrugs] >= 1)
{
UseDrugs1[playerid] = SetTimerEx("UseDrugs", 1000, true, "i", playerid);
}
else if(PlayerInfo[playerid][pHasDrugs] >= 0)
{
SendClientMessage(playerid, COL_RED,"You do not have any drugs.");
}
return 1;
}
forward UseDrugs(playerid);
public UseDrugs(playerid)
{
KillTimer(UseDrugs1[playerid]);
new float:health, float:newhealth;
GetPlayerHealth(playerid,health);
newhealth = health + 5;
SetPlayerHealth(playerid, newhealth);
return 1;
}
Try this, this will add 5 HP to the person's HP level.
Re: takedrugs -
Markus1337 - 24.02.2013
I get tag mismatch on "health" and "newhealth"
pawn Код:
public UseDrugs(playerid)
{
KillTimer(UseDrugs1[playerid]);
new float:health, float:newhealth;
GetPlayerHealth(playerid, health);
newhealth = health + 5;
SetPlayerHealth(playerid, newhealth);
return 1;
}
Re: takedrugs -
Da_Noob - 24.02.2013
Try this
pawn Код:
public UseDrugs(playerid)
{
KillTimer(UseDrugs1[playerid]);
new float:health, float:newhealth = 5;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health + newhealth);
return 1;
}
I don't know if it'll work, give it a shot.