Damage erro
#1

pawn Код:
//local variable "playerid" shadows a variable at a preceding level

public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0); // Ding Sound
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(weaponid == 24) SetPlayerHealth(playerid, HP-75);//DesertEagle
    if(weaponid == 22) SetPlayerHealth(playerid, HP-30);//Colt45
    if(weaponid == 32) SetPlayerHealth(playerid, HP-10);//Tec9
    if(weaponid == 28) SetPlayerHealth(playerid, HP-10);//Uzi
    if(weaponid == 23) SetPlayerHealth(playerid, HP-35);//SilencedColt
    if(weaponid == 31) SetPlayerHealth(playerid, HP-45);//M4
    if(weaponid == 30) SetPlayerHealth(playerid, HP-45);//AK
    if(weaponid == 29) SetPlayerHealth(playerid, HP-35);//MP5
    if(weaponid == 34) SetPlayerHealth(playerid, HP-30);//SniperRifle
    if(weaponid == 33) SetPlayerHealth(playerid, HP-50);//CuntGun
    if(weaponid == 25) SetPlayerHealth(playerid, HP-55);//PumpShotgun
    if(weaponid == 27) SetPlayerHealth(playerid, HP-65);//Spaz12
    return 1;
}
Reply
#2

the identifer of a global variable has to be unique.

meaning something like
pawn Код:
#include    "a_samp"

main(){}

new random_stuff;

public OnGamemodeInit()
{
    new random_stuff;
   
    return 1;
}
will throw the same warning.
"warning 219: local variable "random_stuff" shadows a variable at a preceding level"

this means that somewhere in your script is a variable by the name "playerid"

search for it and get rid of it.
especially "playerid" as identifer... really bad choice if it's a global one,
as most of the callbacks contain a "playerid" param.

also, generating too much global variables isn't good.
Stuff will get messy after some time.
Try to stay local & use pointers wherever you can

also, i suggest using a switch instead of these endless control structures
Reply
#3

So what should i do
Reply
#4

Quote:
Originally Posted by Gogeta101
Посмотреть сообщение
So what should i do
search for the variable shadowing "playerid" with the identifer "playerid" and get rid of it or rename it.

example:

pawn Код:
#include    "a_samp"

main(){}

new random_stuff_ABC;//now it's not shadowing other variables (like the one in OnGamemodeinit), it's unique now, just as it should be.

public OnGamemodeInit()
{
    new random_stuff;
   
    return 1;
}
identifers of global variables HAVE to be unique, just like
id's in CSS
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)