Wiki mistake?
#1

The wiki seems to have a mistake.

pawn Код:
public OnPlayerUpdate(playerid)
    {
        new Float:health;
        GetPlayerHealth(playerid,health);
        if (health < 50.0)
        {
            SetPlayerHealth(playerid, 50.0);
        }
        return 1;
    }
This is copied straight from the wiki, just changed the command to OnPlayerUpdate.

Errors appear:
pawn Код:
E:\SAMP\RPG all\RPG\gamemodes\rc-apo.pwn(848) : warning 219: local variable "health" shadows a variable at a preceding level
E:\SAMP\RPG all\RPG\gamemodes\rc-apo.pwn(849) : error 035: argument type mismatch (argument 2)
E:\SAMP\RPG all\RPG\gamemodes\rc-apo.pwn(850) : warning 213: tag mismatch
E:\SAMP\RPG all\RPG\gamemodes\rc-apo.pwn(850) : warning 206: redundant test: constant expression is non-zero
E:\SAMP\RPG all\RPG\gamemodes\rc-apo.pwn(848) : warning 203: symbol is never used: "health"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

Everything is fine with the example, it's just your fault that health is declared as global variable. Just change the name:

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float: fHealth;
    GetPlayerHealth(playerid, fHealth);
    if (fHealth < 50.0) SetPlayerHealth(playerid, 50.0);
    return 1;
}
Reply
#3

Do you have an enum in Player Info which has an Health array in it? You could use that array instead of creating new variables again.

Like:
Код:
GetPlayerHealth(playerid, PlayerAcc[playerid][Health]);
EDIT: late :P
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Everything is fine with the example, it's just your fault that health is declared as global variable. Just change the name:

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float: fHealth;
    GetPlayerHealth(playerid, fHealth);
    if (fHealth < 50.0) SetPlayerHealth(playerid, 50.0);
    return 1;
}
I fixed it already and yeah it was messing up with an enumerator, my mistake I tought it was bugged at the wiki.

I got another problem though.
pawn Код:
public OnPlayerUpdate(playerid)
    {
        new Float:HealthX;
        GetPlayerHealth(playerid, HealthX);
        pStats[playerid][health] = Float:HealthX; // Tag Mismatch
        return 1;
    }
outputs a Tag Mismatch.

Also tried to do pStats[playerid][health] = HealthX;
Reply
#5

Код:
public OnPlayerUpdate(playerid)
    {
        new Float:HealthX;
        GetPlayerHealth(playerid, HealthX);
        pStats[playerid][health] = HealthX;
        return 1;
    }
Be sure your variable 'health', whether in enumerator or not, have 'Float' tag

Код:
Float:health
Reply
#6

Your pStats[playerid][health] in your enum should be

pawn Код:
enum
{
     float:health
}
Reply
#7

Quote:
Originally Posted by [WA]iRonan
Посмотреть сообщение
I fixed it already and yeah it was messing up with an enumerator, my mistake I tought it was bugged at the wiki.

I got another problem though.
pawn Код:
public OnPlayerUpdate(playerid)
    {
        new Float:HealthX;
        GetPlayerHealth(playerid, HealthX);
        pStats[playerid][health] = Float:HealthX; // Tag Mismatch
        return 1;
    }
outputs a Tag Mismatch.

Also tried to do pStats[playerid][health] = HealthX;
In the enum is used for pStats, health should have the Float: tag.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)