/Heal Command Errors, Can't Understand them or how to fix them
#1

Here is the Pastebin of the Command: http://pastebin.com/f34d93db8
and here are the Errors:
Код:
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(19) : error 029: invalid expression, assumed zero
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(19) : warning 215: expression has no effect
C:\Documents and Settings\User\Desktop\SAMP GameMode\gamemodes\GM.pwn(19) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Note: I have edited the lines of the error to fit to the Pastebin, so you can see where is the problem
Tried to figure out whats the problem there but with no success
Reply
#2

new HP = 100;
new HP=GetPlayerHealth(playerid);
Reply
#3

That code is wonked up in so many places, I don't know where to begin. You've got an if checking if the player using the command is connected, they have to be connected to use the command. It should be if(IsPlayerConnected(giveplayerid)). You've got code in and out of brackets everywhere. You need to rearrange that code to make sense. The funny one is you got an else statement giving the player an error on the if(IsPlayerConnected(playerid)) when it should be giving an error for the Faction check.
Reply
#4

You can't have an "else if" statement following on from nothing. You could have an else if statement after an if statement..

This statement here is completely pointless:

pawn Код:
new HP = 100;
                else if(HP <= 100)
                {
                  SetPlayerHealth(giveplayerid, 100);
                }
It can be replaced with this, which would get rid of the error you mentioned, and would save a couple of lines and some pointless processing!
pawn Код:
SetPlayerHealth(giveplayerid, 100);
EDIT:

pawn Код:
GetPlayerHealth(giveplayerid, HPCheck);
This won't work, as at no point have you defined giveplayerid! You either need to use strtok or sscanf! As the guy above me says, this script is broken in several places!
Reply
#5

about GivePlayerID i have it in the beginning of OnPlayerCommandText.
Now I'll try what you have suggested. Thanks
Reply
#6

BUMP
Tried as you suggested, It worked without errors in the Compiling
Tried it IG It just Heals me instead of asking me the PlayerID I want to heal and the Amount of money he has to pay for the Heal
Can you help me, Cuz I don't understand how to set that the Command will ask the player to do:
Код:
/Heal [PlayerName/PlayerID] [Heal Payment Amount]
instead of just healing the player who does:
Код:
/heal
Reply
#7

heres a MUCH MUCH simpler code for /heal

Код:
	if(strcmp("/heal",cmdtext,true)==0)
	{
		SetPlayerHealth(playerid,100);
		GivePlayerMoney(playerid,-10000);
		SendClientMessage(playerid, COLOR_GREEN, "Your health has been replenished.");
		return 1;
	}
Reply
#8

Quote:
Originally Posted by DanielBurridge
heres a MUCH MUCH simpler code for /heal

Код:
	if(strcmp("/heal",cmdtext,true)==0)
	{
		SetPlayerHealth(playerid,100);
		GivePlayerMoney(playerid,-10000);
		SendClientMessage(playerid, COLOR_GREEN, "Your health has been replenished.");
		return 1;
	}
He's after a heal script that heals the target player, and involves money, not simply a /heal script.

I can only assume that "giveplayer" and the amount are not properly strtok'ed.
Reply
#9

You should try using dcmd with sscanf instead of strtok. Much easier. Here is an example of how quick and easy dcmd with sscanf is.

pawn Код:
dcmd_givehealth(playerid, params[])
{
    new health;
    new string[128];
    if(lvl1[playerid] == 1 || lvlf[playerid] == 1)
    {
        if (sscanf(params, "di", id, health))
        {
            SendClientMessage(playerid, COLOR_WHITE, "Usage: \"/givehealth <playerid> <amount>\"");
        } else if (!IsPlayerConnected(id)) {
            SendClientMessage(playerid, COLOR_WHITE, "Player not found");
        } else {
          GetPlayerName(playerid, sendername, sizeof(sendername));
          GetPlayerName(id, giveplayer, sizeof(giveplayer));
            format(string, sizeof(string), "You healed %s with %d health", giveplayer,health);
            SendClientMessage(playerid, COLOR_GREEN2, string);
    } else {
      SendClientMessage(playerid, COLOR_WHITE, "You need to be Admin or to use this command");
    }
    return 1;
}
https://sampwiki.blast.hk/wiki/Fast_Commands
Reply
#10

Quote:
Originally Posted by [Fackin'
Pyro ]
You should try using dcmd with sscanf instead of strtok. Much easier. Here is an example of how quick and easy dcmd with sscanf is.

pawn Код:
dcmd_givehealth(playerid, params[])
{
    new health;
    new string[128];
    if(lvl1[playerid] == 1 || lvlf[playerid] == 1)
    {
        if (sscanf(params, "di", id, health))
        {
            SendClientMessage(playerid, COLOR_WHITE, "Usage: \"/givehealth <playerid> <amount>\"");
        } else if (!IsPlayerConnected(id)) {
            SendClientMessage(playerid, COLOR_WHITE, "Player not found");
        } else {
          GetPlayerName(playerid, sendername, sizeof(sendername));
          GetPlayerName(id, giveplayer, sizeof(giveplayer));
            format(string, sizeof(string), "You healed %s with %d health", giveplayer,health);
            SendClientMessage(playerid, COLOR_GREEN2, string);
    } else {
      SendClientMessage(playerid, COLOR_WHITE, "You need to be Admin or to use this command");
    }
    return 1;
}
https://sampwiki.blast.hk/wiki/Fast_Commands
Well, I'm kinda a Scripter Beginner, Learning the Laguage...
and DCMD is kinda complicated for me...
Can you Re-Write it into if(strcmp(cmd, "/heal", true) == 0) ?
I'll appreciate it allot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)