Chemicals system. - 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: Chemicals system. (
/showthread.php?tid=597426)
Chemicals system. -
Shovelizer - 31.12.2015
So yeah,I've been trying to make a chemical system which is basically a drug system.
In this system when I use crack I get a 5 second timer where I can use chemicals which give me even more armor.
The problem is that I can only use chemicals once within that 5 second timer.
Can someone help me?
Here's the code
Код:
CMD:usecrack(playerid,params[]) //Where I use crack//
{
GetPlayerArmour(playerid, Armour);
if(crack < 2)
{
SendClientMessage(playerid, COLOR_RED, "You don't have enough crack");
return 1;
}
else if(Armour > 99)
{
SendClientMessage(playerid, COLOR_RED, "You have enough armour");
return 1;
}
else
{
crack -= 2;
SendClientMessage(playerid, COLOR_GREEN, "You've used some crack");
SetPlayerArmour(playerid, Armour+10);
SetTimerEx("Chem", 5000, false, "i", playerid);
ChemTimer = 1;
return 1;
}
}
This is my use chems code below
Код:
CMD:usechems(playerid, params[])
{
if(chems < 2)
{
SendClientMessage(playerid, COLOR_RED, "You don't have enough chems");
return 1;
}
else if(ChemTimer == 0)
{
SendClientMessage(playerid, COLOR_RED, "You need to use crack first inorder to use chems");
return 1;
}
else if(Armour > 99)
{
SendClientMessage(playerid, COLOR_RED, "You have enough armour");
return 1;
}
else
{
chems -= 2;
SendClientMessage(playerid, COLOR_RED, "You've used some chems");
SetPlayerArmour(playerid, Armour+20);
return 1;
}
}
Here is all the New,Forward,and Public
Код:
new pot,crack,chems;
new Float:Armour;
forward Chem(playerid);
new ChemTimer;
public Chem(playerid)
{
ChemTimer = 0;
return 1;
}
Pls Don't bash me about my bad coding skills,I've been learning it only for a few days
Re: Chemicals system. -
JimmyCh - 31.12.2015
I would suggest using SetTimer(funcname[], interval, repeating) and KillTimer(timerid) which would actually work in this case with no problems.
Re: Chemicals system. -
Shovelizer - 03.01.2016
How?