1 error.
#1

Hello, i got little error. what's the problem?

ATTENTION: DO NOT Give me a NEW command that YOU made, ONLY fix the error.

PHP код:
CMD:healme(playeridparams[])
{
  new 
Float:health;
  if(
GetPlayerMoney(playerid) < 900) return SendClientMessage(playerid, -1"{FF0000}You don't have enough cash to heal yourself.");
  
SendClientMessage(playerid, -1"{00CC00}You have healed your self.");
  
GetPlayerHealth(playeridhealth);
  
SetPlayerHealth(playerid100);
  else 
// that line<<<<<<<<<<<<<
  
{
    
SetTimer("ICanHeal"480000true);
    
SendClientMessage(playerid, -1"{FF0000}You can't heal yourself now.");
  }
  if(
health == 100)
  {
      return 
SendClientMessage(playerid, -1"{FF0000}Your health is already full.");
  }
  return 
1;
}
forward ICanHeal(playerid);
public 
ICanHeal(playerid)
{
  
SendClientMessage(playerid, -1"{FF0000}You can heal yourself now. [/Healme]");
  return 
1;

invalid expression, assumed zero
Reply
#2

which line ??
Reply
#3

There should be an 'if' statement before you use 'else'.
Reply
#4

Quote:
Originally Posted by Stuun23
Посмотреть сообщение
Hello, i got little error. what's the problem?

ATTENTION: DO NOT Give me a NEW command that YOU made, ONLY fix the error.

PHP код:
CMD:healme(playeridparams[])
{
  new 
Float:health;
  if(
GetPlayerMoney(playerid) < 900) return SendClientMessage(playerid, -1"{FF0000}You don't have enough cash to heal yourself.");
  
SendClientMessage(playerid, -1"{00CC00}You have healed your self.");
  
GetPlayerHealth(playeridhealth);
  
SetPlayerHealth(playerid100);
  else 
// that line<<<<<<<<<<<<<
  
{
    
SetTimer("ICanHeal"480000true);
    
SendClientMessage(playerid, -1"{FF0000}You can't heal yourself now.");
  }
  if(
health == 100)
  {
      return 
SendClientMessage(playerid, -1"{FF0000}Your health is already full.");
  }
  return 
1;
}
forward ICanHeal(playerid);
public 
ICanHeal(playerid)
{
  
SendClientMessage(playerid, -1"{FF0000}You can heal yourself now. [/Healme]");
  return 
1;

invalid expression, assumed zero
This should work:
pawn Код:
new heal[MAX_PLAYERS];
CMD:healme(playerid, params[])
{
  new Float:health;
  if(GetPlayerMoney(playerid) < 900) return SendClientMessage(playerid, -1, "{FF0000}You don't have enough cash to heal yourself.");
  if(heal[playerid] == 1) return SendClientMessage(playerid, -1, "{FF0000}You cant heal yourself.");
  if(health == 100)
  {
      return SendClientMessage(playerid, -1, "{FF0000}Your health is already full.");
  }
  SendClientMessage(playerid, -1, "{00CC00}You have healed your self.");
  heal[playerid] = 1;
  GetPlayerHealth(playerid, health);
  SetPlayerHealth(playerid, 100);
  SetTimer("ICanHeal", 480000, true);
  SendClientMessage(playerid, -1, "{FF0000}You can't heal yourself now.");
  return 1;
}
forward ICanHeal(playerid);
public ICanHeal(playerid)
{
  SendClientMessage(playerid, -1, "{FF0000}You can heal yourself now. [/Healme]");
  heal[playerid] = 0;
  return 1;
}
Reply
#5

It should be 0
pawn Код:
if(heal[playerid] == 0) return SendClientMessage(playerid, -1, "{FF0000}You cant heal yourself.");
Reply
#6

Quote:
Originally Posted by Ironboy
Посмотреть сообщение
It should be 0
pawn Код:
if(heal[playerid] == 0) return SendClientMessage(playerid, -1, "{FF0000}You cant heal yourself.");
No, why?
Reply
#7

You cannot use functions between "if" and "else" statements.
I'll show a quick example underneath.

This wont work.
pawn Код:
if(something) // Codes
SetPlayerHealth(playerid, 100)
// Codes between if and else ^
else // Codes
Although this will work.
pawn Код:
if(something) // Codes
else // Codes
SetPlayerHealth(playerid, 100)
// Codes not between if and else ^
Therefore you gotta do this:
pawn Код:
if(GetPlayerMoney(playerid) < 900) return SendClientMessage(playerid, -1, "{FF0000}You don't have enough cash to heal yourself.");
else
{
    SetTimer("ICanHeal", 480000, true);
    SendClientMessage(playerid, -1, "{FF0000}You can't heal yourself now.");
}
SendClientMessage(playerid, -1, "{00CC00}You have healed your self.");
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, 100);
EDIT: After looking on your script, you might have wanted to create an else instead of the functions, without using the "if"?
You always need an "if" to activate an "else".
Reply
#8

You could use SetTimerEx instead of using a global timer.
Reply
#9

I did something like that, will it work?

PHP код:
CMD:healme(playeridparams[])
{
   new 
Float:health;
   if(
GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, -1"{FF0000}ERROR: You don't got enough cash to heal yourself.");
   if(
heal[playerid] < 90) return SendClientMessage(playerid, -1"{FF0000}No need to heal yourself. Only if it's lower than 90 you can heal yourself.");
   if(
health 100)
   {
     
SetPlayerHealth(playerid100);
     
SendClientMessage(playerid, -1"{FF9933}You have healed yourself.");
     
SetTimerEx("HealMessage"480000false"i"playerid);
   }
   else
   {
     
SendClientMessage(playerid, -1"{FF0000}You can't heal yourself now.");
     
heal[playerid] = 0;
   }
   return 
1;
}
forward HealMessage(playerid);
public 
HealMessage(playerid)
{
  
SendClientMessage(playerid, -1"{FF0000}You can heal yourself now.");
  
heal[playerid] = 1;
  return 
1;

And at the top new heal[MAX_PLAYERS];, No errors.
Reply
#10

Код:
   
   if(health < 100)
   {
     SetPlayerHealth(playerid, 100);
     SendClientMessage(playerid, -1, "{FF9933}You have healed yourself.");
     SetTimerEx("HealMessage", 480000, false, "i", playerid);
     heal[playerid] = 0;
   }
   else if(heal == 0)
   {
     SendClientMessage(playerid, -1, "{FF0000}You can't heal yourself now.");
   }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)