/sethp and /setarmor
#1

Hey guys i made this commmand but i am new in this lenguage of pawn and i dont know why my comands still not working i have no errors or warnings but always i use /sethp always kill me and never put the % of life i want to give...and with /sethp nothing happens, what can i do? by the way sorry for my bad english

this is my code :

PHP код:
CMD:sethp(playerid,params[])
    {
        if(
IsPlayerConnected(playerid))
        {
           new 
id,Float:c;
        if(
sscanf(params,"rf",id,c))
        {
        
SendClientMessage(playeridCOLOR_GRAD"USAGE: /sethp [Playerid/PartOfName] [Health]");
        return 
1;
        }
        if (
PlayerInfo[playerid][pAdmin] >= 4)
        {
          if(
IsPlayerConnected(id))
        {
         if(
id!= INVALID_PLAYER_ID)
          {
        
SetPlayerHealth(idc);
        }
        }
        }
        else
        {
          
SendClientMessage(playeridCOLOR_GRAD"You are not authorized to use that command!");
        }
        }
        return 
1;
    }
CMD:setarmor(playerid,params[])
    {
        if(
IsPlayerConnected(playerid))
        {
         new 
id,Float:c;
        if(
sscanf(params,"rf",id,c))
        {
        
SendClientMessage(playeridCOLOR_GRAD"USAGE: /setarmor [Playerid/PartOfName] [Armor]");
        return 
1;
        }
        if (
PlayerInfo[playerid][pAdmin] >= 4)
        {
          if(
IsPlayerConnected(id))
        {
         if(
id!= INVALID_PLAYER_ID)
          {
        
SetPlayerArmour(idc);
        }
        }
        }
        else
        {
          
SendClientMessage(playeridCOLOR_GRAD"You are not authorized to use that command!");
        }
        }
        return 
1;
    } 
Reply
#2

I simplified your commands, see below:
Код:
CMD:sethp(playerid, params[])
{
	new id, hp;
	if(PlayerInfo[playerid][pAdmin] >= 4) return SendClientMessage(playerid, COLOR_GRAD, "You are not authorized to use that command!");
    if(sscanf(params, "ud", id, hp)) return SendClientMessage(playerid, COLOR_GRAD, "USAGE: /sethp [Playerid/PartOfName] [Health]"); 
	if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[Error] Player not connected.");

	new Float:hp2 = float(hp);
	SetPlayerHealth(id, hp2);
	return 1;
}

CMD:setarmor(playerid, params[])
{
	new id, armor;
	if(PlayerInfo[playerid][pAdmin] >= 4) return SendClientMessage(playerid, COLOR_GRAD, "You are not authorized to use that command!");
    if(sscanf(params, "ud", id, armor)) return SendClientMessage(playerid, COLOR_GRAD, "USAGE: /setarmor [Playerid/PartOfName] [Armor]"); 
	if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[Error] Player not connected.");

	new Float:armor2 = float(armor);
	SetPlayerArmour(id, armor2);
	return 1;
}
The problem with your commands I believe was that you weren't converting the user input health/armor amount from an integer (/sethp JohnKiller 99) to a float (new Float:armor2 = float(armor).
Reply
#3

Код:
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1465) : warning 204: symbol is assigned a value that is never used: "armor2"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
also i cant use the cmd because its says you're not autorized...
Reply
#4

Quote:
Originally Posted by Jaua10
Посмотреть сообщение
Код:
C:\Users\Jaua\Downloads\gta-rp\gamemodes\GTARP.pwn(1465) : warning 204: symbol is assigned a value that is never used: "armor2"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
also i cant use the cmd because its says you're not autorized...
PHP код:
CMD:sethp(playeridparams[])
{
    new 
idFloat:hp;
    if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridCOLOR_GRAD"You are not authorized to use that command!");
    if(
sscanf(params"uf"idhp)) return SendClientMessage(playeridCOLOR_GRAD"USAGE: /sethp [Playerid/PartOfName] [Health]"); 
    if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"[Error] Player not connected.");
    
SetPlayerHealth(idhp);
    return 
1;
}
CMD:setarmor(playeridparams[])
{
    new 
idFloat:armor;
    if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridCOLOR_GRAD"You are not authorized to use that command!");
    if(
sscanf(params"uf"idarmor)) return SendClientMessage(playeridCOLOR_GRAD"USAGE: /setarmor [Playerid/PartOfName] [Armor]"); 
    if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"[Error] Player not connected.");
    
SetPlayerArmour(idarmor);
    return 
1;

Reply
#5

Excelent now its workign, thanks alot guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)