SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 20/08/2009, 02:26 PM   #1
dafel2
Huge Clucker
 
Join Date: Jan 2007
Posts: 231
Reputation: 1
Default /heal playerid

Code:
dcmd_heal(playerid,params[])
{
  new PlayerName[MAX_PLAYER_NAME];
  new Float:tmp3;
	new Float:px, Float:py, Float:pz;
	new string[128];
	new giveplayerid;
	new idx,tmpit[256];
	tmpit = strtok(params,idx);
 	giveplayerid = ReturnUser(tmpit);
	GetPlayerPos(giveplayerid,px,py,pz);
  if(sscanf(params,"i",strval(params))) SendClientMessage(playerid,COLOR_RED,"Usage: /heal <playerid>");
  if(!PlayerToPoint(3.0,playerid,px,py,pz)) return SendClientMessage(playerid, COLOR_RED, "You are not close enough!");
  if(PlayerInventoryPlayerHasItem(playerid,"Small HP Pack")) return SendClientMessage(playerid, COLOR_RED, "You Dont Have Medkit");
  {
  else // ERROR
  {
    if(!IsPlayerConnected(strval(params))) return SendClientMessage(playerid,COLOR_RED,"Error, player not found!");
    GetPlayerHealth(playerid,tmp3);
    SetPlayerHealth(playerid,tmp3+20);
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    format(string,sizeof(string),"You have been healed by %s",PlayerName(strval(params))); //ERROR line 3614
    SendClientMessage(strval(params),COLOR_RED,string);
  }
  }
  return 1;
}
Code:

(3608) : error 029: invalid expression, assumed zero
(3614) : error 012: invalid function call, not a valid address
(3614) : error 001: expected token: ";", but found ")"
(3614) : error 029: invalid expression, assumed zero
(3614) : fatal error 107: too many error messages on one line
Commented where are errors.
Can someone help me fix these errors?
dafel2 is offline  
Old 20/08/2009, 02:29 PM   #2
Redgie
Huge Clucker
 
Join Date: Aug 2007
Posts: 206
Reputation: 13
Default Re: /heal playerid

Code:
format(string,sizeof(string),"You have been healed by %s",PlayerName(strval(params))); //ERROR line 3614
Should be

Code:
format(string,sizeof(string),"You have been healed by %s",PlayerName(strval(params)); //ERROR line 3614
Also, you used else without giving it anything to do, it should look like this (This is with both errors fixed)

Code:
dcmd_heal(playerid,params[])
{
  new PlayerName[MAX_PLAYER_NAME];
  new Float:tmp3;
	new Float:px, Float:py, Float:pz;
	new string[128];
	new giveplayerid;
	new idx,tmpit[256];
	tmpit = strtok(params,idx);
 	giveplayerid = ReturnUser(tmpit);
	GetPlayerPos(giveplayerid,px,py,pz);
  if(sscanf(params,"i",strval(params))) SendClientMessage(playerid,COLOR_RED,"Usage: /heal <playerid>");
  if(!PlayerToPoint(3.0,playerid,px,py,pz)) return SendClientMessage(playerid, COLOR_RED, "You are not close enough!");
  if(PlayerInventoryPlayerHasItem(playerid,"Small HP Pack"))
  {
    SendClientMessage(playerid, COLOR_RED, "You Dont Have Medkit");
    return 1;
	}
  if(!IsPlayerConnected(strval(params))) return SendClientMessage(playerid,COLOR_RED,"Error, player not found!");
  GetPlayerHealth(playerid,tmp3);
  SetPlayerHealth(playerid,tmp3+20);
  GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
  format(string,sizeof(string),"You have been healed by %s",PlayerName(strval(params)); //ERROR line 3614
  SendClientMessage(strval(params),COLOR_RED,string);
  return 1;
}
Redgie is offline  
Old 20/08/2009, 02:31 PM   #3
dafel2
Huge Clucker
 
Join Date: Jan 2007
Posts: 231
Reputation: 1
Default Re: /heal playerid

Fixed the
Code:
else
error


but same error at line 3614 :/
dafel2 is offline  
Old 20/08/2009, 02:31 PM   #4
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: /heal playerid

I suggest you to do
pawn Code:
format(string,sizeof string,"You have been healed by %s.",PlayerName(giveplayerid));
MenaceX^ is offline  
Old 20/08/2009, 02:37 PM   #5
dafel2
Huge Clucker
 
Join Date: Jan 2007
Posts: 231
Reputation: 1
Default Re: /heal playerid

Quote:
Originally Posted by revenngeR
Fixed the
Code:
else
error


but same error at line 3614 :/
dafel2 is offline  
Old 20/08/2009, 02:41 PM   #6
sandisk125
Big Clucker
 
Join Date: Jul 2009
Posts: 186
Reputation: 0
Default Re: /heal playerid

Quote:
Originally Posted by revenngeR
Quote:
Originally Posted by revenngeR
Fixed the
Code:
else
error


but same error at line 3614 :/
so show your line 3614,how we can answer you?!
sandisk125 is offline  
Old 20/08/2009, 02:42 PM   #7
dafel2
Huge Clucker
 
Join Date: Jan 2007
Posts: 231
Reputation: 1
Default Re: /heal playerid

Quote:
Originally Posted by sandisk125
Quote:
Originally Posted by revenngeR
Quote:
Originally Posted by revenngeR
Fixed the
Code:
else
error


but same error at line 3614 :/
so show your line 3614,how we can answer you?!
i have commented it

Code:
dcmd_heal(playerid,params[])
{
  new PlayerName[MAX_PLAYER_NAME];
  new Float:tmp3;
	new Float:px, Float:py, Float:pz;
	new string[128];
	new giveplayerid;
	new idx,tmpit[256];
	tmpit = strtok(params,idx);
 	giveplayerid = ReturnUser(tmpit);
	GetPlayerPos(giveplayerid,px,py,pz);
  if(sscanf(params,"i",strval(params))) SendClientMessage(playerid,COLOR_RED,"Usage: /heal <playerid>");
  if(!PlayerToPoint(3.0,playerid,px,py,pz)) return SendClientMessage(playerid, COLOR_RED, "You are not close enough!");
  if(PlayerInventoryPlayerHasItem(playerid,"Small HP Pack"))
  {
    SendClientMessage(playerid, COLOR_RED, "You Dont Have Medkit");
    return 1;
	}
  if(!IsPlayerConnected(strval(params))) return SendClientMessage(playerid,COLOR_RED,"Error, player not found!");
  GetPlayerHealth(playerid,tmp3);
  SetPlayerHealth(playerid,tmp3+20);
  GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
  format(string,sizeof(string),"You have been healed by %s",PlayerName(strval(params)); //ERROR line 3615 same errors as before
  SendClientMessage(strval(params),COLOR_RED,string);
  return 1;
}
dafel2 is offline  
Old 20/08/2009, 02:47 PM   #8
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: /heal playerid

You didn't fix the missed bracket.. add one more to strval(params[0])
MenaceX^ is offline  
Old 20/08/2009, 02:59 PM   #9
dafel2
Huge Clucker
 
Join Date: Jan 2007
Posts: 231
Reputation: 1
Default Re: /heal playerid

Quote:
Originally Posted by MenaceX^
You didn't fix the missed bracket.. add one more to strval(params[0])
now i only have

Code:
 error 012: invalid function call, not a valid address
dafel2 is offline  
Old 20/08/2009, 05:00 PM   #10
craponnaruto
Big Clucker
 
Join Date: Jul 2009
Posts: 138
Reputation: 0
Default Re: /heal playerid

What line is the error on?You can find out by looking at the number before the error.
craponnaruto is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's wrong with skins? GetPlayerSkin(playerid) & SetPlayerSkin(playerid, skin) McSquizzy Help Archive 7 16/04/2010 02:27 PM
Help with if(MedicBill[playerid] == 1 && PlayerInfo[playerid][pJailed] == 0 && Keeboo13 Help Archive 0 11/04/2010 05:38 AM
WG40[playerid] = 1; For everyone not only playerid? pawelf94 Help Archive 4 23/12/2009 03:31 PM
Help please /heal <playerid> Klutty Help Archive 2 23/05/2009 12:48 PM


All times are GMT. The time now is 09:06 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.