SA-MP Forums Archive
Wiki mistake? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wiki mistake? (/showthread.php?tid=488014)



Wiki mistake? - [WA]iRonan - 16.01.2014

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.



Re: Wiki mistake? - Konstantinos - 16.01.2014

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;
}



Re: Wiki mistake? - Zex Tan - 16.01.2014

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


Re: Wiki mistake? - [WA]iRonan - 16.01.2014

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;


Re: Wiki mistake? - erminpr0 - 16.01.2014

Код:
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



Re: Wiki mistake? - Zex Tan - 16.01.2014

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

pawn Код:
enum
{
     float:health
}



Re: Wiki mistake? - Konstantinos - 16.01.2014

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.