[HELP]Help me plz
#1

I create command:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new idx;
	cmd = strtok(cmdtext, idx);
	if (strcmp(cmd, "/test", true) == 0)
	{
		new tmp[256];
		tmp = strtok(cmdtext, idx);
		new tested = strval(tmp);
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid, COLOR_RED, "Используйте /test <ID>");
		  return 1;
		}
		else
		{
			new Float:playerh;
			new health;
			health = GetPlayerHealth(tested, playerh);
			new saved;
      if(health == 1)
      {
      SendClientMessage(playerid, COLOR_RED, "Мало хп");
      }
			else
			{
			  GetPlayerHealth(tested, health);
			  health = saved;
			  SetPlayerHealth(tested, health-1);
        if(health == saved)
        {
          SendClientMessage(playerid, COLOR_RED, "Плохой результат");
			    SetPlayerHealth(tested, health+1);
        }
			}
			else
			{
			  SendClientMessage(playerid, COLOR_GREEN, "Хороший результат");
			  SetPlayerHealth(tested, health+1);
			}
		}
	}
	return 0;
}
When i compile this, pawno show me:
Код:
C:\DOCUME~1\CRAZYS~1\0016~1\server\FILTER~1\th.pwn(58) : warning 213: tag mismatch
C:\DOCUME~1\CRAZYS~1\0016~1\server\FILTER~1\th.pwn(67) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Lines:
Код:
55      }
56			else
57			{
58			  GetPlayerHealth(tested, health);
and
Код:
64			    SetPlayerHealth(tested, health+1);
65        }
66			}
67			else
68			{
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp(cmd, "/test", true) == 0)
    {
        new tmp[256];
        tmp = strtok(cmdtext, idx);
        new tested = strval(tmp);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_RED, "Используйте /test <ID>");
            return 1;
        }
        else
        {
            new Float:health;
            GetPlayerHealth(tested, health);
            //getplayerhealth dont return a value, the variable health will get the current health from the player
            new Float:saved;
            if(health == 1.00)
            {
                SendClientMessage(playerid, COLOR_RED, "Мало хп");
            }
            else
            {
                GetPlayerHealth(tested, health); //get the health a second time ??? unused ...
                health = saved; //set the variable to 0.00 because saved is 0.00
                SetPlayerHealth(tested, health-1); //set the players health to -1 so he die
                if(health == saved)
                {
                    SendClientMessage(playerid, COLOR_RED, "Плохой результат");
                    SetPlayerHealth(tested, health+1); //set his health +1 also to 0 but thats already unused because he is dead
                }
            }
            else //a else after a else dont work
            {
                SendClientMessage(playerid, COLOR_GREEN, "Хороший результат");
                SetPlayerHealth(tested, health+1);
            }
        }
    }
    return 0;
}
Reply
#3

i like your script and its helped me learn how to do it.
I have one problem when trying your script... i get this..

: error 029: invalid expression, assumed zero

and it points to
Quote:

else
{
SendClientMessage(playerid, COLOR_WHITE, "Хороший результат");
SetPlayerHealth(tested, health+1);

Any suggestions?
Reply
#4

GetPlayerHealth() currently is bugged apparently.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)