31.03.2014, 01:55
I've been sitting around trying to work on and really make a good drug system. I've only gotten around to crack so far, but it has all been going along nicely until now. My issue is that I have a system where if the player uses 6 grams of crack - they will overdose and need to get medical attention. I haven't fully implemented the EMS group, so the command I made to kill the timer and heal the player is healcrackoverdose. Well, the thing is that it's not working. I've tried timer ID 0, 1, and 2. It should be 0 as this was the first timer I've created in my entire script. Can someone tell me my issue?
Here is a good portion of all of the code I've made:
And then here is the rest:
And then that right there I put under OnPlayerConnect.
Here is a good portion of all of the code I've made:
PHP код:
CMD:usecrack(playerid, params[])
{
if(UseDrugsTimer[playerid]) return SendClientMessage(playerid,COLOR_GREY,"You must wait 5 seconds!");
if(PlayerCrackStoned[playerid] >= 5)
{
SendClientMessage(playerid, COLOR_RED, "You have used too much crack; therefore you have overdosed!");
SendClientMessage(playerid, COLOR_RED, "You must seek medical attention or you will die!");
SetTimerEx("Crackdeath", 10000, true, "i", playerid);
}
if(PlayerCrackStoned[playerid] >= 2)
{
GameTextForPlayer(playerid, "~w~You are~n~~p~Stoned", 4000, 1);
SetPlayerDrunkLevel(playerid, 15000);
SetPlayerWeather(playerid, 2009);
}
if(PlayerDrugInfo[playerid][pCrack] >= 1)
{
new Float:armor;
GetPlayerArmour(playerid, armor);
if(armor > 80) { SetPlayerArmour(playerid, 100.0); }
else { SetPlayerArmour(playerid, armor + 10.0); }
PlayerCrackStoned[playerid] += 1;
SendClientMessage(playerid, COLOR_BLUE, "You have used a gram of crack!");
UseDrugsTimer[playerid] = 1; PlayerDrugInfo[playerid][pCrack] -= 1;
SetTimerEx("UseDrugs",5*1000,0,"i",playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You don't have any crack left!");
}
return 1;
}
forward UseDrugs(playerid);
forward Crackdeath(playerid);
public UseDrugs(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(UseDrugsTimer[playerid])
{
UseDrugsTimer[playerid] = 0;
}
return 1;
}
public Crackdeath(playerid)
{
new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid,hp-5);
}
CMD:healcrackoverdose(playerid, params[])
{
SetPlayerHealth(playerid, 100);
KillTimer();
return 1;
}
PHP код:
new PlayerCrackStoned[MAX_PLAYERS];
new UseDrugsTimer[MAX_PLAYERS];
PHP код:
PlayerCrackStoned[playerid] = 0;
UseDrugsTimer[playerid] = 0;