SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/03/2017, 08:10 PM   #1
LeeXx
Little Clucker
 
Join Date: Mar 2017
Posts: 15
Reputation: 0
Default /sethp, /setarmour not working

Hello so basically i'm a newbie in scripting i tried making these 2 simple cmd's, but it doesn't work for a reason. When i try to test it on my ID, it says Player is not connected.

Here is the codes for /sethp cmd:

Code:
CMD:sethp(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin]>1337)
	{
	new Float:Health;
	new PID;
	if(sscanf(params, "ud", PID, Health)) return SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /sethp [playerid] [health]");
	if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, -1, "Player is not connected.");
	SetPlayerHealth(PID, Health);
	}
	else SendClientMessage(playerid, -1, "You are not authorized to use this command!");
	return 1;
}
And codes for /setarmour cmd:

Code:
CMD:setarmour(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin]>1337)
	{
	new float:Armour;
	new PID;
	if(sscanf(params,"ud",PID,Armour)) return SendClientMessage(playerid,COLOR_GRAD1,"USAGE: /setarmour [playerid] [armor]");
	if(!IsPlayerConnected(PID)) return SendClientMessage(playerid,COLOR_GRAD1,"Player is not connected.");
	SetPlayerArmour(playerid, Armour);
	}
	else SendClientMessage(playerid,-1,"You are not authorized to use this command!");
	return 1;
}
I get the same result for both CMD's, so i'm sure that i made something wrong but i cant find what is it...
LeeXx is offline   Reply With Quote
Old 28/03/2017, 08:35 PM   #2
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 822
Reputation: 130
Default Re: /sethp, /setarmour not working

Try removing "Float:Health" & "Float:Armor". You don't need the Float.
__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester

Kane is offline   Reply With Quote
Old 28/03/2017, 08:41 PM   #3
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 542
Reputation: 75
Default Re: /sethp, /setarmour not working

Eh?

PHP Code:
CMD:sethp(playerid,params[])
{
    new 
Float:HealthPID;
    if(
PlayerInfo[playerid][pAdmin] > 1337SendClientMessage(playerid, -1"You are not authorized to use this command!");
    if(
sscanf(params"uf"PIDHealth)) return SendClientMessage(playeridCOLOR_GRAD1"USAGE: /sethp [playerid] [health]");
    if(
PID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"Player is not connected.");
    
//else
    
SetPlayerHealth(PIDHealth);
    return 
1;
}

CMD:setarmour(playeridparams[])
{
    new 
float:ArmourPID;
    if(
PlayerInfo[playerid][pAdmin] > 1337SendClientMessage(playerid,-1,"You are not authorized to use this command!");
    if(
sscanf(params,"uf"PIDArmour)) return SendClientMessage(playerid,COLOR_GRAD1,"USAGE: /setarmour [playerid] [armor]");
    if(
PID == INVALID_PLAYER_ID)  return SendClientMessage(playerid,COLOR_GRAD1,"Player is not connected.");
    
//else
    
SetPlayerArmour(PIDArmour);
    return 
1;

ISmokezU is offline   Reply With Quote
Old 28/03/2017, 08:58 PM   #4
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,088
Reputation: 126
Default Re: /sethp, /setarmour not working

PHP Code:
if(!IsPlayerConnected(PID)) 
This will display the message if the player is connected.

EDIT:
PHP Code:
if(IsPlayerConnectedEx(PID)) return SendClientMessage(playerid,GREY,"Player is not connected"); 
jasperschellekens is offline   Reply With Quote
Old 29/03/2017, 07:31 AM   #5
LeeXx
Little Clucker
 
Join Date: Mar 2017
Posts: 15
Reputation: 0
Default Re: /sethp, /setarmour not working

I tried removing Flaot:health and armour, but nothing. And I thought this code

PHP Code:
if(!IsPlayerConnected(PID)) 
will display the message if the player is not connected with this sign "!"?
LeeXx is offline   Reply With Quote
Old 29/03/2017, 07:53 AM   #6
Tamer
High-roller
 
Tamer's Avatar
 
Join Date: Nov 2011
Location: Turkey
Posts: 1,099
Reputation: 172
Default Re: /sethp, /setarmour not working

Quote:
Originally Posted by LeeXx View Post
I tried removing Flaot:health and armour, but nothing. And I thought this code

PHP Code:
if(!IsPlayerConnected(PID)) 
will display the message if the player is not connected with this sign "!"?
! sign means NOT.

For example 1 != 2 one is NOT equal to two.

if(!IsPlayerConnected) if IsPlayer NOT connected.
__________________
The three stages of truth:

- Ridicule.
- Violent opposition.
- Acceptance.


Quote:
The greatest hypnotist on the planet Earth is an oblong box in the corner of the room. It is constantly telling us what to believe is real. If you can persuade people that what they see with their eyes is what there is to see you've got them. you know because they'll laugh in your face of an explanation that portrays the biggest picture of what's happening... and they have.
Tamer is offline   Reply With Quote
Old 29/03/2017, 08:29 AM   #7
LeeXx
Little Clucker
 
Join Date: Mar 2017
Posts: 15
Reputation: 0
Default Re: /sethp, /setarmour not working

So that means my codes are correct? Yet I still get the same result, when I try to /sethp [MyID] to test it, it shows the message ''Player is not connected''?
LeeXx is offline   Reply With Quote
Old 29/03/2017, 08:33 AM   #8
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,266
Reputation: 366
Default Re: /sethp, /setarmour not working

well, probably you got old sscanf or smth, try replacing "u" with "i" or "d" also its Float: not float:

so
PHP Code:
CMD:setarmour(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin]>1337)
    {
    new 
float:Armour;
    new 
PID;
    if(
sscanf(params,"ud",PID,Armour)) return SendClientMessage(playerid,COLOR_GRAD1,"USAGE: /setarmour [playerid] [armor]");
    if(!
IsPlayerConnected(PID)) return SendClientMessage(playerid,COLOR_GRAD1,"Player is not connected.");
    
SetPlayerArmour(playeridArmour);
    }
    else 
SendClientMessage(playerid,-1,"You are not authorized to use this command!");
    return 
1;

gotta be
PHP Code:
CMD:setarmour(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin]>1337)
    {
    new 
Float:Armour;
    new 
PID;
    if(
sscanf(params,"if",PID,Armour)) return SendClientMessage(playerid,COLOR_GRAD1,"USAGE: /setarmour [playerid] [armor]");
    if(!
IsPlayerConnected(PID)) return SendClientMessage(playerid,COLOR_GRAD1,"Player is not connected.");
    
SetPlayerArmour(PIDArmour);
    }
    else 
SendClientMessage(playerid,-1,"You are not authorized to use this command!");
    return 
1;

d,i for integers and u gets playerid by his name or by his id directly [ not supported by old sscanfs or supported but a bit bugged ]. and f for floats. so in your sscanf d has to be f as health and armour are Float values.

also
PHP Code:
SetPlayerArmour(playeridArmour); 
had to be
PHP Code:
SetPlayerArmour(PIDArmour); 
jlalt is offline   Reply With Quote
Old 29/03/2017, 09:06 AM   #9
LeeXx
Little Clucker
 
Join Date: Mar 2017
Posts: 15
Reputation: 0
Default Re: /sethp, /setarmour not working

Yeah it actually worked, thanks for explaining to me Jlalt. + rep my friend!
LeeXx is offline   Reply With Quote
Old 29/03/2017, 09:09 AM   #10
Juvanii
Huge Clucker
 
Juvanii's Avatar
 
Join Date: Jun 2014
Location: San Andreas
Posts: 373
Reputation: 21
Default Re: /sethp, /setarmour not working

Download the latest version of sscanf from:
http://forum.sa-mp.com/showthread.php?t=570927

PHP Code:
CMD:sethp(playerid,params[])
{
    new 
healthtargetid;
    if(
PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, -1"You are not authorized to use this command!");
    if(
sscanf(params"ui"targetidhealth)) return SendClientMessage(playeridCOLOR_GRAD1"USAGE: /sethp [playerid] [health]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"Player is not connected.");
    
SetPlayerHealth(targetidhealth);
    return 
1;
}

CMD:setarmour(playerid,params[])
{
    new 
armourtargetid;
    if(
PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, -1"You are not authorized to use this command!");
    if(
sscanf(params"ui"targetidhealth)) return SendClientMessage(playeridCOLOR_GRAD1"USAGE: /setarmour [playerid] [armour]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"Player is not connected.");
    
SetPlayerArmour(targetidarmour);
    return 
1;



EDIT: Too Late :))
__________________
Juvanii is offline   Reply With Quote
Reply

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
[Tutorial] Making /setarmour command Trollerz Tutorials 8 13/12/2014 01:51 PM
/sethp command not working arad55 Scripting Help 16 05/08/2014 12:55 AM
setarmour issue itsCody Scripting Help 2 19/06/2013 07:33 AM
[COMPILE ERROR] sethp abd setarmour! NewerthRoleplay Scripting Help 1 02/05/2012 03:09 PM
[HElp] /sethealth, /setarmour [Lsgw]LoL Help Archive 1 28/06/2011 12:49 PM


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


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