A little problem with the heal command
#1

ok so here`s the code for the /heal command

Код:
dcmd_heal(playerid,params[])
{
  #pragma unused params
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	if(IsPlayerInCheckpoint(playerid) == 1)
 	{
 	  if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			SendClientMessage(playerid,COLOUR_RED,"You must be on foot. Get out of the vehicle!");
		}
		else
		{
			new PRICE = 1000;
			if(PRICE <= GetPlayerMoney(playerid))
	 		{
				GivePlayerMoney(playerid, - PRICE);
				SetPlayerHealth(playerid, 100);
				SetPlayerArmour(playerid, 100);
				SendClientMessage(playerid,COLOUR_GREEN,"You have been succesfully healed. Have fun!");
			}
			else
		  {
		    SendClientMessage(playerid,COLOUR_GREEN,"You need 1000$ to heal and armor yourself!");
			}
  		}
	else SendClientMessage(playerid,COLOUR_RED,"You must be at the Hospital!");
	}
	return 1;
}
and here`s the error it gives

Код:
C:\DOCUME~1\Master\Desktop\SANFIE~2\GAMEMO~1\SF-MW1~1.PWN(225) : error 029: invalid expression, assumed zero
hope you can help me ASAP
Reply
#2

I'm assuming the error line is GivePlayerMoney.

You should do:
pawn Код:
GivePlayerMoney(playerid, GetPlayerMoney(playerid0) - PRICE);
Reply
#3

That's just enlarging problem, but if it is there, and simple - don't work, just use old nice *(-1) it just works, it would be like this
GivePlayerMoney(playerid,PRICE*(-1));
Reply
#4

actually, if I change with

GivePlayerMoney(playerid, GetPlayerMoney(playerid0) - PRICE);

I still get the same problem, so that`s not the problem
Reply
#5

Post the exact line where the error is showing.
Reply
#6

Ok, sorry for everyone who i started to help - i'm leaving for some hours, and just post the error line (ctr+g if you can't find where...) and hope for help.

AND SERIUSLY GET IT, THE OTHER CODE YOU'RE POSTING IS WRONG, YOU JUST GET HIS MONEY, THEN GIVE IT TO HIM, AND THEN TAKE 1000$, IF YOU GOT IT, THEN YES IT GIVES YOUR MONEY IN DOUBLE AND TAKES 1000$ WHAT CAN BE SMALL MONEY.
Reply
#7

Quote:
Originally Posted by gotenks918
Post the exact line where the error is showing.
the exact line is

else SendClientMessage(playerid,COLOUR_RED,"You must be at the Hospital!");
Reply
#8

try this:

pawn Код:
dcmd_heal(playerid,params[])
{
  #pragma unused params
  new Float:x, Float:y, Float:z;
  GetPlayerPos(playerid, x, y, z);
  if(IsPlayerInCheckpoint(playerid) == 1){
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOUR_RED,"You must be on foot. Get out of the vehicle!");
    new PRICE = 1000;
    if(PRICE <= GetPlayerMoney(playerid)){
      GivePlayerMoney(playerid, - PRICE);
      SetPlayerHealth(playerid, 100);
      SetPlayerArmour(playerid, 100);
      return SendClientMessage(playerid,COLOUR_GREEN,"You have been succesfully healed. Have fun!");
    }
    else return SendClientMessage(playerid,COLOUR_GREEN,"You need 1000$ to heal and armor yourself!");
  }
  else return SendClientMessage(playerid,COLOUR_RED,"You must be at the Hospital!");
}
Reply
#9

It works! Thanks alot!

Tho` I have another problem now. I`m trying to add a pickup and I wrote this:

Код:
#define HEAL_POSITION 0 // defined the heal pos

HEAL_POSITION = AddStaticPickup(1239, 1, -2695.4238, 639.0695, 14.4531, -1); //put this under OnPlayerConnect()
and it gives me this:

error 022: must be lvalue (non-constant)
Reply
#10

https://sampwiki.blast.hk/wiki/CreatePickup
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)