Variables
#1

Hey guys! Code:
pawn Код:
1593:       new litai = GetPVarInt(playerid, "Myrelitai"); // here I use this variable FIRST time in this callback (OnPlayerSpawn). So here I get money from PVar.
1594:       if(litai > 99) {DuotiLitu(playerid, 100);} // if money is more than 99 so we give player 100.
1595:       else if(litai < 100) // else if money is less than 100, then...
1596:       {
1597:           new lits; // we declare new variable
1598:           lits = 100 - litai; // set its value tu 100-'litai', because 'litai' is greater than 100
1599:           DuotiLitu(playerid, lits); // and we give player money amount named 'lits'
1600:       }
Now about errors
Код:
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1593) : warning 219: local variable "litai" shadows a variable at a preceding level
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1594) : warning 213: tag mismatch
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1594) : warning 206: redundant test: constant expression is non-zero
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1595) : warning 213: tag mismatch
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1595) : warning 205: redundant code: constant expression is zero
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1598) : warning 213: tag mismatch
C:\Users\Kamilis2\Desktop\LVG\gamemodes\LVG.pwn(1593) : warning 204: symbol is assigned a value that is never used: "litai"
So what's happening?
Reply
#2

pawn Код:
new litai = GetPVarInt(playerid, "Myrelitai"); // here I use this variable FIRST time in this callback
     if(litai > 99) {DuotiLitu(playerid, 100);} // if money is more than 99 so we give player 100.
      else if(litai < 100) // else if money is less than 100, then...
      {
          new lits2; // we declare new variable
        lits2 = 100 - litai; // set its value tu 100-'litai', because 'litai' is greater than 100
          DuotiLitu(playerid, lits2); // and we give player money amount named 'lits'
   }
Reply
#3

Thanks bro, but still...
Reply
#4

I don't know why you are creating a new variable called "litai", if you are gonna store the exact values in Myrelitai for that, but you must simply use the other variable for that. No need to create a new one.
pawn Код:
if(Myrelitai > 99) {DuotiLitu(playerid, 100);} // if money is more than 99 so we give player 100.
      else if(Myrelitai < 100) // else if money is less than 100, then...
      {
          new lits; // we declare new variable
          lits = 100 - Myrelitai; // set its value tu 100-'litai', because 'litai' is greater than 100
          DuotiLitu(playerid, lits); // and we give player money amount named 'lits'
      }
Should work, cause you get errors for doing weird stuff with the new variable
Reply
#5

@NaClchemistryK: thanks, but I realised what I did wrong. It turns out, that I had written variable 'litai' in players' info enum. Yeah, I know, stupid mistake... Anyway + rep for both of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)