Using --; and ++; with a default number ?
#1

I Wanted to make something like..


--5; for example - instead of Just --; - But I Was wondering about the format ? Help would be appreciated
Reply
#2

What do u mean
Reply
#3

Then do "-5". "--" = Decrease by 1.

Ex:

PHP код:
amount-5// This will decrease "amount" by 5. 
PHP код:
amount--; //This will decrease "amount" by 1. It's the same as doing "amount-1;". 
Reply
#4

Thanks GTA Killer - But , "Amount" is the Variable Name - Right ?

EDIT : Nevermind xD - Repped+
Reply
#5

Still can't figure it out xD

This is how it goes :

PlayerInfo[playerid][MyVariable] -20;

- I Want it to subtract 20 of the amount he has.
Reply
#6

If you want to add or subtract a value, you need to use it like this:
Код:
var -= 20; // minus 20
var += 34; // plus 34
You can only use -- and ++ for quickly subtracting or adding 1
Reply
#7

Код:
PlayerInfo[playerid][MyVariable] -= 20;
equal
Код:
PlayerInfo[playerid][MyVariable] = PlayerInfo[playerid][MyVariable] - 20;
You can read more about it here: https://sampwiki.blast.hk/wiki/Scripting_Basics#Setting
Reply
#8

My bad

Thanks Cessil.
Reply
#9

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
That should work, what's wrong with it?
please have a basic understanding of scripting before you try to help others
https://sampwiki.blast.hk/wiki/Scripting_Basics#Setting
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)