Errors & Problem
#1

This command compiles without errors but it does give a few warnings. Although when I go in game and type /sethp it says Unknown command.

Код:
	COMMAND::sethp(playerid, params[])
	{
		if (PlayerInfo[playerid][pAdmin] <= 1336)
  		{
	   		 new
				toplayer, // Player that is recieving HP
				newhp;
				
			if (!sscanf(params, "ii", toplayer, newhp))
			{
			    if (toplayer != INVALID_PLAYER_ID)
			    {
			        new
			            message[40];
					SetPlayerHealth(toplayer, newhp);
					format(message, sizeof(message), "Your HP has been set to $%d by an admin!", newhp);
					SendClientMessage(toplayer, COLOR_SYSTEM, message);
				}
				else SendClientMessage(playerid, COLOR_SYSTEM, "Invalid ID");
			}
			else SendClientMessage(playerid, COLOR_SYSTEM, "[SYNTAX:] /sethp [id] [hp]");
		}
		else SendClientMessage(playerid, COLOR_SYSTEM, "You're not authorized to use this command.");
		
        return 1;

	}
Warnings:

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\pawno\include\streamer.inc(408) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\gamemodes\RCRP.pwn(232) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\gamemodes\RCRP.pwn(248) : warning 213: tag mismatch
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\gamemodes\RCRP.pwn(511) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Warnings.
Also if anyone could tell me how to fix my other warnings (408 and 511).
Reply
#2

Try this.
pawn Код:
COMMAND::sethp(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] <= 1336)
    {
        new
            toplayer, // Player that is recieving HP
            Float:newhp;

        if (sscanf(params, "if", toplayer, newhp))
        {
            if (IsPlayerConnected(toplayer))
            {
                new
                    message[40];
                   
                SetPlayerHealth(toplayer, newhp);
                format(message, sizeof(message), "Your HP has been set to $%f by an admin!", newhp);
                SendClientMessage(toplayer, COLOR_SYSTEM, message);
            }
            else SendClientMessage(playerid, COLOR_SYSTEM, "Invalid ID");
        }
        else SendClientMessage(playerid, COLOR_SYSTEM, "[SYNTAX:] /sethp [id] [hp]");
    }
    else SendClientMessage(playerid, COLOR_SYSTEM, "You're not authorized to use this command.");

    return 1;

}
And for the other warnings, we need to see some code.
Reply
#3

Thanks, but when I try it, it still says Unknown command.

Anymore ideas? and I do have this just so you know.
Код:
#include <sscanf2>
#include <zcmd>
Reply
#4

You did COMMAND:: sethp.

It requires only one colon. COMMAND: sethp.

I suggest you use CMD: sethp, as its much smaller, but has the same effect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)