Timer on command problem [Solved]
#1

Код:
 	if(strcmp(cmdtext, "/usedrugs", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  	{
			if(PlayerInfo[playerid][pDrugs] > 1)
			{
				if(UseDrugs[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "You have to wait 30secounds before using drugs again.");
				{
	  			 	new Float:armour;
			  	GetPlayerArmour(playerid, armour);
			  	if(armour < 100.0)
				  {
	        	SetPlayerArmour(playerid, armour + 15.0);
	        }
			  	SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[INFO:] 2 grams used.");
			  	PlayerInfo[playerid][pDrugs] -= 2;
			  	PlayerActionMessage(playerid,15.0,"has just took some drugs.");
			  	DrugsIntake[playerid] += 2;
			  	if(DrugsIntake[playerid] >= 2)
    			{
				  	SetTimerEx("DrugEffect", 1000, false, "i", playerid);
				  	}
					SetTimer("UseDrugs", 30000, false);
		 		}
				else SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You don't have any drugs.");
				}
 		}
		return 1;
	}
Код:
(9233) : error 029: invalid expression, assumed zero
Line 9233 is "else SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You don't have any drugs.");"
I have got some help but nothing fixed the error, thats why im now making a thread about it.

Reply
#2

Try

pawn Код:
if(strcmp(cmdtext, "/usedrugs", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pDrugs] > 1)
{
if(UseDrugs[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "You have to wait 30 secounds before using drugs again.");
{
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour < 100.0)
{
SetPlayerArmour(playerid, armour + 15.0);
}
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[INFO:] 2 grams used.");
PlayerInfo[playerid][pDrugs] -= 2;
PlayerActionMessage(playerid,15.0,"has just took some drugs.");
DrugsIntake[playerid] += 2;
if(DrugsIntake[playerid] >= 2)
{
SetTimerEx("DrugEffect", 1000, false, "i", playerid);
}
SetTimer("UseDrugs", 30000, false);
return 1;
}
else return SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You don't have any drugs.");
}
pawn Код:
if(strcmp(cmdtext, "/usedrugs", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pDrugs] > 1)
{
if(UseDrugs[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "You have to wait 30 secounds before using drugs again.");
{
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour < 100.0)
{
SetPlayerArmour(playerid, armour + 15.0);
}
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[INFO:] 2 grams used.");
PlayerInfo[playerid][pDrugs] -= 2;
PlayerActionMessage(playerid,15.0,"has just took some drugs.");
DrugsIntake[playerid] += 2;
if(DrugsIntake[playerid] >= 2)
{
SetTimerEx("DrugEffect", 1000, false, "i", playerid);
}
SetTimer("UseDrugs", 30000, false);
}
return 1;
}
else return SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You don't have any drugs.");
}
I am not sure about this, but try it anyways.
Reply
#3

Thank you for the help. this one worked.
pawn Код:
if(strcmp(cmdtext, "/usedrugs", true) == 0)
    {
      if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pDrugs] > 1)
            {
                if(CommandUsed[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "You have to wait 30secounds before using drugs again.");
                {
                    new Float:armour;
                GetPlayerArmour(playerid, armour);
                if(armour < 100.0)
                  {
                SetPlayerArmour(playerid, armour + 15.0);
            }
                SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[INFO:] 2 grams used.");
                PlayerInfo[playerid][pDrugs] -= 2;
                PlayerActionMessage(playerid,15.0,"has just took some drugs.");
                DrugsIntake[playerid] += 2;
                if(DrugsIntake[playerid] >= 2)
                {
                    SetTimerEx("DrugEffect", 1000, false, "i", playerid);
                    }
                    CommandUsed[playerid] = -1;
                    SetTimer("ResetCmd", 30000, false);
                }
            }
            else SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You don't have any drugs.");
            }
        return 1;
    }
Only thing i need to know now, is where to put "CommandUsed[i] = 0;"
Reply
#4

Sorry for double post.

I use the code from above.
Problem: When i /usedrugs ingame then the timer kicks in But it dosnt reset the command after 30sec, it just disable it.(so i cant use it more than one time).

EDIT: I missed a line thats why it didnt work-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)