Doesen't work. (REP)
#1

Hello, i got a command which gives no errors or warnings but doesen't work.
Could anyone tell me what i'm doing wrong?

pawn Код:
CMD:setarmors(playerid, params[]) // Sasoft
{
    if (PlayerInfo[playerid][pAdmin] >= 3)
    {
        new string[128], radius, ar;
        if(sscanf(params, "dd", ar, radius))
        {
            SendClientMessageEx(playerid, COLOR_GRAD6, "[Syntax]: /setarmors [armor] [radius]");
            return 1;
        }
        if(radius < 1 || radius > 50)
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 51!");
            return 1;
        }
        if(ar < 1 || ar > 100)
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Armour must be higher than 1 and lower than 101!");
            return 1;
        }
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid,X, Y, Z);

        for (new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z))
            {
                SetPlayerArmour(playerid, ar);
                format(string, sizeof(string), "> Admin %s uses his magic and shoots a wave of armour in your direction.", GetPlayerNameEx(playerid));
                SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
            }
        }
        format(string, sizeof(string), "You have given everyone %d armour in %d radius", ar, radius);
        SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
Reply
#2

try this

pawn Код:
CMD:setarmors(playerid, params[]) // Sasoft
{
    if (PlayerInfo[playerid][pAdmin] >= 3)
    {
        new string[128], radius, ar;
        if(sscanf(params, "dd", ar, radius))
        {
            SendClientMessageEx(playerid, COLOR_GRAD6, "[Syntax]: /setarmors [armor] [radius]");
            return 1;
        }
        if(radius < 1 || radius > 50)
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 51!");
            return 1;
        }
        if(ar < 1 || ar > 100)
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Armour must be higher than 1 and lower than 101!");
            return 1;
        }
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid,X, Y, Z);

        for (new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(i, radius, X, Y, Z))
            {
                SetPlayerArmour(i, ar);
                format(string, sizeof(string), "> Admin %s uses his magic and shoots a wave of armour in your direction.", GetPlayerNameEx(playerid));
                SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
            }
        }
        format(string, sizeof(string), "You have given everyone %d armour in %d radius", ar, radius);
        SendClientMessageEx(playerid, COLOR_LIGHTGREEN, string);
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
[/QUOTE]
Reply
#3

Firstly I'd like to state that "radius" (used in IsPlayerInRangeOfPoint and the SSCANF function) should be a float instead of integrer, as also should the armor variable, because it needs a float. so you should use
pawn Код:
if(sscanf(params, "ff", ar, radius))
I'm not sure, but try it.
Reply
#4

Quote:
Originally Posted by CookieJar
Посмотреть сообщение
Firstly I'd like to state that "radius" (used in IsPlayerInRangeOfPoint and the SSCANF function) should be a float instead of integrer, as also should the armor variable, because it needs a float. so you should use
pawn Код:
if(sscanf(params, "ff", ar, radius))
I'm not sure, but try it.
This one is true, you should do that.

Also change
pawn Код:
new string[128], ar, radius;
to
pawn Код:
new string[128], Float:ar, Float:radius;
Reply
#5

Quote:
Originally Posted by Johnson_boy
Посмотреть сообщение
This one is true, you should do that.

Also change
pawn Код:
new string[128], ar, radius;
to
pawn Код:
new string[128], Float:ar, Float:radius;
Yeah sorry, I forgot about those variables
Reply
#6

As frangoth already posted change

if(IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z))
to
if(IsPlayerInRangeOfPoint(i, radius, X, Y, Z))

This will fix it, but also it would be good if you update your armour and radius into float from integer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)