-- and ++ - 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: -- and ++ (
/showthread.php?tid=545859)
-- and ++ -
BoU3A - 11.11.2014
what is -- and ++ mean in pawn?
Re: -- and ++ -
Eth - 11.11.2014
-- means it will decrease the amount of something by 1
and ++ means it will increase the amount of something by 1.
here is an example:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerDeath[playerid] ++; // increase the player death by one
PlayerScore[playerid] --; //will decrease the player score by one
return 1;
}
and its the same as:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerDeath[playerid] += 1; // increase the player death by one
PlayerScore[playerid] -= 1; //will decrease the player score by one
return 1;
}
Re: -- and ++ -
dominik523 - 11.11.2014
Quote:
Originally Posted by Eth
-- means it will decrease the amount of something by 1
and ++ means it will increase the amount of something by 1.
here is an example:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { PlayerDeath[playerid] ++; // increase the player death by one PlayerScore[playerid] --; //will decrease the player score by one return 1; }
and its the same as:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { PlayerDeath[playerid] += 1; // increase the player death by one PlayerScore[playerid] -= 1; //will decrease the player score by one return 1; }
|
Just to add something to your explanation.
++/-- can be used also like this:
pawn Код:
// foo++
new foo;
if(foo++ == 0) // foo variable is currently 0, and after the checking, it's 1
// ++foo
if(++foo == 0) // Variable foo is increased by one, and then it's checked if it's 0