SA-MP Forums Archive
Warning for adding +4 for Player's Variable - 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: Warning for adding +4 for Player's Variable (/showthread.php?tid=437344)



Warning for adding +4 for Player's Variable - Zex Tan - 15.05.2013

I got a warning for this

pawn Код:
-Code Removed -
Warning:
Код:
E:\San Andreas Multiplayer Server Files (Classified)\Castaway Island Roleplay\gamemodes\CI-RP.pwn(1936) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Anyone know how to fix this ?


Re: Warning for adding +4 for Player's Variable - Emmet_ - 15.05.2013

pawn Код:
CMD:levelup(playerid, params[])
{
    new str[64];
    if(PlayerInfo[playerid][Exp] >= PlayerInfo[playerid][Expt])
    {
        PlayerInfo[playerid][Exp] = 0;
        PlayerInfo[playerid][Expt] += 4;
        PlayerInfo[playerid][Level] ++;
        SendClientMessage(playerid, -1, "You've reached to a new level");
    }
    else
    {
        format(str, sizeof(str), "You need %d Experience Points inorder to Level up", PlayerInfo[playerid][Expt]);
        SendClientMessage(playerid, COL_RED, "You need %d Experience Points inorder to Level up");
    }
    return 1;
}



Re: Warning for adding +4 for Player's Variable - RajatPawar - 15.05.2013

You can't do something like that. Do it like -
pawn Код:
var += 4;
EDIT:A bit late.


Re: Warning for adding +4 for Player's Variable - Zex Tan - 15.05.2013

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
pawn Код:
-Code Removed -
Gosh, silly me. Anyway Thanks


Re: Warning for adding +4 for Player's Variable - Zex Tan - 15.05.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
Doing:

pawn Код:
a + 4;
Has no effect, that's a sum but you do nothing with the result. It's like doing:

pawn Код:
8 + 4;
That doesn't change the value of 8, it just creates s new number, but nowhere do you store that new number.
O.... I understand now. Thanks for the explanation.