PDA

View Full Version : [PROBLEM] Armour and Health (MAX)


spyro9696
12/08/2017, 07:28 AM
Hello, I have another problem... I don't know how to set directly to the maximum health and armour.
When I type /health and /armour, it don't set me the max health and armour, but it requires a number.
Ex: /health 100
So, is it possible set your health and armour directly to the maximum typing /health and /armour?

This is the code:

COMMAND:armour(playerid, params[])
{
new id;
if (sscanf(params, "i", id))
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /armour <armour>");
SetPlayerArmour(playerid, id);
// Do something
return 1;
}

COMMAND:health(playerid, params[])
{
new id;
if (sscanf(params, "i", id))
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /health <health>");
SetPlayerHealth(playerid, id);
// Do something
return 1;
}

Zeth
12/08/2017, 07:33 AM
Yes it is possible.
Check this out:
COMMAND:armour(playerid, params[])
{
//new id;
//if (sscanf(params, "i", id))
//return SendClientMessage(playerid, 0xFF0000AA, "Usage: /armour <armour>");
SetPlayerArmour(playerid, 100);
// Do something
return 1;
}

COMMAND:health(playerid, params[])
{
//new id;
//if (sscanf(params, "i", id))
//return SendClientMessage(playerid, 0xFF0000AA, "Usage: /health <health>");
SetPlayerHealth(playerid, 100);
// Do something
return 1;
}

JaKe Elite
12/08/2017, 07:35 AM
COMMAND:armour(playerid, params[])
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, -1, "Armour refilled.");
return 1;
}

COMMAND:health(playerid, params[])
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, -1, "Health refilled.");
return 1;
}

Zeth
12/08/2017, 07:37 AM
COMMAND:armour(playerid, params[])
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, -1, "Armour refilled.");
return 1;
}

COMMAND:health(playerid, params[])
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, -1, "Health refilled.");
return 1;
}


That is what i said above.

spyro9696
12/08/2017, 07:44 AM
COMMAND:armour(playerid, params[])
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, -1, "Armour refilled.");
return 1;
}

COMMAND:health(playerid, params[])
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, -1, "Health refilled.");
return 1;
}



Jake, when I compile, it gives me these errors
http://i.imgur.com/vV4x2co.png

Astralis
12/08/2017, 07:51 AM
Remove ,params[] on each command.

spyro9696
12/08/2017, 08:09 AM
Remove ,params[] on each command.

Ok, but now there are errors only in line 476
http://i.imgur.com/NH1PYhk.png

GuilhermeNunes
12/08/2017, 09:06 AM
CMD:life(playerid)
{
SetPlayerHealth(playerid, 100);
return 1;
}


CMD:armour(playerid)
{
SetPlayerArmour(playerid,100);
return 1;

}

Put in your Code

Qbao
12/08/2017, 09:55 AM
Did you try this command? :D :D
COMMAND:armour(playerid, params[])
{
SetPlayerArmor(playerid, 100);
SendClientMessageEx(playerid, 0x00FF00, "Armour refilled.");
}
//
COMMAND:health(playerid, params[])
{
SetPlayerHealth(playerid, 100);
SendClientMessageEx(playerid, 0x00FF00, "Health refilled.");
}

spyro9696
12/08/2017, 11:42 AM
nothing... errors, errors, errors.... :mad:

Immortal99
12/08/2017, 11:47 AM
It looks like you putting this under another function or somethings wrong above in your script ???

spyro9696
12/08/2017, 11:53 AM
I resolved: I copied and pasted the message into pawno... I writed it manually and now it works.
Thanks.

HoussamMaroc
12/08/2017, 11:43 PM
I think this will fix your error

COMMAND:armour(playerid, params[])
{
new id;
if (sscanf(params, "i", id))
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /armour <armour>");
If(id > 100) return SendClientMessage(playerid, 0xFF0000AA, "Usage: Max Armour Is 100");
SetPlayerArmour(playerid, id);
// Do something
return 1;
}

COMMAND:health(playerid, params[])
{
new id;
if (sscanf(params, "i", id))
return SendClientMessage(playerid, 0xFF0000AA, "Usage: /health <health>");
If(id > 100) return SendClientMessage(playerid, 0xFF0000AA, "Usage: Max Health Is 100");
SetPlayerHealth(playerid, id);
// Do something
return 1;
}

pabloalber84ban
12/08/2017, 11:57 PM
COMMAND:armour(playerid, params[])
{
SetPlayerArmor(playerid, 100.0);
SendClientMessageEx(playerid, 0x00FF00, "Armour refilled.");
}
//
COMMAND:health(playerid, params[])
{
SetPlayerHealth(playerid, 100.0);
SendClientMessageEx(playerid, 0x00FF00, "Health refilled.");
}

KizZweLL
13/08/2017, 04:54 AM
Hello. If you want a command that will set a certain player's health when you type /health [ID]
here it is.


CMD:health(playerid,params[])
{
new id;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,0xFF0000FF,"/health [ID]");
SetPlayerHealth(id,100);
SendClientMessage(id,-1,"Your health has been restored");
return 1;
}


But if you want to make a /health command without id NOTE: It will only restore your HP
here it is.


CMD:health(playerid,params[])
{
SetPlayerHealth(playerid,100);
return 1;
}


If this solved your problem a thanks would be appreciated :)
if you want to do armour command just replace the Health to armour :)

spyro9696
13/08/2017, 07:49 AM
I resolved, thank you very much!